Package com.pivovarit.function
Interface ThrowingSupplier<T,E extends 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.
Represents a function that accepts zero arguments and returns some value.
Function might throw a checked exception instance.
- Author:
- Grzegorz Piwowarek
-
Method Summary
Modifier and TypeMethodDescriptiondefault ThrowingFunction<Void, T, E> get()lift()lifted(ThrowingSupplier<T, ?> supplier) static <T1> Supplier<T1> sneaky(ThrowingSupplier<T1, ?> supplier) Returns a new Supplier instance which rethrows the checked exception using the Sneaky Throws patternuncheck()static <T> Supplier<T> unchecked(ThrowingSupplier<T, ?> supplier)
-
Method Details
-
get
- Throws:
E
-
asFunction
- Returns:
- this Consumer instance as a new Function instance
-
unchecked
-
lifted
-
sneaky
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
- Returns:
- a new Supplier instance which wraps thrown checked exception instance into a RuntimeException
-
lift
- Returns:
- a new Supplier that returns the result as an Optional instance. In case of a failure or null, empty Optional is returned
-