Interface CheckedFunction<T,​R>

  • Type Parameters:
    T - the type of this function's domain
    R - the type of this function's codomain, i.e. the 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 CheckedFunction<T,​R>
    A Function which may throw.
    • Method Detail

      • identity

        static <T> CheckedFunction<T,​T> identity()
        Returns the identity CheckedFunction, i.e. the function that returns its input.
        Type Parameters:
        T - argument type (and return type) of the identity function
        Returns:
        the identity CheckedFunction
      • apply

        R apply​(T t)
         throws java.lang.Exception
        Applies this function to one argument and returns the result.
        Parameters:
        t - argument of type T
        Returns:
        the result of the function application
        Throws:
        java.lang.Exception - if something goes wrong applying this function to the given argument
      • andThen

        default <U> CheckedFunction<T,​U> andThen​(CheckedFunction<? super R,​? extends U> after)
        Returns a composed function that first applies this to the given argument and then applies after to the result.
        Type Parameters:
        U - return type of after
        Parameters:
        after - the function applied after this
        Returns:
        a function composed of this and after
        Throws:
        java.lang.NullPointerException - if after is null
      • compose

        default <U> CheckedFunction<U,​R> compose​(CheckedFunction<? super U,​? extends T> before)
        Returns a composed function that first applies before to the given argument and then applies this to the result.
        Type Parameters:
        U - argument type of before
        Parameters:
        before - the function applied before this
        Returns:
        a function composed of before and this
        Throws:
        java.lang.NullPointerException - if before is null