Interface IOFunction<T,R>

Type Parameters:
T - the type of the input
R - the type of the result
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>
Like SafeFunction but only for IOException
  • Method Details

    • constant

      static <T,R> IOFunction<T,R> constant(R r)
      A IOFunction that always returns the same value, ignoring the input.
      Type Parameters:
      T - the type of the input
      R - the type of the result
      Parameters:
      r - the value to return
      Returns:
      a IOFunction that always returns the given value
    • of

      static <T,R> IOFunction<T,R> of(Function<T,R> function)
      Wrap a Function in a IOFunction
      Type Parameters:
      T - the type of the input
      R - the type of the result
      Parameters:
      function - the function to wrap
      Returns:
      a IOFunction that delegates to the given function
    • apply

      R apply(T t) throws IOException
      Apply the function, possibly throwing an exception.
      Parameters:
      t - the input
      Returns:
      the result
      Throws:
      IOException - if an I/O error occurs
    • applyCatching

      default Result<R> applyCatching(T t)
      Apply the function, catching any exceptions and wrapping them in a Result
      Parameters:
      t - the input
      Returns:
      the result
    • asFunction

      default Function<T,R> asFunction()
      Turn this IOFunction into a Function that sneaky throws any exceptions.
      Returns:
      a Function that sneaky throws any exceptions