public interface ImmediateSupplier<T>
Supplier that has an extra method capable of supplying a value immediately or an absent if definitely not available,
or throwing an ImmediateSupplier.ImmediateUnsupportedException if it cannot determine whether a value is immediately available.| Modifier and Type | Interface and Description |
|---|---|
static class |
ImmediateSupplier.ImmediateUnsupportedException
Indicates that a supplier does not support immediate evaluation,
i.e.
|
static class |
ImmediateSupplier.ImmediateValueNotAvailableException
Indicates that an attempt was made to forcibly get a requested immediate value
where blocking is required.
|
| Modifier and Type | Method and Description |
|---|---|
Maybe<T> |
getImmediately()
Gets the value promptly, or returns
Maybe.absent() if the value requires blocking,
or throws ImmediateSupplier.ImmediateUnsupportedException if it cannot be determined whether the value requires blocking or not. |
Maybe<T> getImmediately()
Maybe.absent() if the value requires blocking,
or throws ImmediateSupplier.ImmediateUnsupportedException if it cannot be determined whether the value requires blocking or not.
The Maybe.absent() returned here indicates that a value definitively is pending, just it is not yet available,
and an attempt to Maybe.get() it should throw an ImmediateSupplier.ImmediateValueNotAvailableException;
it can be created with ImmediateSupplier.ImmediateValueNotAvailableException.newAbsentWithExceptionSupplier() to
avoid creating traces (or simply with Maybe.absent(new ImmediateValueNotAvailableException(...))).
This is in contrast with this method throwing a ImmediateSupplier.ImmediateUnsupportedException which should be done
if the presence of an eventual value cannot even be determined in a non-blocking way.
Implementations of this method should typically catch the former exception if encountered and return a
Maybe.absent() wrapping it, whereas ImmediateSupplier.ImmediateUnsupportedException instances should be propagated.
ImmediateSupplier.ImmediateUnsupportedException - as above, if cannot be determined whether a value is or might eventually be available