public final class Actions
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <T> Action0 |
asAction(Func0<T> func)
Converts the given parameterless function into an action,
which when invoked, invokes the original function and ignores its result.
|
static <T,U> Action1<T> |
asAction(Func1<? super T,U> func)
Converts the given 1 parameter function into an action,
which when invoked, invokes the original function and ignores its result.
|
static <T,U,V> Action2<T,U> |
asAction(Func2<? super T,? super U,V> func)
Converts the given 2 parameter function into an action,
which when invoked, invokes the original function and ignores its result.
|
static <T> Action0 |
asAction0(Func0<T> run)
Wrap the supplied no-parameter function into an action.
|
static Action0 |
asAction0(java.lang.Runnable run)
Wrap the supplied runnable into an action.
|
static <E extends java.lang.Exception> |
asAction0E(Action0 action)
Wrap the given exception-less action.
|
static Action0E<java.io.IOException> |
asAction0E(java.io.Closeable closeable)
Wraps the given closeable instance into an Action0E.
|
static <T> Action1<T> |
asAction1(Action0 run)
Wrap the parameterless action into an Action1.
|
static <T,U> Action1<T> |
asAction1(Func1<T,U> run)
Wrap the supplied one-parameter function into an action.
|
static <T> Action1<T> |
asAction1(java.lang.Runnable run)
Wrap the supplied runnable into an action.
|
static <T,E extends java.lang.Exception> |
asAction1E(Action1<? super T> action)
Wrap the given exception-less action.
|
static <T,U> Action2<T,U> |
asAction2(Action0 run)
Wrap the parameterless action into an Action2.
|
static <T,U,E extends java.lang.Exception> |
asAction2E(Action2<? super T,? super U> action)
Wrap the given exception-less action.
|
static java.lang.Runnable |
asRunnable(Action0 action)
Wrap the given action into a runnable instance.
|
static Action0E<java.io.IOException> |
close(java.io.Closeable c)
Creates an action which will close the given closeable.
|
static Action0 |
closeSilently(java.io.Closeable c)
Wraps the closeable into action and suppresses any close exception.
|
static <T,U> Action2<T,U> |
dualAction(Action1<? super T> first,
Action1<? super U> second)
Returns a composite two parameter action from the supplied two actions
which will be invoked for each of the parameters.
|
static <T,U,E extends java.lang.Exception> |
dualAction(Action1E<? super T,? extends E> first,
Action1E<? super U,? extends E> second)
Returns a composite two parameter action from the supplied two actions
which will be invoked for each of the parameters; and allows throwing an exception.
|
static Action0 |
noAction0() |
static <T> Action1<T> |
noAction1()
Returns an action which does nothing with its parameter.
|
static <T,U> Action2<T,U> |
noAction2()
Returns an action which does nothing with its parameter.
|
@Nonnull public static <T> Action0 asAction0(@Nonnull Func0<T> run)
T - the return type of the function, irrelevantrun - the original runnable@Nonnull public static Action0 asAction0(@Nonnull java.lang.Runnable run)
run - the original runnable@Nonnull public static <T,U> Action1<T> asAction1(@Nonnull Func1<T,U> run)
T - the parameter typeU - the return type, irrelevantrun - the original runnable@Nonnull public static <T> Action1<T> asAction1(@Nonnull Action0 run)
T - the parameter typerun - the original action@Nonnull public static <T,U> Action2<T,U> asAction2(@Nonnull Action0 run)
T - the first parameter typeU - the second parameter typerun - the original action@Nonnull public static <T> Action1<T> asAction1(@Nonnull java.lang.Runnable run)
T - the parameter typerun - the original runnable@Nonnull
public static java.lang.Runnable asRunnable(@Nonnull
Action0 action)
action - the target action@Nonnull public static Action0 noAction0()
@Nonnull public static <T> Action1<T> noAction1()
T - the type of the parameter (irrelevant)@Nonnull public static <T,U> Action2<T,U> noAction2()
T - the type of the first parameter (irrelevant)U - the type of the second parameter (irrelevant)@Nonnull public static <T,U> Action2<T,U> dualAction(@Nonnull Action1<? super T> first, @Nonnull Action1<? super U> second)
T - the first parameter typeU - the second parameter typefirst - the first action reacting to the first parametersecond - the second action reacting to the second parameter@Nonnull public static <T,U,E extends java.lang.Exception> Action2E<T,U,E> dualAction(@Nonnull Action1E<? super T,? extends E> first, @Nonnull Action1E<? super U,? extends E> second)
T - the first parameter typeU - the second parameter typeE - the exception typefirst - the first action reacting to the first parametersecond - the second action reacting to the second parameter@Nonnull public static <E extends java.lang.Exception> Action0E<E> asAction0E(@Nonnull Action0 action)
E - the exception typeaction - the action to wrap@Nonnull public static <T,E extends java.lang.Exception> Action1E<T,E> asAction1E(@Nonnull Action1<? super T> action)
T - the parameter typeE - the exception typeaction - the action to wrap@Nonnull public static <T,U,E extends java.lang.Exception> Action2E<T,U,E> asAction2E(@Nonnull Action2<? super T,? super U> action)
T - the first parameter typeU - the second parameter typeE - the exception typeaction - the action to wrap@Nonnull public static Action0E<java.io.IOException> close(@Nonnull java.io.Closeable c)
c - the closeable@Nonnull public static Action0 closeSilently(@Nonnull java.io.Closeable c)
c - the closeable@Nonnull public static <T> Action0 asAction(@Nonnull Func0<T> func)
T - the function's return typefunc - the function to wrap@Nonnull public static <T,U> Action1<T> asAction(@Nonnull Func1<? super T,U> func)
T - the action/function parameterU - the function's return typefunc - the function to wrap@Nonnull public static <T,U,V> Action2<T,U> asAction(@Nonnull Func2<? super T,? super U,V> func)
T - the first action/function parameterU - the second action/function parameterV - the function's return typefunc - the function to wrap@Nonnull public static Action0E<java.io.IOException> asAction0E(@Nonnull java.io.Closeable closeable)
closeable - the closeable to call