public final class Functions extends Object
| Modifier and Type | Method and Description |
|---|---|
static <N extends Number> |
abs()
Returns the absolute value of an argument.
|
static <T> Function<T,Number> |
abs(Function<T,? extends Number> selector)
Returns the absolute value of an argument evaluation result.
|
static <T,U> BiFunction<T,U,Number> |
add(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of
left.apply(T) + right.apply(U). |
static <T,U> BiPredicate<T,U> |
and(Function<T,Boolean> left,
Function<U,Boolean> right)
Returns the value of
left.apply(T) && right.apply(U). |
static <T,U> BiPredicate<T,U> |
and(Predicate<T> left,
Predicate<U> right)
Returns the value of
left.apply(T) && right.apply(U). |
static <T,U> BiFunction<T,U,Number> |
bitwiseAnd(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of
left.apply(T) & right.apply(U). |
static Function<?,Number> |
bitwiseNot()
Returns the bitwise not value of an argument.
|
static Function<?,Number> |
bitwiseNot(Function<?,? extends Number> selector)
Returns the bitwise not value of an argument evaluation result.
|
static <T,U> BiFunction<T,U,Number> |
bitwiseOr(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of
left.apply(T) | right.apply(U). |
static <T,Result> Function<T,Result> |
constant(Result result)
Represents a function returning a constant value.
|
static <T,U> BiFunction<T,U,Number> |
divide(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of
left.apply(T) / right.apply(U). |
static <T,U> BiPredicate<T,U> |
equal(Function<T,?> left,
Function<U,?> right)
Returns the value of
left.apply(T) == right.apply(U). |
static <T,Result> Function<T,Result> |
field(Class<? super T> outerType,
String fieldName)
Represents a function returning value of a field using reflection.
|
static <T,U,Key extends Comparable<Key>> |
greaterThan(Function<T,Key> left,
Function<U,Key> right)
Returns the value of
left.apply(T) > right.apply(U). |
static <T,U,Key extends Comparable<Key>> |
greaterThanOrEqual(Function<T,Key> left,
Function<U,Key> right)
Returns the value of
left.apply(T) >= right.apply(U). |
static <Result,T> Function<T,Result> |
iif(Function<? super T,Boolean> predicate,
Function<? super T,? extends Result> ifTrue,
Function<? super T,? extends Result> ifFalse)
Returns the value of
predicate.apply(T) ? ifTrue.apply(T) : ifFalse.apply(T). |
static <Result,T> Predicate<T> |
instanceOf(Function<? super T,? extends Result> operand,
Class<?> type)
Returns the value of
operand.apply(T) instanceof type. |
static <T,U,Key extends Comparable<Key>> |
lessThan(Function<T,Key> left,
Function<U,Key> right)
Returns the value of
left.apply(T) < right.apply(U). |
static <T,U,Key extends Comparable<Key>> |
lessThanOrEqual(Function<T,Key> left,
Function<U,Key> right)
Returns the value of
left.apply(T) <= right.apply(U). |
static <T,U> BiFunction<T,U,Number> |
modulo(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of
left.apply(T) % right.apply(U). |
static <T,U> BiFunction<T,U,Number> |
multiply(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of
left.apply(T) * right.apply(U). |
static Function<?,Number> |
negate()
Returns the negative value of an argument.
|
static Function<?,Number> |
negate(Function<?,? extends Number> selector)
Returns the negative value of an argument evaluation result.
|
static <T> Predicate<T> |
not(Function<T,Boolean> predicate)
Negates the return value of a predicate.
|
static <T,U> BiPredicate<T,U> |
or(Function<T,Boolean> left,
Function<U,Boolean> right)
Returns the value of
left.apply(T) || right.apply(U). |
static <T,U> BiPredicate<T,U> |
or(Predicate<T> left,
Predicate<U> right)
Returns the value of
left.apply(T) || right.apply(U). |
static <T,U> BiFunction<T,U,Number> |
power(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of left.apply(T)right.apply(U).
|
static <T,Result> Function<T,Result> |
property(Class<? super T> outerType,
String propertyName)
Represents a function returning value of a property using reflection.
|
static <T,U> BiFunction<T,U,Number> |
shiftLeft(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of
left.apply(T) << right.apply(U). |
static <T,U> BiFunction<T,U,Number> |
shiftRight(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of
left.apply(T) >> right.apply(U). |
static <T,U> BiFunction<T,U,Number> |
subtract(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of
left.apply(T) - right.apply(U). |
static <T,U> BiFunction<T,U,Number> |
xor(Function<T,? extends Number> left,
Function<U,? extends Number> right)
Returns the value of
left.apply(T) ^ right.apply(U). |
public static <T> Function<T,Number> abs(Function<T,? extends Number> selector)
abs(selector.apply(N))T - the type of the input type.selector - a function to extract the numeric value from T.public static <N extends Number> Function<N,Number> abs()
N - the type of the argument.public static Function<?,Number> negate(Function<?,? extends Number> selector)
-selector.invoke(?)selector - a function to negate the numeric parameter.public static Function<?,Number> negate()
public static Function<?,Number> bitwiseNot(Function<?,? extends Number> selector)
~selector.invoke(?)selector - a function to complement the numeric parameter.public static Function<?,Number> bitwiseNot()
public static <T,U> BiFunction<T,U,Number> bitwiseAnd(Function<T,? extends Number> left, Function<U,? extends Number> right)
left.apply(T) & right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) & right.apply(U)public static <T,U> BiFunction<T,U,Number> add(Function<T,? extends Number> left, Function<U,? extends Number> right)
left.apply(T) + right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) + right.apply(U)public static <T,U> BiFunction<T,U,Number> subtract(Function<T,? extends Number> left, Function<U,? extends Number> right)
left.apply(T) - right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) - right.apply(U)public static <T,U> BiFunction<T,U,Number> multiply(Function<T,? extends Number> left, Function<U,? extends Number> right)
left.apply(T) * right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) * right.apply(U)public static <T,U> BiFunction<T,U,Number> divide(Function<T,? extends Number> left, Function<U,? extends Number> right)
left.apply(T) / right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) / right.apply(U)public static <T,U> BiFunction<T,U,Number> modulo(Function<T,? extends Number> left, Function<U,? extends Number> right)
left.apply(T) % right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) % right.apply(U)public static <T,U> BiFunction<T,U,Number> bitwiseOr(Function<T,? extends Number> left, Function<U,? extends Number> right)
left.apply(T) | right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) | right.apply(U)public static <T,U> BiFunction<T,U,Number> power(Function<T,? extends Number> left, Function<U,? extends Number> right)
T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.public static <T,U> BiFunction<T,U,Number> shiftLeft(Function<T,? extends Number> left, Function<U,? extends Number> right)
left.apply(T) << right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) << right.apply(U)public static <T,U> BiFunction<T,U,Number> shiftRight(Function<T,? extends Number> left, Function<U,? extends Number> right)
left.apply(T) >> right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) >> right.apply(U)public static <T,U> BiFunction<T,U,Number> xor(Function<T,? extends Number> left, Function<U,? extends Number> right)
left.apply(T) ^ right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) ^ right.apply(U)public static <T,U> BiPredicate<T,U> and(Predicate<T> left, Predicate<U> right)
left.apply(T) && right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) && right.apply(U)public static <T,U> BiPredicate<T,U> and(Function<T,Boolean> left, Function<U,Boolean> right)
left.apply(T) && right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) && right.apply(U)public static <T,U> BiPredicate<T,U> or(Predicate<T> left, Predicate<U> right)
left.apply(T) || right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) || right.apply(U)public static <T,U> BiPredicate<T,U> or(Function<T,Boolean> left, Function<U,Boolean> right)
left.apply(T) || right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) || right.apply(U)public static <T,U,Key extends Comparable<Key>> BiPredicate<T,U> lessThan(Function<T,Key> left, Function<U,Key> right)
left.apply(T) < right.apply(U).T - the type of the first argument.U - the type of the second argument.Key - the type of the value to compare on.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) < right.apply(U)public static <T,U,Key extends Comparable<Key>> BiPredicate<T,U> lessThanOrEqual(Function<T,Key> left, Function<U,Key> right)
left.apply(T) <= right.apply(U).T - the type of the first argument.U - the type of the second argument.Key - the type of the value to compare on.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) <= right.apply(U)public static <T,U> BiPredicate<T,U> equal(Function<T,?> left, Function<U,?> right)
left.apply(T) == right.apply(U).T - the type of the first argument.U - the type of the second argument.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) == right.apply(U)public static <T,U,Key extends Comparable<Key>> BiPredicate<T,U> greaterThanOrEqual(Function<T,Key> left, Function<U,Key> right)
left.apply(T) >= right.apply(U).T - the type of the first argument.U - the type of the second argument.Key - the type of the value to compare on.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) >= right.apply(U)public static <T,U,Key extends Comparable<Key>> BiPredicate<T,U> greaterThan(Function<T,Key> left, Function<U,Key> right)
left.apply(T) > right.apply(U).T - the type of the first argument.U - the type of the second argument.Key - the type of the value to compare on.left - a function to extract the left hand value from T.right - a function to extract the right hand value from T.left.apply(T) > right.apply(U)public static <T,Result> Function<T,Result> constant(Result result)
Result - the type of returned value.T - the type of the ignored argument.result - value to return.public static <T,Result> Function<T,Result> property(Class<? super T> outerType, String propertyName) throws NoSuchMethodException
Result - the type of returned value.T - the type of the argument.outerType - Class of the objects in the sequence.propertyName - name of the property to retrieve. The implementation will look for get<propertyName>() method.NoSuchMethodException - if a matching method is not found.public static <T,Result> Function<T,Result> field(Class<? super T> outerType, String fieldName) throws NoSuchFieldException
Result - the type of returned value.T - the type of the argument.outerType - Class of the objects in the sequence.fieldName - name of the field to retrieve.NoSuchFieldException - if a field with the specified name is not found.public static <Result,T> Predicate<T> instanceOf(Function<? super T,? extends Result> operand, Class<?> type)
operand.apply(T) instanceof type.Result - the type of returned value.T - the type of the argument.operand - a function to extract the operand from Ttype - the Class to test by.operand.apply(T) instanceof type.public static <Result,T> Function<T,Result> iif(Function<? super T,Boolean> predicate, Function<? super T,? extends Result> ifTrue, Function<? super T,? extends Result> ifFalse)
predicate.apply(T) ? ifTrue.apply(T) : ifFalse.apply(T).
Note, that either ifTrue or ifFalse function is evaluated.
Result - the type of returned value.T - the type of the argument.predicate - predicate to test.ifTrue - a function to evaluate if predicate returns true.ifFalse - a function to evaluate if predicate returns false.predicate.apply(T) ? ifTrue.apply(T) : ifFalse.apply(T).public static <T> Predicate<T> not(Function<T,Boolean> predicate)
!predicate.apply(T).T - the type of the argument.predicate - predicate to negate its evaluation result.!predicate.apply(T).Copyright © 2023 Streamx. All rights reserved.