Interface CheckedConsumer<T>

  • Type Parameters:
    T - the type of the consumed argument
    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 CheckedConsumer<T>
    A function that consumes an argument, returns nothing and may throw an Exception. Such a function is expected to perform side-effects, i.e. altering the outer world.
    • Method Detail

      • accept

        void accept​(T t)
             throws java.lang.Exception
        Consumes the given argument t by performing an action.
        Parameters:
        t - the input argument
        Throws:
        java.lang.Exception - if an error occurs when performing the action
      • andThen

        default CheckedConsumer<T> andThen​(CheckedConsumer<? super T> after)
        Returns a new CheckedConsumer that first executes this operation and then the given operation after. If this operation throws an exception after is not executed.
        Parameters:
        after - a function that consumes a given argument after this successfully did
        Returns:
        a new CheckedConsumer that first performs this and then after
        Throws:
        java.lang.NullPointerException - if after is null