P - Type-variable for the promised value.T - Type-variable for the possibly existing value.public final class PromisedValue<P,T> extends Object
A value of type P is always available (thus; promised).
Used by Emoji.getCategory().
| Modifier and Type | Class and Description |
|---|---|
static interface |
PromisedValue.NullableFunction<P,T>
Supertype of
Function with a Nullable annotation for IntelliJ code inspection. |
| Constructor and Description |
|---|
PromisedValue(P promisedValue,
PromisedValue.NullableFunction<P,T> mapper)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Optional<T> |
getPossibleValue()
Tries to fetch the possible value using the provided
mapper. |
P |
getPromisedValue()
Returns the promised value.
|
public PromisedValue(P promisedValue, PromisedValue.NullableFunction<P,T> mapper)
promisedValue - The promised value. This will be used to fetch the possible value later.mapper - A function to determine the possible value based on the defined promised value.public P getPromisedValue()
public Optional<T> getPossibleValue()
mapper.
If the mapper also returns null, the returned Optional is empty. Although, it might succeed on the next try. Once the Optional returns non-empty, the possible value remains the same.