Class ExpressionDrivenValue<T>
- java.lang.Object
-
- com.inductiveautomation.perspective.gateway.driven.LockGuardedDrivenValue<T>
-
- com.inductiveautomation.perspective.gateway.driven.ExpressionDrivenValue<T>
-
- Type Parameters:
T
- The type of the driven value
- All Implemented Interfaces:
DrivenValue<T>
- Direct Known Subclasses:
ExpressionDrivenStringValue
public abstract class ExpressionDrivenValue<T> extends LockGuardedDrivenValue<T>
An ExpressionDrivenValue is aLockGuardedDrivenValue
driven by aPerspectiveExpression
. The injectedvalueChangedCallback
is called by aThread
holding the injected lock object when a new value is emitted from the expression and it passes validation. Derived classes get to decide what passing validation means.
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
dirty
protected QualifiedValue
value
-
Fields inherited from class com.inductiveautomation.perspective.gateway.driven.LockGuardedDrivenValue
lock
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ExpressionDrivenValue(java.lang.Object lock, PerspectiveExpression expr, java.lang.Runnable valueChangedCallback)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.Optional<T>
getAndClear()
Fetch the current driven valueprotected boolean
isDirtyInternal()
Called after asserting that the calling thread holds the injected lock.protected boolean
isReadyInternal()
Called after asserting that the calling thread holds the injected lock.protected abstract boolean
isValidValue(QualifiedValue value)
This method is called when a new value is emitted from the expression.void
shutdown()
Lifecycle hook to shut down the driven valuevoid
startup()
Lifecycle hook to start up the driven value-
Methods inherited from class com.inductiveautomation.perspective.gateway.driven.LockGuardedDrivenValue
getAndClearInternal, isDirty, isReady
-
-
-
-
Field Detail
-
value
protected QualifiedValue value
-
dirty
protected boolean dirty
-
-
Constructor Detail
-
ExpressionDrivenValue
protected ExpressionDrivenValue(@Nonnull java.lang.Object lock, @Nonnull PerspectiveExpression expr, @Nonnull java.lang.Runnable valueChangedCallback)
-
-
Method Detail
-
isValidValue
protected abstract boolean isValidValue(QualifiedValue value)
This method is called when a new value is emitted from the expression. If the value passes validation, the value is set, dirty bits are set, and the callback is notified. If the value does not pass validation, nothing happens and a debug message is logged.- Parameters:
value
- the latest value emitted from the expression- Returns:
- true if the value passes validation, false otherwise
-
isReadyInternal
protected boolean isReadyInternal()
Description copied from class:LockGuardedDrivenValue
Called after asserting that the calling thread holds the injected lock.- Specified by:
isReadyInternal
in classLockGuardedDrivenValue<T>
- See Also:
LockGuardedDrivenValue.isReady()
-
isDirtyInternal
protected boolean isDirtyInternal()
Description copied from class:LockGuardedDrivenValue
Called after asserting that the calling thread holds the injected lock.- Specified by:
isDirtyInternal
in classLockGuardedDrivenValue<T>
- See Also:
LockGuardedDrivenValue.isDirty()
-
startup
public void startup()
Description copied from interface:DrivenValue
Lifecycle hook to start up the driven value
-
shutdown
public void shutdown()
Description copied from interface:DrivenValue
Lifecycle hook to shut down the driven value
-
getAndClear
@Nonnull public java.util.Optional<T> getAndClear()
Description copied from interface:DrivenValue
Fetch the current driven value- Specified by:
getAndClear
in interfaceDrivenValue<T>
- Overrides:
getAndClear
in classLockGuardedDrivenValue<T>
- Returns:
- An
Optional
containing the current driven value, if present, or an empty Optional if the driven value is null / not present.
-
-