-
- Type Parameters:
T- type to extract from
- All Superinterfaces:
Comparator<T>,Expression<T>,HasAsDouble<T>,HasAsInt<T>,HasAsLong<T>,HasCompare<T>,HasCompose<T>,HasHash<T>,HasMap<T,BooleanUnaryOperator,ToBoolean<T>>,HasMapToDouble<T,BooleanToDoubleFunction>,Predicate<T>,ToBooleanFunction<T>
- All Known Subinterfaces:
ToBooleanOrElse<T>,ToBooleanOrElseGet<T>,ToBooleanOrThrow<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface ToBoolean<T> extends Expression<T>, ToBooleanFunction<T>, HasAsDouble<T>, HasAsInt<T>, HasAsLong<T>, HasMap<T,BooleanUnaryOperator,ToBoolean<T>>, HasMapToDouble<T,BooleanToDoubleFunction>, HasHash<T>, HasCompare<T>, HasCompose<T>
Expression that given an entity returns abooleanvalue. This expression can be implemented using a lambda, or it can be a result of another operation. It has additional methods for operating on it.- Since:
- 3.1.0
- Author:
- Emil Forslund
- See Also:
ToBooleanFunction,Predicate
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleanapplyAsBoolean(T object)default ToDouble<T>asDouble()Returns an expression that casts the result of the current expression into adouble.default ToInt<T>asInt()Returns an expression that casts the result of the current expression into anint.default ToLong<T>asLong()Returns an expression that casts the result of the current expression into along.default intcompare(T first, T second)default <V> ToBoolean<V>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.default <V> ToBooleanNullable<V>composeNullable(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.default ExpressionTypeexpressionType()Returns the expression type of this expression.default longhash(T object)Hash the specified object into a 64-bit hash.default ToBoolean<T>map(BooleanUnaryOperator operator)Returns an expression for the value of this expression mapped using the specified mapping function.default ToDouble<T>mapToDouble(BooleanToDoubleFunction operator)Maps the result of this expression into adoubleby passing it to the specifiedmapper, producing a new expression that implementsToDouble.static <T> ToBoolean<T>of(Predicate<T> lambda)Returns a typedToBoolean<T>using the providedlambda.-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface com.speedment.common.function.ToBooleanFunction
test
-
-
-
-
Method Detail
-
of
static <T> ToBoolean<T> of(Predicate<T> lambda)
Returns a typedToBoolean<T>using the providedlambda.- Type Parameters:
T- type to extract from- Parameters:
lambda- to convert- Returns:
- a typed
ToBoolean<T>using the providedlambda - Throws:
NullPointerException- if the providedlambdaisnull
-
applyAsBoolean
boolean applyAsBoolean(T object)
- Specified by:
applyAsBooleanin interfaceToBooleanFunction<T>
-
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
-
asDouble
default ToDouble<T> asDouble()
Description copied from interface:HasAsDoubleReturns an expression that casts the result of the current expression into adouble.- Specified by:
asDoublein interfaceHasAsDouble<T>- Returns:
- the casted expression
-
asInt
default ToInt<T> asInt()
Description copied from interface:HasAsIntReturns an expression that casts the result of the current expression into anint.
-
asLong
default ToLong<T> asLong()
Description copied from interface:HasAsLongReturns an expression that casts the result of the current expression into along.
-
mapToDouble
default ToDouble<T> mapToDouble(BooleanToDoubleFunction operator)
Description copied from interface:HasMapToDoubleMaps the result of this expression into adoubleby passing it to the specifiedmapper, producing a new expression that implementsToDouble.- Specified by:
mapToDoublein interfaceHasMapToDouble<T,BooleanToDoubleFunction>- Parameters:
operator- the mapper to use on the result of this expression- Returns:
- the new mapped expression
-
map
default ToBoolean<T> map(BooleanUnaryOperator operator)
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> ToBoolean<V> 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. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.ToBooleanis a bit special when it comes to thecompose()-method. If thebeforemethod returnsnull, the composed expression will returnfalse. This is to remain compatible with how Speedment handles predicates in streams. To get aToBooleanNullablethat acts as you might expect, instead usecompose(java.util.function.Function<? super V, ? extends T>)- Specified by:
composein interfaceHasCompose<T>- Type Parameters:
V- the input type of thebeforefunction- Parameters:
before- the function to apply before this function is applied- Returns:
- the composed expression
-
composeNullable
default <V> ToBooleanNullable<V> composeNullable(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. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.- Type Parameters:
V- the input type of thebeforefunction- Parameters:
before- the function to apply before this function is applied- Returns:
- the composed expression
- Since:
- 3.1.2
-
-