Package de.xima.fc.interfaces
Interface ISerializableThrowingSupplier<T>
-
- Type Parameters:
T
- the type of results supplied by this supplier
- All Superinterfaces:
Serializable
,Supplier<T>
- 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 ISerializableThrowingSupplier<T> extends Supplier<T>, Serializable
ASupplier
that is also serializable and can throw exceptions.Represents a supplier of results.
There is no requirement that a new or distinct result be returned each time the supplier is invoked.
This is a
functional interface
whose functional method isget()
.- Since:
- 8.0.1
- Author:
- XIMA MEDIA GmbH
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default T
get()
static <T> ISerializableThrowingSupplier<T>
of(ISerializableThrowingSupplier<T> supplier)
Returns the given supplier, for improved variable inference.T
tryGet()
Gets a result.
-
-
-
Method Detail
-
tryGet
T tryGet() throws Exception
Gets a result.- Returns:
- The result
- Throws:
Exception
- When this operation fails.
-
of
static <T> ISerializableThrowingSupplier<T> of(ISerializableThrowingSupplier<T> supplier)
Returns the given supplier, for improved variable inference. Sometimes you need to create local variables and assign them to a new lambda. This does not work well with variable inference, as Java cannot infer the type of an anonymous lambda. This utility method lets you write slightly more readable code like this:final var supplier = ISerializableThrowingSupplier.of(t -> ...);
- Type Parameters:
T
- the type of results supplied by this supplier- Parameters:
supplier
- Supplier to return.- Returns:
- The given supplier.
-
-