Interface DrivenValue<T>
-
- Type Parameters:
T
- The type of the driven value
- All Known Implementing Classes:
AbstractStaticDrivenValue
,ExpressionDrivenStringValue
,ExpressionDrivenValue
,LockGuardedDrivenValue
,LockGuardedDrivenValueCollection
public interface DrivenValue<T>
A DrivenValue contains a value which can change (driven by some source). It hasstartup()
andshutdown()
hooks to allow the implementation to prepare / tear down its instance. The value may be fetched by callinggetAndClear()
which will fetch the current value and reset its dirty state to false. Clients should alwaysstartup()
before using the instance. Before fetching the latest value,isReady()
must be checked and must return true. IfisDirty()
returns false, the last value fetched is the latest value which will be returned on the next call togetAndClear()
. When finished with the instance,shutdown()
must be called to clean up.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Optional<T>
getAndClear()
Fetch the current driven valueboolean
isDirty()
boolean
isReady()
void
shutdown()
Lifecycle hook to shut down the driven valuevoid
startup()
Lifecycle hook to start up the driven value
-
-
-
Method Detail
-
startup
void startup()
Lifecycle hook to start up the driven value
-
shutdown
void shutdown()
Lifecycle hook to shut down the driven value
-
isReady
boolean isReady()
- Returns:
- true if the driven value is ready to fetch
-
isDirty
boolean isDirty()
- Returns:
- true if the driven value has changed since the last time it was fetched
-
getAndClear
@Nonnull java.util.Optional<T> getAndClear()
Fetch the current driven value- Returns:
- An
Optional
containing the current driven value, if present, or an empty Optional if the driven value is null / not present.
-
-