Class FunctionalIO

java.lang.Object
org.apache.hadoop.util.functional.FunctionalIO

@Private public final class FunctionalIO extends Object
Functional utilities for IO operations.
  • Method Details

    • uncheckIOExceptions

      public static <T> T uncheckIOExceptions(CallableRaisingIOE<T> call)
      Invoke any operation, wrapping IOExceptions with UncheckedIOException.
      Type Parameters:
      T - type of result
      Parameters:
      call - callable
      Returns:
      result
      Throws:
      UncheckedIOException - if an IOE was raised.
    • toUncheckedIOExceptionSupplier

      public static <T> Supplier<T> toUncheckedIOExceptionSupplier(CallableRaisingIOE<T> call)
      Type Parameters:
      T - type of result
      Parameters:
      call - call to wrap
      Returns:
      a supplier which invokes the call.
    • extractIOExceptions

      public static <T> T extractIOExceptions(Supplier<T> call) throws IOException
      Invoke the supplier, catching any UncheckedIOException raised, extracting the inner IOException and rethrowing it.
      Type Parameters:
      T - type of result
      Parameters:
      call - call to invoke
      Returns:
      result
      Throws:
      IOException - if the call raised an IOException wrapped by an UncheckedIOException.
    • toUncheckedFunction

      public static <T, R> Function<T,R> toUncheckedFunction(FunctionRaisingIOE<T,R> fun)
      Type Parameters:
      T - type of input
      R - type of return value.
      Parameters:
      fun - function to wrap
      Returns:
      a new function which invokes the inner function and wraps exceptions.