public final class Functions
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.Runnable |
EMPTY_RUNNABLE
An empty runnable.
|
static Pred0 |
FALSE
Constant parameterless function which returns always false.
|
static Func1<java.lang.Integer,java.lang.Long> |
INT_TO_LONG
Casts an integer value to long.
|
static Func1<java.lang.Long,java.lang.Integer> |
LONG_TO_INT
Converts a long to integer, ignoring any overflow or underflow.
|
static Func1<java.lang.Long,java.lang.Integer> |
LONG_TO_INT_CHECKED
Converts a long to integer or throws an ArithmeticException if
overflow or underflow happens.
|
static Pred0 |
TRUE
Constant parameterless function which returns always true.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> Pred1<T> |
alwaysFalse1()
Returns a function which always returns false regardless of its parameters.
|
static <T,U> Pred2<T,U> |
alwaysFalse2()
Returns a function which always returns false regardless of its parameters.
|
static <T> Pred1<T> |
alwaysTrue1()
Returns a function which always returns true regardless of its parameters.
|
static <T,U> Pred2<T,U> |
alwaysTrue2()
Returns a function which always returns true regardless of its parameters.
|
static Func2<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean> |
and() |
static Func0<java.lang.Boolean> |
and(Func0<java.lang.Boolean> f1,
Func0<java.lang.Boolean> f2)
Returns a function which takes the logical AND of the given two functions when invoked.
|
static <T> Func1<T,java.lang.Boolean> |
and(Func1<? super T,java.lang.Boolean> f1,
Func1<? super T,java.lang.Boolean> f2)
Returns a function which takes the logical AND of the given two functions when invoked.
|
static <T,U> Func2<T,U,java.lang.Boolean> |
and(Func2<? super T,? super U,java.lang.Boolean> f1,
Func2<? super T,? super U,java.lang.Boolean> f2)
Returns a function which takes the logical AND of the given two functions when invoked.
|
static <T> Func0<java.util.ArrayList<T>> |
arrayListProvider()
A list creator factory.
|
static <T,U> Func1<U,java.util.ArrayList<T>> |
arrayListProvider1()
A list creator factory for Func1 that ignores the parameter.
|
static <T> java.util.concurrent.Callable<T> |
asCallable(Func0<? extends T> func)
Wraps the given Func0 object into a callable instance.
|
static <T> java.util.Comparator<T> |
asComparator(Func2<? super T,? super T,java.lang.Integer> func)
Wrap the given two argument function returning an integer as a comparator.
|
static Func1<java.lang.Integer,java.lang.Double> |
asDoubleFunc1(java.util.List<? extends java.lang.Number> values)
Wrap the given list of number into a function which
returns the
param1 element as double. |
static <T> Func0<T> |
asFunc0(Action0 action,
T result)
Wraps the given action into a function which calls the
action and then returns the
result value. |
static Func0<java.lang.Boolean> |
asFunc0(java.util.concurrent.atomic.AtomicBoolean source)
Wraps the given atomic boolean and returns its value.
|
static Func0<java.lang.Integer> |
asFunc0(java.util.concurrent.atomic.AtomicInteger source)
Wraps the given atomic integer object and returns its value.
|
static Func0<java.lang.Long> |
asFunc0(java.util.concurrent.atomic.AtomicLong source)
Wraps the given atomic integer object and returns its value.
|
static <T> Func0<T> |
asFunc0(java.util.concurrent.atomic.AtomicReference<? extends T> source)
Wraps the given atomic reference object and returns its value.
|
static <T> Func0<T> |
asFunc0(java.util.concurrent.Callable<? extends T> call)
Wraps the given Callable function into a Func0 object.
|
static <T> Func0<T> |
asFunc0(java.lang.ref.Reference<? extends T> ref)
Wrap the given reference into a function.
|
static <T> Func0<T> |
asFunc0(java.lang.Runnable action,
T result)
Wraps the given Runnable into a function which calls the
action and then returns the
result value. |
static <T,U> Func1<T,U> |
asFunc1(Action0 action,
U result)
Wraps the given action into a function which calls the
action and then returns the
result value. |
static <T,U> Func1<T,U> |
asFunc1(Action1<? super T> action,
U result)
Wraps the given action into a function which calls the
action and then returns the
result value. |
static <T,U> Func1<T,U> |
asFunc1(java.util.concurrent.Callable<? extends U> call)
Wraps the given callable function into a 1 parameter function.
|
static Func1<java.lang.Integer,java.lang.Double> |
asFunc1(double... values)
Wrap the given one dimensional array into a function which
returns the
param1 element. |
static <T,U> Func1<T,U> |
asFunc1(Func0<? extends U> f)
Wraps the given zero parameter function into a 1 parameter function which
ignores its parameter.
|
static Func1<java.lang.Integer,java.lang.Integer> |
asFunc1(int... values)
Wrap the given one dimensional array into a function which
returns the
param1 element. |
static <T> Func1<java.lang.Integer,T> |
asFunc1(java.util.List<? extends T> values)
Wrap the given list into a function which
returns the
param1 element. |
static Func1<java.lang.Integer,java.lang.Long> |
asFunc1(long... values)
Wrap the given one dimensional array into a function which
returns the
param1 element. |
static <K,V> Func1<K,V> |
asFunc1(java.util.Map<? super K,? extends V> map)
Creates a single parameter function which returns values from the given map.
|
static <T,U> Func1<T,U> |
asFunc1(java.lang.Runnable action,
U result)
Wraps the given Runnable into a function which calls the
action and then returns the
result value. |
static <K> Func1<K,java.lang.Boolean> |
asFunc1(java.util.Set<? super K> set)
Creates a single parameter predicate function which returns true if the supplied
parameter is in the given collection.
|
static <T,U,V> Func2<T,U,V> |
asFunc2(Action0 action,
V value)
Wraps the given action into a 2 parameter function which returns the supplied value.
|
static <T,U,V> Func2<T,U,V> |
asFunc2(Action2<? super T,? super U> action,
V result)
Wraps the given action into a function which calls the
action and then returns the
result value. |
static <T,U,V> Func2<T,U,V> |
asFunc2(java.util.concurrent.Callable<? extends V> call)
Wraps the given callable function into a 2 parameter function.
|
static <T> Func2<T,T,java.lang.Integer> |
asFunc2(java.util.Comparator<? super T> comparator)
Wrap the given comparator function into a function object.
|
static Func2<java.lang.Integer,java.lang.Integer,java.lang.Double> |
asFunc2(double[][] values)
Wrap the given two dimensional array into a function which
returns the
param1, param2 element. |
static <T,U,V> Func2<T,U,V> |
asFunc2(Func0<? extends V> f)
Wraps the given zero parameter function into a 2 parameter function which
ignores its parameters.
|
static Func2<java.lang.Integer,java.lang.Integer,java.lang.Integer> |
asFunc2(int[][] values)
Wrap the given two dimensional array into a function which
returns the
param1, param2 element. |
static Func2<java.lang.Integer,java.lang.Integer,java.lang.Long> |
asFunc2(long[][] values)
Wrap the given two dimensional array into a function which
returns the
param1, param2 element. |
static <K1,K2,V> Func2<K1,K2,V> |
asFunc2(java.util.Map<? super K1,? extends java.util.Map<? super K2,? extends V>> map)
Wraps a two-layer (map of map of something) into a two parameter function.
|
static <T,U,V> Func2<T,U,V> |
asFunc2(java.lang.Runnable action,
V value)
Wraps the given Runnable into a 2 parameter function which returns the supplied value.
|
static <T> Func2<java.lang.Integer,java.lang.Integer,T> |
asFunc2(T[][] values)
Wrap the given two dimensional array into a function which
returns the
param1, param2 element. |
static Func1<java.lang.Integer,java.lang.Integer> |
asIntFunc1(java.util.List<? extends java.lang.Number> values)
Wrap the given list of number into a function which
returns the
param1 element as int. |
static Func1<java.lang.Integer,java.lang.Long> |
asLongFunc1(java.util.List<? extends java.lang.Number> values)
Wrap the given list of number into a function which
returns the
param1 element as long. |
static <T extends java.lang.Comparable<? super T>> |
comparator()
Returns a convenience comparator which basically compares
objects which implement the
Comparable
interface. |
static <T extends java.lang.Comparable<? super T>> |
comparator0()
Returns a convenience comparator which basically compares objects which implement the
Comparable
interface. |
static <T extends java.lang.Comparable<? super T>> |
comparatorReverse()
Creates a new comparator which reverses the order of the comparison.
|
static <T> java.util.Comparator<T> |
comparatorReverse(java.util.Comparator<? super T> normal)
Creates a new comparator which reverses the order produced by the given
normal comparator.
|
static <K,V> Func0<java.util.concurrent.ConcurrentHashMap<K,V>> |
concurrentHashMapProvider()
A map creator factory.
|
static <Param1,Result> |
constant(Result value)
Creates a function which returns always the same value.
|
static <T> Func0<T> |
constant0(T value)
Creates a function which returns always the same value.
|
static <T,U,V> Func2<T,U,V> |
constant2(V value)
Creates a constant function which always returns the given
value regardless of the parameters.
|
static Func1<java.math.BigInteger,java.math.BigInteger> |
decrementBigInteger() |
static Func1<java.lang.Integer,java.lang.Integer> |
decrementInt() |
static Func1<java.lang.Long,java.lang.Long> |
decrementLong() |
static <T> Func1<T,java.lang.Boolean> |
equal(T value)
Returns a function which returns true if its submitted parameter
value equals to the given constant.
|
static <T> Func2<T,T,java.lang.Boolean> |
equals()
Returns a function which compares its two parameters by a null-safe
equals.
|
static <T extends java.lang.Comparable<? super T>> |
greaterOrEqual(T value)
Create a function which returns true for submitted values greater or equal than the given value.
|
static <T> Func1<T,java.lang.Boolean> |
greaterOrEqual(T value,
java.util.Comparator<? super T> comparator)
Returns a function which returns true if the function parameter
is greater or equal to the constant in respect to the supplied comparator.
|
static <T extends java.lang.Comparable<? super T>> |
greaterThan(T value)
Create a function which returns true for submitted values greater
than the given value.
|
static <T> Func1<T,java.lang.Boolean> |
greaterThan(T value,
java.util.Comparator<? super T> comparator)
Returns a function which returns true if the function parameter
is greater than the constant in respect to the supplied comparator.
|
static <K,V> Func0<java.util.HashMap<K,V>> |
hashMapProvider()
A map creator factory.
|
static <T> Func0<java.util.HashSet<T>> |
hashSetProvider()
A set creation provider.
|
static <T> Func1<T,T> |
identity()
Returns a function which returns its parameter value.
|
static <T,U> Func2<T,U,T> |
identityFirst()
Returns a helper function of two parameters which always returns its first parameter.
|
static <T,U> Func2<T,U,U> |
identitySecond()
Returns a helper function of two parameters which always returns its second parameter.
|
static Func1<java.math.BigInteger,java.math.BigInteger> |
incrementBigInteger() |
static Func1<java.lang.Integer,java.lang.Integer> |
incrementBy(int value)
Returns a function which increments its parameter by the given amount.
|
static Func1<java.lang.Long,java.lang.Long> |
incrementBy(long value)
Returns a function which increments its parameter by the given amount.
|
static Func1<java.lang.Integer,java.lang.Integer> |
incrementInt() |
static Func1<java.lang.Long,java.lang.Long> |
incrementLong() |
static <T extends java.lang.Comparable<? super T>> |
lessOrEqual(T value)
Create a function which returns true for submitted values less or equal
than the given value.
|
static <T> Func1<T,java.lang.Boolean> |
lessOrEqual(T value,
java.util.Comparator<? super T> comparator)
Create a function which returns true for submitted values less or equal
than the given value in respect to the supplied comparator.
|
static <T extends java.lang.Comparable<? super T>> |
lessThan(T value)
Create a function which returns true for submitted values less
than the given value.
|
static <T> Func1<T,java.lang.Boolean> |
lessThan(T value,
java.util.Comparator<? super T> comparator)
Create a function which returns true for submitted values less
than the given value in respect to the supplied comparator.
|
static <K,V> Func0<java.util.LinkedHashMap<K,V>> |
linkedHashMapProvider()
A map creator factory.
|
static <T> Func0<java.util.LinkedList<T>> |
linkedListProvider()
A list creator factory.
|
static <T extends java.lang.Comparable<? super T>> |
max()
Returns a function which returns the greater of its parameters.
|
static <T> Func2<T,T,T> |
max(java.util.Comparator<? super T> comparator)
Returns a function which returns the greater of its parameters in respect to the supplied
Comparator. |
static <T extends java.lang.Comparable<? super T>> |
min()
Returns a function which returns the smaller of its parameters.
|
static <T> Func2<T,T,T> |
min(java.util.Comparator<? super T> comparator)
Returns a function which returns the smaller of its parameters in respect to the supplied
Comparator. |
static Func1<java.lang.Boolean,java.lang.Boolean> |
negate() |
static Func0<java.lang.Boolean> |
not(Func0<java.lang.Boolean> func)
Creates a function which negates the supplied function's value.
|
static <T> Func1<T,java.lang.Boolean> |
not(Func1<? super T,java.lang.Boolean> f)
Returns a function which creates the logical not of the wrapped function value for value t:T.
|
static <T,U> Func2<T,U,java.lang.Boolean> |
not(Func2<? super T,? super U,java.lang.Boolean> f)
Returns a function which creates the logical not of the wrapped function value for value
t:T and u:U.
|
static <T> Func1<T,java.lang.Boolean> |
notEqual(T value)
Returns a function which returns true if its sumbitted parameter
value does not equal to the given constant.
|
static Func2<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean> |
or() |
static Func0<java.lang.Boolean> |
or(Func0<java.lang.Boolean> f1,
Func0<java.lang.Boolean> f2)
Returns a function which takes the logical OR of the given two functions when invoked.
|
static <T> Func1<T,java.lang.Boolean> |
or(Func1<? super T,java.lang.Boolean> f1,
Func1<? super T,java.lang.Boolean> f2)
Returns a function which takes the logical OR of the given two functions when invoked.
|
static <T,U> Func2<T,U,java.lang.Boolean> |
or(Func2<? super T,? super U,java.lang.Boolean> f1,
Func2<? super T,? super U,java.lang.Boolean> f2)
Returns a function which takes the logical OR of the given two functions when invoked.
|
static <T,U> Func2<T,U,Pair<T,U>> |
pairUp() |
static Func2<java.math.BigDecimal,java.math.BigDecimal,java.math.BigDecimal> |
sumBigDecimal()
Retuns a function that adds two BigDecimal numbers and
returns a new one.
|
static Func2<java.math.BigInteger,java.math.BigInteger,java.math.BigInteger> |
sumBigInteger()
Retuns a function that adds two BigInteger numbers and
returns a new one.
|
static Func2<java.lang.Double,java.lang.Double,java.lang.Double> |
sumDouble()
Retuns a function that adds two Double number and
returns a new one.
|
static Func2<java.lang.Float,java.lang.Float,java.lang.Float> |
sumFloat()
Retuns a function that adds two Float number and
returns a new one.
|
static Func2<java.lang.Integer,java.lang.Integer,java.lang.Integer> |
sumInteger()
Retuns a function that adds two Integer number and
returns a new one.
|
static Func2<java.lang.Long,java.lang.Long,java.lang.Long> |
sumLong()
Retuns a function that adds two Long number and
returns a new one.
|
static <T,U,V> Func2<T,U,V> |
swap(Func2<U,T,V> func)
Returns a function which calls the supplied
function with swapped parameter order.
|
static <K,V> Func0<java.util.TreeMap<K,V>> |
treeMapProvider()
A map creator factory.
|
static <K,V> Func0<java.util.TreeMap<K,V>> |
treeMapProvider(java.util.Comparator<? super K> keyComparator)
A map creator factory.
|
static <T> Func0<java.util.TreeSet<T>> |
treeSetProvider()
A set creation provider.
|
static <T> Func0<java.util.TreeSet<T>> |
treeSetProvider(java.util.Comparator<? super T> elementComparator)
A set creation provider.
|
static Func0<java.lang.Boolean> |
xor(Func0<java.lang.Boolean> f1,
Func0<java.lang.Boolean> f2)
Returns a function which takes the logical XOR of the given two functions when invoked.
|
static <T> Func1<T,java.lang.Boolean> |
xor(Func1<? super T,java.lang.Boolean> f1,
Func1<? super T,java.lang.Boolean> f2)
Returns a function which takes the logical XOR of the given two functions when invoked.
|
static <T,U> Func2<T,U,java.lang.Boolean> |
xor(Func2<? super T,? super U,java.lang.Boolean> f1,
Func2<? super T,? super U,java.lang.Boolean> f2)
Returns a function which takes the logical XOR of the given two functions when invoked.
|
@Nonnull public static final Pred0 FALSE
@Nonnull public static final Pred0 TRUE
@Nonnull public static final java.lang.Runnable EMPTY_RUNNABLE
public static final Func1<java.lang.Integer,java.lang.Long> INT_TO_LONG
LONG_TO_INT_CHECKED,
LONG_TO_INTpublic static final Func1<java.lang.Long,java.lang.Integer> LONG_TO_INT_CHECKED
LONG_TO_INT,
INT_TO_LONGpublic static final Func1<java.lang.Long,java.lang.Integer> LONG_TO_INT
LONG_TO_INT_CHECKED,
INT_TO_LONG@Nonnull public static <T> Pred1<T> alwaysFalse1()
T - the type of the parameter (irrelevant)@Nonnull public static <T> Pred1<T> alwaysTrue1()
T - the type of the parameter (irrelevant)@Nonnull public static <T,U> Pred2<T,U> alwaysFalse2()
T - the type of the parameter (irrelevant)U - the type of the parameter (irrelevant)@Nonnull public static <T,U> Pred2<T,U> alwaysTrue2()
T - the type of the parameter (irrelevant)U - the type of the parameter (irrelevant)@Nonnull
public static <T> java.util.concurrent.Callable<T> asCallable(@Nonnull
Func0<? extends T> func)
T - the return typefunc - the function to wrap@Nonnull
public static <T> java.util.Comparator<T> asComparator(@Nonnull
Func2<? super T,? super T,java.lang.Integer> func)
T - the type of the elements to comparefunc - the function to wrap@Nonnull public static <T> Func0<T> asFunc0(@Nonnull Action0 action, T result)
result value.T - the result typeaction - the action to invokeresult - the result to present after the action invocation@Nonnull public static <T,U> Func1<T,U> asFunc1(@Nonnull Action1<? super T> action, U result)
result value.T - the parameter typeU - the result typeaction - the action to invokeresult - the result to present after the action invocation@Nonnull public static <T,U,V> Func2<T,U,V> asFunc2(@Nonnull Action2<? super T,? super U> action, V result)
result value.T - the first parameter typeU - the second parameter typeV - the result typeaction - the action to invokeresult - the result to present after the action invocation@Nonnull public static <T> Func0<T> asFunc0(@Nonnull java.util.concurrent.Callable<? extends T> call)
T - the return type of the functioncall - the original call function@Nonnull public static <T> Func2<T,T,java.lang.Integer> asFunc2(@Nonnull java.util.Comparator<? super T> comparator)
T - the type of elements to comparecomparator - the comparator@Nonnull public static Func0<java.lang.Boolean> asFunc0(@Nonnull java.util.concurrent.atomic.AtomicBoolean source)
source - the source atomic reference@Nonnull public static Func0<java.lang.Integer> asFunc0(@Nonnull java.util.concurrent.atomic.AtomicInteger source)
source - the source atomic reference@Nonnull public static Func0<java.lang.Long> asFunc0(@Nonnull java.util.concurrent.atomic.AtomicLong source)
source - the source atomic reference@Nonnull public static <T> Func0<T> asFunc0(@Nonnull java.util.concurrent.atomic.AtomicReference<? extends T> source)
T - the type of the contained objectsource - the source atomic reference@Nonnull public static <T extends java.lang.Comparable<? super T>> java.util.Comparator<T> comparator()
Comparable
interface. The comparator is null safe in the manner,
that nulls are always less than any non-nulls.
To have a comparator which places nulls last, use the comparator0() method.T - the element types to comparecomparator0()@Nonnull public static <T extends java.lang.Comparable<? super T>> java.util.Comparator<T> comparator0()
Comparable
interface. The comparator is null safe in the manner, that nulls are always greater than any non-nulls.
To have a comparator which places nulls first, use the comparator() method.T - the element types to compare@Nonnull public static <T extends java.lang.Comparable<? super T>> java.util.Comparator<T> comparatorReverse()
T - the element type, which must be self comparable@Nonnull
public static <T> java.util.Comparator<T> comparatorReverse(@Nonnull
java.util.Comparator<? super T> normal)
T - the element typenormal - the normal comparator@Nonnull public static <Param1,Result> Func1<Param1,Result> constant(Result value)
Param1 - the parameter type, irrelevantResult - the value type to returnvalue - the value to return@Nonnull public static <T> Func0<T> constant0(T value)
T - the value type to returnvalue - the value to return@Nonnull public static Func1<java.math.BigInteger,java.math.BigInteger> decrementBigInteger()
BigIntegers.@Nonnull public static Func1<java.lang.Integer,java.lang.Integer> decrementInt()
@Nonnull public static Func1<java.lang.Long,java.lang.Long> decrementLong()
@Nonnull public static <T> Func1<T,java.lang.Boolean> equal(T value)
T - the value typevalue - the value@Nonnull public static <T extends java.lang.Comparable<? super T>> Func1<T,java.lang.Boolean> greaterOrEqual(@Nonnull T value)
T - a type which is comparable with itselfvalue - constant to compare against@Nonnull public static <T> Func1<T,java.lang.Boolean> greaterOrEqual(@Nonnull T value, @Nonnull java.util.Comparator<? super T> comparator)
T - the value typevalue - constant to compare againstcomparator - the comparator for Ts.@Nonnull public static <T extends java.lang.Comparable<? super T>> Func1<T,java.lang.Boolean> greaterThan(@Nonnull T value)
T - a type which is comparable with itselfvalue - constant to compare against@Nonnull public static <T> Func1<T,java.lang.Boolean> greaterThan(@Nonnull T value, @Nonnull java.util.Comparator<? super T> comparator)
T - the value typevalue - constant to compare againstcomparator - the comparator for Ts.@Nonnull public static <T> Func1<T,T> identity()
T - the type of the object@Nonnull public static <T,U> Func2<T,U,T> identityFirst()
T - the result and the first parameter typeU - the second parameter type, irrelevant@Nonnull public static <T,U> Func2<T,U,U> identitySecond()
T - the result and the second parameter typeU - the first parameter type, irrelevant@Nonnull public static Func1<java.math.BigInteger,java.math.BigInteger> incrementBigInteger()
BigIntegers.@Nonnull public static Func1<java.lang.Integer,java.lang.Integer> incrementBy(int value)
value - the value to increment by@Nonnull public static Func1<java.lang.Long,java.lang.Long> incrementBy(long value)
value - the value to increment by@Nonnull public static Func1<java.lang.Integer,java.lang.Integer> incrementInt()
@Nonnull public static Func1<java.lang.Long,java.lang.Long> incrementLong()
@Nonnull public static <T extends java.lang.Comparable<? super T>> Func1<T,java.lang.Boolean> lessOrEqual(@Nonnull T value)
T - a type which is comparable to itselfvalue - constant to compare against@Nonnull public static <T> Func1<T,java.lang.Boolean> lessOrEqual(@Nonnull T value, @Nonnull java.util.Comparator<? super T> comparator)
T - a type which is comparable to itselfvalue - constant to compare againstcomparator - the comparator@Nonnull public static <T extends java.lang.Comparable<? super T>> Func1<T,java.lang.Boolean> lessThan(@Nonnull T value)
T - a type which is comparable with itselfvalue - constant to compare against@Nonnull public static <T> Func1<T,java.lang.Boolean> lessThan(@Nonnull T value, @Nonnull java.util.Comparator<? super T> comparator)
T - a type which is comparable to itselfvalue - constant to compare againstcomparator - the comparator@Nonnull public static <T extends java.lang.Comparable<? super T>> Func2<T,T,T> max()
T - the parameter types, which must be self-comparable@Nonnull public static <T> Func2<T,T,T> max(@Nonnull java.util.Comparator<? super T> comparator)
Comparator.
If only one of the parameters is null, the other parameter is returned.
If both parameters are null, null is returned.T - the parameter types, which must be self-comparablecomparator - the value comparator@Nonnull public static <T extends java.lang.Comparable<? super T>> Func2<T,T,T> min()
T - the parameter types, which must be self-comparable@Nonnull public static <T> Func2<T,T,T> min(@Nonnull java.util.Comparator<? super T> comparator)
Comparator.
If only one of the parameters is null, the other parameter is returned.
If both parameters are null, null is returned.T - the parameter types, which must be self-comparablecomparator - the value comparator@Nonnull public static Func0<java.lang.Boolean> not(@Nonnull Func0<java.lang.Boolean> func)
func - the original function@Nonnull public static <T> Func1<T,java.lang.Boolean> notEqual(@Nonnull T value)
T - the value typevalue - the value@Nonnull public static Func2<java.math.BigDecimal,java.math.BigDecimal,java.math.BigDecimal> sumBigDecimal()
If the first parameter is null, it returns the second parameter.
@Nonnull public static Func2<java.math.BigInteger,java.math.BigInteger,java.math.BigInteger> sumBigInteger()
If the first parameter is null, it returns the second parameter.
@Nonnull public static Func2<java.lang.Double,java.lang.Double,java.lang.Double> sumDouble()
If the first parameter is null, it returns the second parameter.
@Nonnull public static Func2<java.lang.Float,java.lang.Float,java.lang.Float> sumFloat()
If the first parameter is null, it returns the second parameter.
@Nonnull public static Func2<java.lang.Integer,java.lang.Integer,java.lang.Integer> sumInteger()
If the first parameter is null, it returns the second parameter.
@Nonnull public static Func2<java.lang.Long,java.lang.Long,java.lang.Long> sumLong()
If the first parameter is null, it returns the second parameter.
@Nonnull public static <T> Func2<T,T,java.lang.Boolean> equals()
T - the parameter type@Nonnull public static <K,V> Func1<K,V> asFunc1(@Nonnull java.util.Map<? super K,? extends V> map)
K - the key typeV - the value typemap - the backing map.@Nonnull public static <K1,K2,V> Func2<K1,K2,V> asFunc2(@Nonnull java.util.Map<? super K1,? extends java.util.Map<? super K2,? extends V>> map)
If the first level map returns null, the function returns null.
K1 - the first level key typeK2 - the second level key typeV - the value type typemap - the source map of map of something@Nonnull public static <K> Func1<K,java.lang.Boolean> asFunc1(@Nonnull java.util.Set<? super K> set)
K - the element typeset - the backing set@Nonnull public static <T> Func0<java.util.ArrayList<T>> arrayListProvider()
T - the value type@Nonnull public static <T,U> Func1<U,java.util.ArrayList<T>> arrayListProvider1()
T - the value typeU - the function parameter type, ignored@Nonnull public static <T> Func0<java.util.LinkedList<T>> linkedListProvider()
T - the value type@Nonnull public static <K,V> Func0<java.util.HashMap<K,V>> hashMapProvider()
K - the key typeV - the value type@Nonnull public static <K,V> Func0<java.util.TreeMap<K,V>> treeMapProvider()
K - the key typeV - the value type@Nonnull public static <K,V> Func0<java.util.TreeMap<K,V>> treeMapProvider(@Nonnull java.util.Comparator<? super K> keyComparator)
K - the key typeV - the value typekeyComparator - the key comparator function@Nonnull public static <K,V> Func0<java.util.LinkedHashMap<K,V>> linkedHashMapProvider()
K - the key typeV - the value type@Nonnull public static <K,V> Func0<java.util.concurrent.ConcurrentHashMap<K,V>> concurrentHashMapProvider()
K - the key typeV - the value type@Nonnull public static <T> Func0<java.util.HashSet<T>> hashSetProvider()
T - the element type@Nonnull public static <T> Func0<java.util.TreeSet<T>> treeSetProvider()
T - the element type@Nonnull public static <T> Func0<java.util.TreeSet<T>> treeSetProvider(@Nonnull java.util.Comparator<? super T> elementComparator)
T - the element typeelementComparator - the custom element comparator@Nonnull public static Func2<java.lang.Integer,java.lang.Integer,java.lang.Double> asFunc2(@Nonnull double[][] values)
param1, param2 element.values - the values@Nonnull public static Func2<java.lang.Integer,java.lang.Integer,java.lang.Integer> asFunc2(@Nonnull int[][] values)
param1, param2 element.values - the values@Nonnull public static Func2<java.lang.Integer,java.lang.Integer,java.lang.Long> asFunc2(@Nonnull long[][] values)
param1, param2 element.values - the values@Nonnull public static <T> Func2<java.lang.Integer,java.lang.Integer,T> asFunc2(@Nonnull T[][] values)
param1, param2 element.T - the element typevalues - the values@Nonnull public static Func1<java.lang.Integer,java.lang.Double> asFunc1(@Nonnull double... values)
param1 element.values - the values@Nonnull public static Func1<java.lang.Integer,java.lang.Long> asFunc1(@Nonnull long... values)
param1 element.values - the values@Nonnull public static Func1<java.lang.Integer,java.lang.Integer> asFunc1(@Nonnull int... values)
param1 element.values - the values@Nonnull public static <T> Func1<java.lang.Integer,T> asFunc1(@Nonnull java.util.List<? extends T> values)
param1 element.T - the element typevalues - the values@Nonnull public static Func1<java.lang.Integer,java.lang.Double> asDoubleFunc1(@Nonnull java.util.List<? extends java.lang.Number> values)
param1 element as double.values - the values@Nonnull public static Func1<java.lang.Integer,java.lang.Integer> asIntFunc1(@Nonnull java.util.List<? extends java.lang.Number> values)
param1 element as int.values - the values@Nonnull public static Func1<java.lang.Integer,java.lang.Long> asLongFunc1(@Nonnull java.util.List<? extends java.lang.Number> values)
param1 element as long.values - the values@Nonnull public static <T> Func1<T,java.lang.Boolean> and(@Nonnull Func1<? super T,java.lang.Boolean> f1, @Nonnull Func1<? super T,java.lang.Boolean> f2)
T - the parameter typef1 - the first functionf2 - the second function@Nonnull public static Func2<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean> or()
@Nonnull public static <T> Func1<T,java.lang.Boolean> or(@Nonnull Func1<? super T,java.lang.Boolean> f1, @Nonnull Func1<? super T,java.lang.Boolean> f2)
T - the element typef1 - the first functionf2 - the second function@Nonnull public static <T> Func1<T,java.lang.Boolean> xor(@Nonnull Func1<? super T,java.lang.Boolean> f1, @Nonnull Func1<? super T,java.lang.Boolean> f2)
T - the element typef1 - the first functionf2 - the second function@Nonnull public static <T,U> Func2<T,U,java.lang.Boolean> and(@Nonnull Func2<? super T,? super U,java.lang.Boolean> f1, @Nonnull Func2<? super T,? super U,java.lang.Boolean> f2)
T - the first parameter typeU - the second parameter typef1 - the first functionf2 - the second function@Nonnull public static <T,U> Func2<T,U,java.lang.Boolean> or(@Nonnull Func2<? super T,? super U,java.lang.Boolean> f1, @Nonnull Func2<? super T,? super U,java.lang.Boolean> f2)
T - the first parameter typeU - the second parameter typef1 - the first functionf2 - the second function@Nonnull public static <T,U> Func2<T,U,java.lang.Boolean> xor(@Nonnull Func2<? super T,? super U,java.lang.Boolean> f1, @Nonnull Func2<? super T,? super U,java.lang.Boolean> f2)
T - the first parameter typeU - the second parameter typef1 - the first functionf2 - the second function@Nonnull public static <T> Func1<T,java.lang.Boolean> not(@Nonnull Func1<? super T,java.lang.Boolean> f)
T - the parameter typef - the function to wrap@Nonnull public static <T,U> Func2<T,U,java.lang.Boolean> not(@Nonnull Func2<? super T,? super U,java.lang.Boolean> f)
T - the first parameter typeU - the second parameter typef - the function to wrap@Nonnull public static <T> Func0<T> asFunc0(@Nonnull java.lang.ref.Reference<? extends T> ref)
Note that the references may return null if their contained object gets garbage collected.
T - the referenced object typeref - the reference object@Nonnull public static Func2<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean> and()
@Nonnull public static Func0<java.lang.Boolean> and(@Nonnull Func0<java.lang.Boolean> f1, @Nonnull Func0<java.lang.Boolean> f2)
f1 - the first functionf2 - the second function@Nonnull public static Func0<java.lang.Boolean> or(@Nonnull Func0<java.lang.Boolean> f1, @Nonnull Func0<java.lang.Boolean> f2)
f1 - the first functionf2 - the second function@Nonnull public static Func0<java.lang.Boolean> xor(@Nonnull Func0<java.lang.Boolean> f1, @Nonnull Func0<java.lang.Boolean> f2)
f1 - the first functionf2 - the second function@Nonnull public static <T,U> Func1<T,U> asFunc1(@Nonnull Func0<? extends U> f)
T - the function parameter type (irrelevant)U - the function return typef - the function to wrap@Nonnull public static <T,U,V> Func2<T,U,V> asFunc2(@Nonnull Func0<? extends V> f)
T - the function first parameter type (irrelevant)U - the function second parameter type (irrelevant)V - the function return typef - the function to wrap@Nonnull public static <T,U,V> Func2<T,U,V> constant2(V value)
T - the first parameter type, irrelevantU - the second parameter type, irrelevantV - the return typevalue - the value to return@Nonnull public static <T> Func0<T> asFunc0(java.lang.Runnable action, T result)
result value.T - the result typeaction - the action to invokeresult - the result to present after the action invocation@Nonnull public static <T,U> Func1<T,U> asFunc1(@Nonnull java.lang.Runnable action, U result)
result value.T - the parameter type, irrelevantU - the result typeaction - the action to invokeresult - the result to present after the action invocation@Nonnull public static <T,U> Func1<T,U> asFunc1(@Nonnull Action0 action, U result)
result value.T - the parameter type, irrelevantU - the result typeaction - the action to invokeresult - the result to present after the action invocation@Nonnull public static <T,U> Func1<T,U> asFunc1(@Nonnull java.util.concurrent.Callable<? extends U> call)
If the callable throws an exception, it gets wrapped into RuntimeException and gets rethrown.
T - the function parameter type, irrelevantU - the return typecall - the callable instancepublic static <T,U,V> Func2<T,U,V> asFunc2(@Nonnull java.util.concurrent.Callable<? extends V> call)
If the callable throws an exception, it gets wrapped into RuntimeException and gets rethrown.
T - the function first parameter type, irrelevantU - the function second parameter type, irrelevantV - the return typecall - the callable instance@Nonnull public static <T,U,V> Func2<T,U,V> asFunc2(@Nonnull Action0 action, V value)
If the callable throws an exception, it gets wrapped into RuntimeException and gets rethrown.
T - the function first parameter type, irrelevantU - the function second parameter type, irrelevantV - the return typeaction - the action to invokevalue - the value to return@Nonnull public static <T,U,V> Func2<T,U,V> asFunc2(@Nonnull java.lang.Runnable action, V value)
If the callable throws an exception, it gets wrapped into RuntimeException and gets rethrown.
T - the function first parameter type, irrelevantU - the function second parameter type, irrelevantV - the return typeaction - the action to invokevalue - the value to return@Nonnull public static <T,U> Func2<T,U,Pair<T,U>> pairUp()
T - the first parameter typeU - the second parameter type@Nonnull public static Func1<java.lang.Boolean,java.lang.Boolean> negate()
public static <T,U,V> Func2<T,U,V> swap(Func2<U,T,V> func)
T - the first parameter, becomes second in funcU - the second parameter, becomes first in funcV - the result typefunc - the function to swap around.