Interface ThrowingSupplier<T,E extends Exception>

Type Parameters:
T - the type of the output to the function
E - the type of the thrown checked exception
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 ThrowingSupplier<T,E extends Exception>
Represents a function that accepts zero arguments and returns some value. Function might throw a checked exception instance.
  • Method Details

    • get

      T get() throws E
      Throws:
      E
    • asFunction

      default ThrowingFunction<Void,T,E> asFunction()
      Returns:
      this Consumer instance as a new Function instance
    • unchecked

      static <T> Supplier<T> unchecked(ThrowingSupplier<T,?> supplier)
    • lifted

      static <T> Supplier<Optional<T>> lifted(ThrowingSupplier<T,?> supplier)
    • sneaky

      static <T1> Supplier<T1> sneaky(ThrowingSupplier<T1,?> supplier)
      Returns a new Supplier instance which rethrows the checked exception using the Sneaky Throws pattern
      Returns:
      Supplier instance that rethrows the checked exception using the Sneaky Throws pattern
    • uncheck

      default Supplier<T> uncheck()
      Returns:
      a new Supplier instance which wraps thrown checked exception instance into a RuntimeException
    • lift

      default Supplier<Optional<T>> lift()
      Returns:
      a new Supplier that returns the result as an Optional instance. In case of a failure or null, empty Optional is returned