T
- type to extract fromE
- enum typepublic interface ToEnumNullable<T,E extends Enum<E>> extends Expression<T>, ToNullable<T,E,ToEnum<T,E>>, HasMapToDoubleIfPresent<T,ToDoubleFunction<E>>, HasMapIfPresent<T,UnaryOperator<E>,ToEnumNullable<T,E>>, HasHash<T>, HasCompare<T>, HasCompose<T>
enum
value, or
null
. 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 |
---|---|
default ToStringNullable<T> |
asName()
Returns an alternative expression that represents the
Enum.name()
of the enum that would otherwise have been returned by this expression. |
default ToIntNullable<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 ToEnumNullable<T,E> |
mapIfPresent(UnaryOperator<E> mapper)
Returns an expression for the value of this expression mapped using the
specified mapping function.
|
default ToDoubleNullable<T> |
mapToDoubleIfPresent(ToDoubleFunction<E> mapper)
Maps the result of this expression into a
double by passing it to
the specified mapper , producing a new expression that implements
ToDouble . |
static <T,E extends Enum<E>> |
of(Class<E> enumClass,
Function<T,E> lambda)
Returns a typed
ToEnumNullable<T> using the provided
lambda . |
default ToEnum<T,E> |
orElse(E value)
Returns an equivalent expression as this, except that it will return
the
value if given an argument that would cause this
expression to return null . |
default ToEnum<T,E> |
orElseGet(ToEnum<T,E> getter)
Returns an equivalent expression as this, except that it will return
the
getter expression if given an argument that would cause this
expression to return null . |
default ToEnum<T,E> |
orThrow()
Returns an equivalent expression as this, except that it will throw a
NullPointerException if given an argument that would cause this
expression to return null . |
isNotNull, isNotNull, isNull, isNull
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
static <T,E extends Enum<E>> ToEnumNullable<T,E> of(Class<E> enumClass, Function<T,E> lambda)
ToEnumNullable<T>
using the provided
lambda
.T
- type to extract fromE
- enum typelambda
- to convertenumClass
- class for the enumToEnumNullable<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 ToIntNullable<T> asOrdinal()
Enum.ordinal()
of the enum that would otherwise have been
returned by this expression.
If this expression would have returned null
, then the new
expression will also evaluate to null
.
default ToStringNullable<T> asName()
Enum.name()
of the enum that would otherwise have been returned by this expression.
If this expression would have returned null
, then the new
expression will also evaluate to null
.
default ToEnum<T,E> orThrow()
ToNullable
NullPointerException
if given an argument that would cause this
expression to return null
.default ToEnum<T,E> orElseGet(ToEnum<T,E> getter)
ToNullable
getter
expression if given an argument that would cause this
expression to return null
.default ToEnum<T,E> orElse(E value)
ToNullable
value
if given an argument that would cause this
expression to return null
.default ToDoubleNullable<T> mapToDoubleIfPresent(ToDoubleFunction<E> mapper)
HasMapToDoubleIfPresent
double
by passing it to
the specified mapper
, producing a new expression that implements
ToDouble
. If this expression would have evaluated to
null
, then the new expression will as well.mapToDoubleIfPresent
in interface HasMapToDoubleIfPresent<T,ToDoubleFunction<E extends Enum<E>>>
mapper
- the mapper to use on the result of this expressiondefault ToEnumNullable<T,E> mapIfPresent(UnaryOperator<E> mapper)
HasMapIfPresent
mapIfPresent
in interface HasMapIfPresent<T,UnaryOperator<E extends Enum<E>>,ToEnumNullable<T,E extends Enum<E>>>
mapper
- the mapping functiondefault 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.