Package org.apache.sshd.common.util
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 theCallable
interface - accepts one argument and possibly throws something
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description RET
invoke(ARG arg)
static <ARG> void
invokeAll(ARG arg, java.util.Collection<? extends Invoker<? super ARG,?>> invokers)
Invokes all the instances ignoring the return value.static <ARG> java.util.AbstractMap.SimpleImmutableEntry<Invoker<? super ARG,?>,java.lang.Throwable>
invokeTillFirstFailure(ARG arg, java.util.Collection<? extends Invoker<? super ARG,?>> invokers)
Invokes all instances until 1st failure (if any)static <ARG> Invoker<ARG,java.lang.Void>
wrapAll(java.util.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,java.lang.Void>
wrapFirst(java.util.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,java.lang.Void> wrapAll(java.util.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, java.util.Collection<? extends Invoker<? super ARG,?>> invokers) throws java.lang.Throwable
Invokes 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 ignoresnull
members)- Throws:
java.lang.Throwable
- If invocation failed
-
wrapFirst
static <ARG> Invoker<ARG,java.lang.Void> wrapFirst(java.util.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> java.util.AbstractMap.SimpleImmutableEntry<Invoker<? super ARG,?>,java.lang.Throwable> invokeTillFirstFailure(ARG arg, java.util.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 ignoresnull
members)- Returns:
- A
AbstractMap.SimpleImmutableEntry
representing the first failed invocation -null
if all were successful (or none invoked).
-
-