Interface IThrowingFunction<T,​R>

    • Method Detail

      • of

        static <T,​R> IThrowingFunction<T,​R> of​(IThrowingFunction<T,​R> fn)
        Returns the given supplier, for improved variable inference. Sometimes you need to create local variables and assign them to a new lambda. This does not work well with variable inference, as Java cannot infer the type of anonymous lambdas. This utility method lets you write slightly more readable code like this:
         final var fn = ISerializableThrowingFunction.of(t -> ...);
         
        You can also use this helper method to create a function from a lambda expression that throws checked exceptions and use the result as a Function that rethrows checked exceptions as unchecked ones.
        Type Parameters:
        T - the type of the argument expected by the function
        R - the type of the result of the function
        Parameters:
        fn - Function to return.
        Returns:
        The given supplier.
      • throwingFunction

        static <T,​R> IThrowingFunction<T,​R> throwingFunction​(IThrowingFunction<T,​R> fn)
        Returns the given function, for improved variable inference. Sometimes you need to create local variables and assign them to a new lambda. This does not work well with variable inference, as Java cannot infer the type of anonymous lambdas. This utility method lets you write slightly more readable code like this:
         final var fn = throwingFunction(t -> ...);
         
        You can also use this helper method to create a function from a lambda expression that throws checked exceptions and use the result as a Function that rethrows checked exceptions as unchecked ones.
        Type Parameters:
        T - the type of the argument expected by the function
        R - the type of the result of the function
        Parameters:
        fn - Function to return.
        Returns:
        The given supplier.