T - the function first parameter typeU - the function second parameter typeV - the return typepublic class Func2Builder<T,U,V> extends java.lang.Object implements Func2<T,U,V>
Functions utility class as instance methods.
The class itself is of type Func2<T, U, V> and can be used where this type is needed.
| Modifier and Type | Field and Description |
|---|---|
protected Func2<T,U,V> |
f
The wrapped function.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Func2Builder(Func2<T,U,V> f)
Construct an instance of this builder with the wrapped function.
|
| Modifier and Type | Method and Description |
|---|---|
static <T,U> Func2Builder<T,U,java.lang.Boolean> |
alwaysFalse() |
static <T,U> Func2Builder<T,U,java.lang.Boolean> |
alwaysTrue() |
Func2Builder<T,U,java.lang.Boolean> |
and(Func0<java.lang.Boolean> func)
Returns a function which produces the logical AND value of this and the other function.
|
Func2Builder<T,U,java.lang.Boolean> |
and(Func2<? super T,? super U,java.lang.Boolean> func)
Returns a function which produces the logical AND value of this and the other function.
|
static <T,U,V> Func2Builder<T,U,V> |
from(Action0 action,
V result)
Construct a function which invokes the given action and
returns a constant value.
|
static <T,U,V> Func2Builder<T,U,V> |
from(Action2<? super T,? super U> action,
V result)
Construct a function which invokes the given action and
returns a constant value.
|
static <T,U,V> Func2Builder<T,U,V> |
from(java.util.concurrent.Callable<? extends V> f)
Wrap the given function into a new builder.
|
static <T> Func2Builder<T,T,java.lang.Integer> |
from(java.util.Comparator<? super T> comp)
Wraps the given comparator into a 2 parameter function.
|
static Func2Builder<java.lang.Integer,java.lang.Integer,java.lang.Double> |
from(double[][] matrix)
Returns a matrix indexer function.
|
static <T,U,V> Func2Builder<T,U,V> |
from(Func0<V> f)
Wraps the given Func0 function into a Func2 object which ignores
its parameter T.
|
static <T,U,V> Func2Builder<T,U,V> |
from(Func2<T,U,V> f)
Wrap the given function into a function builder instance.
|
static Func2Builder<java.lang.Integer,java.lang.Integer,java.lang.Integer> |
from(int[][] matrix)
Returns a matrix indexer function.
|
static Func2Builder<java.lang.Integer,java.lang.Integer,java.lang.Long> |
from(long[][] matrix)
Returns a matrix indexer function.
|
static <T,U,V> Func2Builder<T,U,V> |
from(java.lang.Runnable run,
V result)
Construct a function which invokes the given runnable and
returns a constant value.
|
static <T> Func2Builder<java.lang.Integer,java.lang.Integer,T> |
from(T[][] matrix)
Returns a matrix indexer function.
|
static <T,U,V> Func2Builder<T,U,V> |
from(V value)
Wraps the given value and the function returns this value
regardless of the parameters.
|
V |
invoke(T param1,
U param2)
The method that gets invoked with two parameters.
|
Func2Builder<T,U,java.lang.Boolean> |
not()
Returns a function which takes the logical not of the wrapped boolean returning function.
|
Func2Builder<T,U,java.lang.Boolean> |
or(Func0<java.lang.Boolean> func)
Returns a function which produces the logical AND value of this and the other function.
|
Func2Builder<T,U,java.lang.Boolean> |
or(Func2<? super T,? super U,java.lang.Boolean> func)
Returns a function which produces the logical OR value of this and the other function.
|
java.util.Comparator<T> |
toComparator()
Convert this two parameter function into a comparator.
|
Func0Builder<V> |
toFunc0(T param1,
U param2)
Convert this function into a zero parameter function builder by fixing the parameter
to the given values.
|
Func2Builder<T,U,java.lang.Boolean> |
xor(Func0<java.lang.Boolean> func)
Returns a function which produces the logical AND value of this and the other function.
|
Func2Builder<T,U,java.lang.Boolean> |
xor(Func2<? super T,? super U,java.lang.Boolean> func)
Returns a function which produces the logical XOR value of this and the other function.
|
@Nonnull public static <T,U,V> Func2Builder<T,U,V> from(@Nonnull Func2<T,U,V> f)
T - the function first parameter typeU - the function second parameter typeV - the return typef - the function to wrap@Nonnull public static <T,U,V> Func2Builder<T,U,V> from(@Nonnull Func0<V> f)
T - the function first parameter typeU - the function second parameter typeV - the return typef - the function to wrap@Nonnull public static <T,U,V> Func2Builder<T,U,V> from(V value)
T - the function parameter type, irrelevantU - the function parameter type, irrelevantV - the return typevalue - the value to returnpublic V invoke(T param1, U param2)
Func2@Nonnull public static <T,U> Func2Builder<T,U,java.lang.Boolean> alwaysTrue()
T - the parameter type (irrelevant)U - the parameter type (irrelevant)@Nonnull public static <T,U> Func2Builder<T,U,java.lang.Boolean> alwaysFalse()
T - the parameter type (irrelevant)U - the parameter type (irrelevant)@Nonnull public Func0Builder<V> toFunc0(T param1, U param2)
param1 - the fixed parameter valueparam2 - the fixed parameter value@Nonnull public Func2Builder<T,U,java.lang.Boolean> not()
Note: this function will throw a ClassCastException if the current function return type is not Boolean.
@Nonnull public Func2Builder<T,U,java.lang.Boolean> and(@Nonnull Func2<? super T,? super U,java.lang.Boolean> func)
Note: this function will throw a ClassCastException if the current function return type is not Boolean.
func - the function to AND with@Nonnull public Func2Builder<T,U,java.lang.Boolean> and(@Nonnull Func0<java.lang.Boolean> func)
Note: this function will throw a ClassCastException if the current function return type is not Boolean.
func - the function to AND with@Nonnull public Func2Builder<T,U,java.lang.Boolean> or(@Nonnull Func2<? super T,? super U,java.lang.Boolean> func)
Note: this function will throw a ClassCastException if the current function return type is not Boolean.
func - the function to OR with@Nonnull public Func2Builder<T,U,java.lang.Boolean> or(@Nonnull Func0<java.lang.Boolean> func)
Note: this function will throw a ClassCastException if the current function return type is not Boolean.
func - the function to AND with@Nonnull public Func2Builder<T,U,java.lang.Boolean> xor(@Nonnull Func2<? super T,? super U,java.lang.Boolean> func)
Note: this function will throw a ClassCastException if the current function return type is not Boolean.
func - the function to XOR with@Nonnull public Func2Builder<T,U,java.lang.Boolean> xor(@Nonnull Func0<java.lang.Boolean> func)
Note: this function will throw a ClassCastException if the current function return type is not Boolean.
func - the function to AND with@Nonnull public static <T,U,V> Func2Builder<T,U,V> from(@Nonnull Action0 action, V result)
T - the function first parameter typeU - the function second parameter typeV - the return typeaction - the action to invoke on each function invocationresult - the return value by this function@Nonnull public static <T,U,V> Func2Builder<T,U,V> from(@Nonnull java.lang.Runnable run, V result)
T - the function first parameter typeU - the function second parameter typeV - the return typerun - the runnable to wrapresult - the return value by this function@Nonnull public static <T,U,V> Func2Builder<T,U,V> from(@Nonnull Action2<? super T,? super U> action, V result)
T - the function first parameter typeU - the function second parameter typeV - the return typeaction - the action to invoke on each function invocationresult - the return value by this function@Nonnull public static <T,U,V> Func2Builder<T,U,V> from(@Nonnull java.util.concurrent.Callable<? extends V> f)
T - the function first parameter typeU - the function second parameter typeV - the return typef - the function to wrap@Nonnull public static <T> Func2Builder<T,T,java.lang.Integer> from(@Nonnull java.util.Comparator<? super T> comp)
T - the value typecomp - the comparator to wrap@Nonnull public java.util.Comparator<T> toComparator()
Note, if the parameter types are not the same or the return type is not Integer you might expect to get a ClassCastException.
@Nonnull public static <T> Func2Builder<java.lang.Integer,java.lang.Integer,T> from(@Nonnull T[][] matrix)
T - the element typematrix - the matrix to index@Nonnull public static Func2Builder<java.lang.Integer,java.lang.Integer,java.lang.Integer> from(@Nonnull int[][] matrix)
matrix - the matrix to index@Nonnull public static Func2Builder<java.lang.Integer,java.lang.Integer,java.lang.Double> from(@Nonnull double[][] matrix)
matrix - the matrix to index@Nonnull public static Func2Builder<java.lang.Integer,java.lang.Integer,java.lang.Long> from(@Nonnull long[][] matrix)
matrix - the matrix to index