T - the return typepublic final class Func0Builder<T> extends java.lang.Object implements Func0<T>
Functions utility class as instance methods.
The class itself is of type Func0<T> and can be used where this type is needed.
| Modifier and Type | Field and Description |
|---|---|
protected Func0<T> |
f
The wrapped function.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Func0Builder(Func0<T> f)
Constructs an instance of this builder with the wrapped function.
|
| Modifier and Type | Method and Description |
|---|---|
static Func0Builder<java.lang.Boolean> |
alwaysFalse() |
static Func0Builder<java.lang.Boolean> |
alwaysTrue() |
Func0Builder<java.lang.Boolean> |
and(Func0<java.lang.Boolean> func)
Returns a function which produces the logical AND value of this and the other function.
|
static <T> Func0Builder<T> |
from(Action0 action,
T result)
Construct a function which invokes the given action and
returns a constant value.
|
static Func0Builder<java.lang.Boolean> |
from(java.util.concurrent.atomic.AtomicBoolean value)
Construct a function from the given atomic variable.
|
static Func0Builder<java.lang.Integer> |
from(java.util.concurrent.atomic.AtomicInteger value)
Construct a function from the given atomic variable.
|
static Func0Builder<java.lang.Long> |
from(java.util.concurrent.atomic.AtomicLong value)
Construct a function from the given atomic variable.
|
static <T> Func0Builder<T> |
from(java.util.concurrent.atomic.AtomicReference<? extends T> value)
Construct a function from the given atomic variable reference.
|
static <T> Func0Builder<T> |
from(java.util.concurrent.Callable<? extends T> call)
Construct a function from the given callable instance.
|
static <T> Func0Builder<T> |
from(Func0<T> f)
Construct a function builder from the given existing function.
|
static <T> Func0Builder<T> |
from(java.lang.ref.Reference<? extends T> ref)
Wraps the given reference object into a function call.
|
static <T> Func0Builder<T> |
from(java.lang.Runnable run,
T result)
Construct a function which invokes the given runnable and
returns a constant value.
|
static <T> Func0Builder<T> |
from(T value)
Construct a function which returns a constant value.
|
T |
invoke()
The function body to invoke.
|
Func0Builder<java.lang.Boolean> |
not()
Returns a function which takes the logical not of the wrapped boolean returning function.
|
Func0Builder<java.lang.Boolean> |
or(Func0<java.lang.Boolean> func)
Returns a function which produces the logical OR value of this and the other function.
|
java.util.concurrent.Callable<T> |
toCallable() |
<U> Func1Builder<U,T> |
toFunc1() |
<U,V> Func2Builder<U,V,T> |
toFunc2() |
Func0Builder<java.lang.Boolean> |
xor(Func0<java.lang.Boolean> func)
Returns a function which produces the logical XOR value of this and the other function.
|
@Nonnull public static <T> Func0Builder<T> from(@Nonnull Func0<T> f)
T - the return typef - the function to wrappublic static <T> Func0Builder<T> from(T value)
T - the value typevalue - the value returned by the function@Nonnull public static <T> Func0Builder<T> from(@Nonnull Action0 action, T result)
T - the return typeaction - the action to invoke on each function invocationresult - the return value by this function@Nonnull public static <T> Func0Builder<T> from(@Nonnull java.lang.Runnable run, T result)
T - the return typerun - the runnable to wrapresult - the return value by this function@Nonnull public static <T> Func0Builder<T> from(@Nonnull java.util.concurrent.Callable<? extends T> call)
T - the return typecall - the callable instance@Nonnull public static Func0Builder<java.lang.Boolean> from(@Nonnull java.util.concurrent.atomic.AtomicBoolean value)
value - the atomic variable@Nonnull public static Func0Builder<java.lang.Integer> from(@Nonnull java.util.concurrent.atomic.AtomicInteger value)
value - the atomic variable@Nonnull public static Func0Builder<java.lang.Long> from(@Nonnull java.util.concurrent.atomic.AtomicLong value)
value - the atomic variable@Nonnull public static <T> Func0Builder<T> from(@Nonnull java.util.concurrent.atomic.AtomicReference<? extends T> value)
T - the value type of the referencevalue - the atomic variable@Nonnull public static Func0Builder<java.lang.Boolean> alwaysTrue()
@Nonnull public static Func0Builder<java.lang.Boolean> alwaysFalse()
@Nonnull public static <T> Func0Builder<T> from(@Nonnull java.lang.ref.Reference<? extends T> ref)
Note that the function may return null if the reference's object gets garbage collected.
T - the referenced object typeref - the reference to wrap@Nonnull public Func0Builder<java.lang.Boolean> not()
Note: this function will throw a ClassCastException if the current function return type is not Boolean.
@Nonnull public Func0Builder<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 Func0Builder<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 OR with@Nonnull public Func0Builder<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 XOR with@Nonnull public java.util.concurrent.Callable<T> toCallable()
@Nonnull public <U> Func1Builder<U,T> toFunc1()
U - the function parameter (irrelevant)@Nonnull public <U,V> Func2Builder<U,V,T> toFunc2()
U - the function first parameter (irrelevant)V - the function second parameter (irrelevant)