Package com.speedment.runtime.compute
Interface ToEnum<T,E extends Enum<E>>
-
- Type Parameters:
T- type to extract fromE- enum type
- All Superinterfaces:
Comparator<T>,Expression<T>,Function<T,E>,HasCompare<T>,HasCompose<T>,HasHash<T>,HasMap<T,UnaryOperator<E>,ToEnum<T,E>>
- All Known Subinterfaces:
ToEnumOrElse<T,E>,ToEnumOrElseGet<T,E>,ToEnumOrThrow<T,E>
public 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>
Expression that given an entity returns a non-nullenumvalue. The expression also knows about the enum class and can therefore not be implemented as a lambda like the other expressions in this module.- Since:
- 3.1.0
- Author:
- Emil Forslund
- See Also:
Function
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Eapply(T t)default ToString<T>asName()Returns an alternative expression that represents theEnum.name()of the enum that would otherwise have been returned by this expression.default ToInt<T>asOrdinal()Returns an alternative expression that represents theEnum.ordinal()of the enum that would otherwise have been returned by this expression.default intcompare(T first, T second)default <V> ToEnumNullable<V,E>compose(Function<? super V,? extends T> before)Returns a composed expression that first applies thebeforefunction to its input, and then applies this function to the result.Class<E>enumClass()Returns theclassof the enum that this expression returns.default ExpressionTypeexpressionType()Returns the expression type of this expression.default longhash(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>>
ToEnum<T,E>of(Class<E> enumClass, Function<T,E> lambda)Returns a typedToEnum<T>using the providedlambda.-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Method Detail
-
of
static <T,E extends Enum<E>> ToEnum<T,E> of(Class<E> enumClass, Function<T,E> lambda)
Returns a typedToEnum<T>using the providedlambda.- Type Parameters:
T- type to extract fromE- enum type- Parameters:
lambda- to convertenumClass- class of the enum- Returns:
- a typed
ToEnum<T>using the providedlambda - Throws:
NullPointerException- if the providedlambdaisnull
-
enumClass
Class<E> enumClass()
Returns theclassof the enum that this expression returns.- Returns:
- the enum class
-
expressionType
default ExpressionType expressionType()
Description copied from interface:ExpressionReturns the expression type of this expression. It should be safe to cast this instance into the corresponding interface.- Specified by:
expressionTypein interfaceExpression<T>- Returns:
- the expression type
-
asOrdinal
default ToInt<T> asOrdinal()
Returns an alternative expression that represents theEnum.ordinal()of the enum that would otherwise have been returned by this expression.- Returns:
- the ordinal expression
-
asName
default ToString<T> asName()
Returns an alternative expression that represents theEnum.name()of the enum that would otherwise have been returned by this expression.- Returns:
- the name expression
-
map
default ToEnum<T,E> map(UnaryOperator<E> mapper)
Description copied from interface:HasMapReturns an expression for the value of this expression mapped using the specified mapping function. The input type remains the same.
-
hash
default long hash(T object)
Description copied from interface:HasHashHash the specified object into a 64-bit hash. If two equal objects are hashed, they must always result in the same hash. However, objects that are not equal may also result in the same hash.
-
compare
default int compare(T first, T second)
- Specified by:
comparein interfaceComparator<T>- Specified by:
comparein interfaceHasCompare<T>
-
compose
default <V> ToEnumNullable<V,E> compose(Function<? super V,? extends T> before)
Description copied from interface:HasComposeReturns a composed expression that first applies thebeforefunction 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.- Specified by:
composein interfaceFunction<T,E extends Enum<E>>- Specified by:
composein interfaceHasCompose<T>- Type Parameters:
V- the type of input to thebeforefunction, and to the composed expression- Parameters:
before- the function to apply before this function is applied- Returns:
- a composed function that first applies the
beforefunction and then applies this function
-
-