Interface ThrowingSupplier<T,​E extends java.lang.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 java.lang.Exception>
    Represents a function that accepts zero arguments and returns some value. Function might throw a checked exception instance.
    • Method Detail

      • get

        T get()
        throws E extends java.lang.Exception
        Throws:
        E extends java.lang.Exception
      • asFunction

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

        static <T> java.util.function.Supplier<T> unchecked​(ThrowingSupplier<T,​?> supplier)
      • lifted

        static <T> java.util.function.Supplier<java.util.Optional<T>> lifted​(ThrowingSupplier<T,​?> supplier)
      • sneaky

        static <T1> java.util.function.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 java.util.function.Supplier<T> uncheck()
        Returns:
        a new Supplier instance which wraps thrown checked exception instance into a RuntimeException
      • lift

        default java.util.function.Supplier<java.util.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