Interface Invoker<ARG,RET>
-
- Type Parameters:
ARG- Argument typeRET- Return type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Invoker<ARG,RET>
The complement to theCallableinterface - accepts one argument and possibly throws something- Author:
- Apache MINA SSHD Project
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description RETinvoke(ARG arg)static <ARG> voidinvokeAll(ARG arg, Collection<? extends Invoker<? super ARG,?>> invokers)Invokes all the instances ignoring the return value.static <ARG> AbstractMap.SimpleImmutableEntry<Invoker<? super ARG,?>,Throwable>invokeTillFirstFailure(ARG arg, Collection<? extends Invoker<? super ARG,?>> invokers)Invokes all instances until 1st failure (if any)static <ARG> Invoker<ARG,Void>wrapAll(Collection<? extends Invoker<? super ARG,?>> invokers)Wraps a bunch ofInvoker-s that return no value into one that invokes them in the same order as they appear.static <ARG> Invoker<ARG,Void>wrapFirst(Collection<? extends Invoker<? super ARG,?>> invokers)Wraps a bunch ofInvoker-s that return no value into one that invokes them in the same order as they appear.
-
-
-
Method Detail
-
wrapAll
static <ARG> Invoker<ARG,Void> wrapAll(Collection<? extends Invoker<? super ARG,?>> invokers)
Wraps a bunch ofInvoker-s that return no value into one that invokes them in the same order as they appear. Note: all invokers are used and any thrown exceptions are accumulated and thrown as a single exception at the end of invoking all of them.- Type Parameters:
ARG- The argument type- Parameters:
invokers- The invokers to wrap - ignored ifnull/empty- Returns:
- The wrapper
- See Also:
invokeAll
-
invokeAll
static <ARG> void invokeAll(ARG arg, Collection<? extends Invoker<? super ARG,?>> invokers) throws ThrowableInvokes all the instances ignoring the return value. Any intermediate exceptions are accumulated and thrown at the end.- Type Parameters:
ARG- Argument type- Parameters:
arg- The argument to pass to theinvoke(Object)methodinvokers- The invokers to scan - ignored ifnull/empty (also ignoresnullmembers)- Throws:
Throwable- If invocation failed
-
wrapFirst
static <ARG> Invoker<ARG,Void> wrapFirst(Collection<? extends Invoker<? super ARG,?>> invokers)
Wraps a bunch ofInvoker-s that return no value into one that invokes them in the same order as they appear. Note: stops when first invoker throws an exception (otherwise invokes all)- Type Parameters:
ARG- The argument type- Parameters:
invokers- The invokers to wrap - ignored ifnull/empty- Returns:
- The wrapper
- See Also:
invokeTillFirstFailure
-
invokeTillFirstFailure
static <ARG> AbstractMap.SimpleImmutableEntry<Invoker<? super ARG,?>,Throwable> invokeTillFirstFailure(ARG arg, Collection<? extends Invoker<? super ARG,?>> invokers)
Invokes all instances until 1st failure (if any)- Type Parameters:
ARG- Argument type- Parameters:
arg- The argument to pass to theinvoke(Object)methodinvokers- The invokers to scan - ignored ifnull/empty (also ignoresnullmembers)- Returns:
- A
AbstractMap.SimpleImmutableEntryrepresenting the first failed invocation -nullif all were successful (or none invoked).
-
-