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 aLockGuardedDrivenValuedriven by aPerspectiveExpression. The injectedvalueChangedCallbackis called by aThreadholding 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 booleandirtyprotected QualifiedValuevalue-
Fields inherited from class com.inductiveautomation.perspective.gateway.driven.LockGuardedDrivenValue
lock
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedExpressionDrivenValue(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 booleanisDirtyInternal()Called after asserting that the calling thread holds the injected lock.protected booleanisReadyInternal()Called after asserting that the calling thread holds the injected lock.protected abstract booleanisValidValue(QualifiedValue value)This method is called when a new value is emitted from the expression.voidshutdown()Lifecycle hook to shut down the driven valuevoidstartup()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:LockGuardedDrivenValueCalled after asserting that the calling thread holds the injected lock.- Specified by:
isReadyInternalin classLockGuardedDrivenValue<T>- See Also:
LockGuardedDrivenValue.isReady()
-
isDirtyInternal
protected boolean isDirtyInternal()
Description copied from class:LockGuardedDrivenValueCalled after asserting that the calling thread holds the injected lock.- Specified by:
isDirtyInternalin classLockGuardedDrivenValue<T>- See Also:
LockGuardedDrivenValue.isDirty()
-
startup
public void startup()
Description copied from interface:DrivenValueLifecycle hook to start up the driven value
-
shutdown
public void shutdown()
Description copied from interface:DrivenValueLifecycle hook to shut down the driven value
-
getAndClear
@Nonnull public java.util.Optional<T> getAndClear()
Description copied from interface:DrivenValueFetch the current driven value- Specified by:
getAndClearin interfaceDrivenValue<T>- Overrides:
getAndClearin classLockGuardedDrivenValue<T>- Returns:
- An
Optionalcontaining the current driven value, if present, or an empty Optional if the driven value is null / not present.
-
-