Package com.pivovarit.function
Interface ThrowingSupplier<T,E extends java.lang.Exception>
-
- Type Parameters:
T
- the type of the output to the functionE
- 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 Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default ThrowingFunction<java.lang.Void,T,E>
asFunction()
T
get()
default java.util.function.Supplier<java.util.Optional<T>>
lift()
static <T> java.util.function.Supplier<java.util.Optional<T>>
lifted(ThrowingSupplier<T,?> supplier)
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 patterndefault java.util.function.Supplier<T>
uncheck()
static <T> java.util.function.Supplier<T>
unchecked(ThrowingSupplier<T,?> supplier)
-
-
-
Method Detail
-
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
-
-