T
- type to extract fromE
- enum typepublic interface ToEnum<T,E extends Enum<E>> extends Expression<T>, Function<T,E>, HasMap<T,UnaryOperator<E>,ToEnum<T,E>>, HasHash<T>, HasCompare<T>, HasCompose<T>
enum
value. The
expression also knows about the enum class and can therefore not be
implemented as a lambda like the other expressions in this module.Function
Modifier and Type | Method and Description |
---|---|
E |
apply(T t) |
default ToString<T> |
asName()
Returns an alternative expression that represents the
Enum.name()
of the enum that would otherwise have been returned by this expression. |
default ToInt<T> |
asOrdinal()
Returns an alternative expression that represents the
Enum.ordinal() of the enum that would otherwise have been
returned by this expression. |
default int |
compare(T first,
T second) |
default <V> ToEnumNullable<V,E> |
compose(Function<? super V,? extends T> before)
Returns a composed expression that first applies the
before
function to its input, and then applies this function to the result. |
Class<E> |
enumClass()
Returns the
class of the enum that this expression returns. |
default ExpressionType |
expressionType()
Returns the expression type of this expression.
|
default long |
hash(T object)
Hash the specified object into a 64-bit hash.
|
default ToEnum<T,E> |
map(UnaryOperator<E> mapper)
Returns an expression for the value of this expression mapped using the
specified mapping function.
|
static <T,E extends Enum<E>> |
of(Class<E> enumClass,
Function<T,E> lambda)
Returns a typed
ToEnum<T> using the provided
lambda . |
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
static <T,E extends Enum<E>> ToEnum<T,E> of(Class<E> enumClass, Function<T,E> lambda)
ToEnum<T>
using the provided
lambda
.T
- type to extract fromE
- enum typelambda
- to convertenumClass
- class of the enumToEnum<T>
using the provided
lambda
NullPointerException
- if the provided lambda
is
null
Class<E> enumClass()
class
of the enum that this expression returns.default ExpressionType expressionType()
Expression
expressionType
in interface Expression<T>
default ToInt<T> asOrdinal()
Enum.ordinal()
of the enum that would otherwise have been
returned by this expression.default ToString<T> asName()
Enum.name()
of the enum that would otherwise have been returned by this expression.default ToEnum<T,E> map(UnaryOperator<E> mapper)
HasMap
default long hash(T object)
HasHash
default int compare(T first, T second)
compare
in interface Comparator<T>
compare
in interface HasCompare<T>
default <V> ToEnumNullable<V,E> compose(Function<? super V,? extends T> before)
HasCompose
before
function to its input, and then applies this function to the result.
If evaluation of either function throws an exception, it is relayed to
the caller of the composed function.compose
in interface Function<T,E extends Enum<E>>
compose
in interface HasCompose<T>
V
- the type of input to the before
function, and to the
composed expressionbefore
- the function to apply before this function is appliedbefore
function and then applies this functionCopyright © 2019 Speedment, Inc.. All rights reserved.