Interface ThrowableFunction1<T,​R>

  • Type Parameters:
    T - The type this function will consume
    R - The type this function will return
    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 ThrowableFunction1<T,​R>
    A function that takes a single argument of type R and returns a value of type T.
    The difference with this interface and Function is that it allows for raising checked exceptions.
    Primary use case is to create concise lambda expressions such as the Try.map(ThrowableFunction1) and Future.map(ThrowableFunction1) where the function could throw an exception.
    Since:
    1.10
    • Method Detail

      • apply

        R apply​(T t)
         throws java.lang.Throwable
        Applies this function returning a result.
        Parameters:
        t - The value of type T provided to the function
        Returns:
        The function result
        Throws:
        java.lang.Throwable - Any error that may occur when applying the function
        Since:
        1.10