Interface Invoker<ARG,​RET>

  • Type Parameters:
    ARG - Argument type
    RET - 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 the Callable interface - accepts one argument and possibly throws something
    Author:
    Apache MINA SSHD Project
    • Method Detail

      • wrapAll

        static <ARG> Invoker<ARG,​Void> wrapAll​(Collection<? extends Invoker<? super ARG,​?>> invokers)
        Wraps a bunch of Invoker-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 if null/empty
        Returns:
        The wrapper
        See Also:
        invokeAll
      • invokeAll

        static <ARG> void invokeAll​(ARG arg,
                                    Collection<? extends Invoker<? super ARG,​?>> invokers)
                             throws 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 the invoke(Object) method
        invokers - The invokers to scan - ignored if null/empty (also ignores null members)
        Throws:
        Throwable - If invocation failed
      • wrapFirst

        static <ARG> Invoker<ARG,​Void> wrapFirst​(Collection<? extends Invoker<? super ARG,​?>> invokers)
        Wraps a bunch of Invoker-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 if null/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 the invoke(Object) method
        invokers - The invokers to scan - ignored if null/empty (also ignores null members)
        Returns:
        A AbstractMap.SimpleImmutableEntry representing the first failed invocation - null if all were successful (or none invoked).