T - the function parameter typeU - the return typepublic final class Func1Builder<T,U> extends java.lang.Object implements Func1<T,U>
Functions utility class as instance methods.
The class itself is of type Func1<T, U> and can be used where this type is needed.
| Modifier and Type | Field and Description |
|---|---|
protected Func1<T,U> |
f
The wrapped function.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Func1Builder(Func1<T,U> f)
Construct a function builder by wrapping the given function.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> Func1Builder<T,java.lang.Boolean> |
alwaysFalse() |
static <T> Func1Builder<T,java.lang.Boolean> |
alwaysTrue() |
Func1Builder<T,java.lang.Boolean> |
and(Func0<java.lang.Boolean> func)
Returns a function which produces the logical AND value of this and the other function.
|
Func1Builder<T,java.lang.Boolean> |
and(Func1<? super T,java.lang.Boolean> func)
Returns a function which produces the logical AND value of this and the other function.
|
<V> Func1Builder<V,U> |
composeFrom(Func1<? super V,? extends T> func)
Compose this function with the other function by supplying the output of this
function as input for the other function and return its result,
e.g.,
this(func(V)). |
<V> Func1Builder<T,V> |
composeTo(Func1<? super U,? extends V> func)
Compose this function with the other function by supplying the output of this
function as input for the other function and return its result,
e.g.,
func(this(T)). |
static <T,U> Func1Builder<T,U> |
from(Action0 action,
U result)
Construct a function which invokes the given action and
returns a constant value.
|
static <T,U> Func1Builder<T,U> |
from(Action1<? super T> action,
U result)
Construct a function which invokes the given action and
returns a constant value.
|
static <T,U> Func1Builder<T,U> |
from(java.util.concurrent.Callable<? extends U> f)
Wrap the given function into a new builder.
|
static Func1Builder<java.lang.Integer,java.lang.Double> |
from(double... values)
Returns an indexer function which returns the corresponding array element.
|
static <T,U> Func1Builder<T,U> |
from(Func0<U> f)
Wraps the given Func0 function into a Func1 object which ignores
its parameter T.
|
static <T,U> Func1Builder<T,U> |
from(Func1<T,U> f)
Wrap the given function into a new builder.
|
static Func1Builder<java.lang.Integer,java.lang.Integer> |
from(int... values)
Returns an indexer function which returns the corresponding array element.
|
static <T> Func1Builder<java.lang.Integer,T> |
from(java.util.List<? extends T> values)
Returns a function builder which will return the indexth element
from the supplied list.
|
static Func1Builder<java.lang.Integer,java.lang.Long> |
from(long... values)
Returns an indexer function which returns the corresponding array element.
|
static <T,U> Func1Builder<T,U> |
from(java.util.Map<? super T,? extends U> map)
Creates a function builder which relays all invocations to the supplied
map's get method.
|
static <T,U> Func1Builder<T,U> |
from(java.lang.Runnable run,
U result)
Construct a function which invokes the given runnable and
returns a constant value.
|
static <T> Func1Builder<T,java.lang.Boolean> |
from(java.util.Set<? super T> values)
Returns a function builder which will return true if its
parameter is contained in the given set of values.
|
static <T> Func1Builder<java.lang.Integer,T> |
from(T... values)
Returns a function builder which will return the indexth element
from the supplied array.
|
static <T,U> Func1Builder<T,U> |
from(U value)
Wraps the given value and the function returns this value
regardless of the parameters.
|
static Func1Builder<java.lang.Integer,java.lang.Double> |
fromDoubles(java.util.List<? extends java.lang.Number> values)
Returns an indexer function which returns the corresponding list element.
|
static Func1Builder<java.lang.Integer,java.lang.Integer> |
fromInts(java.util.List<? extends java.lang.Number> values)
Returns an indexer function which returns the corresponding list element.
|
static Func1Builder<java.lang.Integer,java.lang.Long> |
fromLongs(java.util.List<? extends java.lang.Number> values)
Returns an indexer function which returns the corresponding list element.
|
U |
invoke(T param1)
The method that gets invoked with a parameter.
|
Func1Builder<T,java.lang.Boolean> |
not()
Returns a function which takes the logical not of the wrapped boolean returning function.
|
Func1Builder<T,java.lang.Boolean> |
or(Func0<java.lang.Boolean> func)
Returns a function which produces the logical AND value of this and the other function.
|
Func1Builder<T,java.lang.Boolean> |
or(Func1<? super T,java.lang.Boolean> func)
Returns a function which produces the logical OR value of this and the other function.
|
Func0Builder<U> |
toFunc0(T param1)
Convert this function into a zero parameter function builder by fixing the parameter
to the given value.
|
Func1Builder<T,java.lang.Boolean> |
xor(Func0<java.lang.Boolean> func)
Returns a function which produces the logical AND value of this and the other function.
|
Func1Builder<T,java.lang.Boolean> |
xor(Func1<? super T,java.lang.Boolean> func)
Returns a function which produces the logical XOR value of this and the other function.
|
@Nonnull public static <T,U> Func1Builder<T,U> from(@Nonnull Func1<T,U> f)
T - the parameter typeU - the return typef - the function to wrap@Nonnull public static <T,U> Func1Builder<T,U> from(@Nonnull Func0<U> f)
T - the function parameter type (irrelevant)U - the function return typef - the function to wrap@Nonnull public static <T,U> Func1Builder<T,U> from(U value)
T - the function parameter type, irrelevantU - the return typevalue - the value to return@Nonnull public static <T> Func1Builder<java.lang.Integer,T> from(@Nonnull T... values)
T - the element typevalues - the values to return from@Nonnull public static <T> Func1Builder<java.lang.Integer,T> from(@Nonnull java.util.List<? extends T> values)
T - the element typevalues - the values to return from@Nonnull public static <T> Func1Builder<T,java.lang.Boolean> from(@Nonnull java.util.Set<? super T> values)
T - the element typevalues - the values to return from@Nonnull public static <T,U> Func1Builder<T,U> from(@Nonnull java.util.Map<? super T,? extends U> map)
T - the key typeU - the value typemap - the map to wrap@Nonnull public static <T> Func1Builder<T,java.lang.Boolean> alwaysTrue()
T - the parameter type (irrelevant)@Nonnull public static <T> Func1Builder<T,java.lang.Boolean> alwaysFalse()
T - the parameter type (irrelevant)public U invoke(T param1)
Func1@Nonnull public Func0Builder<U> toFunc0(T param1)
param1 - the fixed parameter value@Nonnull public Func1Builder<T,java.lang.Boolean> not()
Note: this function will throw a ClassCastException if the current function return type is not Boolean.
@Nonnull public Func1Builder<T,java.lang.Boolean> and(@Nonnull Func1<? super T,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 Func1Builder<T,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 Func1Builder<T,java.lang.Boolean> or(Func1<? super T,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 Func1Builder<T,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 Func1Builder<T,java.lang.Boolean> xor(@Nonnull Func1<? super T,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 Func1Builder<T,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 <V> Func1Builder<T,V> composeTo(@Nonnull Func1<? super U,? extends V> func)
func(this(T)).V - the new return typefunc - the function to compose with@Nonnull public <V> Func1Builder<V,U> composeFrom(@Nonnull Func1<? super V,? extends T> func)
this(func(V)).V - the outer parameter typefunc - the function to compose with@Nonnull public static <T,U> Func1Builder<T,U> from(@Nonnull Action0 action, U result)
T - the function parameter typeU - the return typeaction - the action to invoke on each function invocationresult - the return value by this function@Nonnull public static <T,U> Func1Builder<T,U> from(@Nonnull java.lang.Runnable run, U result)
T - the function parameter typeU - the return typerun - the runnable to wrapresult - the return value by this function@Nonnull public static <T,U> Func1Builder<T,U> from(@Nonnull Action1<? super T> action, U result)
T - the function parameter typeU - the return typeaction - the action to invoke on each function invocationresult - the return value by this function@Nonnull public static <T,U> Func1Builder<T,U> from(@Nonnull java.util.concurrent.Callable<? extends U> f)
T - the parameter typeU - the return typef - the function to wrap@Nonnull public static Func1Builder<java.lang.Integer,java.lang.Integer> from(@Nonnull int... values)
values - the array of values@Nonnull public static Func1Builder<java.lang.Integer,java.lang.Double> from(@Nonnull double... values)
values - the array of values@Nonnull public static Func1Builder<java.lang.Integer,java.lang.Long> from(@Nonnull long... values)
values - the array of values@Nonnull public static Func1Builder<java.lang.Integer,java.lang.Double> fromDoubles(@Nonnull java.util.List<? extends java.lang.Number> values)
values - the list of numbers@Nonnull public static Func1Builder<java.lang.Integer,java.lang.Integer> fromInts(@Nonnull java.util.List<? extends java.lang.Number> values)
values - the list of numbers@Nonnull public static Func1Builder<java.lang.Integer,java.lang.Long> fromLongs(@Nonnull java.util.List<? extends java.lang.Number> values)
values - the list of numbers