Interface IOFunction<T,​R>

  • Type Parameters:
    T - the type of the input to the function
    R - the type of the result of the function
    All Known Subinterfaces:
    IOUnaryOperator<T>
    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 IOFunction<T,​R>
    Represents a function that accepts one argument and produces a result.

    This interface is similar to Function except that it is allowed to throw an IOException.

    Author:
    Magno N A Cruz
    See Also:
    Function
    • Method Detail

      • apply

        R apply​(T t)
         throws java.io.IOException

        This method is the same as Function.apply(Object), but with a support for IOException.

        Parameters:
        t - The function argument.
        Returns:
        The function result.
        Throws:
        java.io.IOException - if there is an I/O error performing the operation.
      • compose

        default <V> IOFunction<V,​R> compose​(@Nonnull
                                                  IOFunction<? super V,​? extends T> before)
                                           throws java.io.IOException

        This method is the same as Function.compose(Function), but with a support for IOException.

        Type Parameters:
        V - The type of input to the before function, and to the composed function.
        Parameters:
        before - The function to apply before this function is applied.
        Returns:
        A composed function that first applies the before function and then applies this function.
        Throws:
        java.io.IOException - if there is an I/O error performing the operation.
        See Also:
        andThen(IOFunction)
      • andThen

        default <V> IOFunction<T,​V> andThen​(@Nonnull
                                                  IOFunction<? super R,​? extends V> after)
                                           throws java.io.IOException

        This method is the same as Function.andThen(Function), but with a support for IOException.

        Type Parameters:
        V - The type of output of the after function, and of the composed function.
        Parameters:
        after - The function to apply after this function is applied.
        Returns:
        A composed function that first applies this function and then applies the after function.
        Throws:
        java.io.IOException - if there is an I/O error performing the operation.
        See Also:
        compose(IOFunction)
      • identity

        static <T> IOFunction<T,​T> identity()
                                           throws java.io.IOException
        Returns a function that always returns its input argument.
        Type Parameters:
        T - The type of the input and output objects to the function.
        Returns:
        A function that always returns its input argument.
        Throws:
        java.io.IOException - if there is an I/O error performing the operation.