Class 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 a LockGuardedDrivenValue driven by a PerspectiveExpression. The injected valueChangedCallback is called by a Thread 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.
    • 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
      • 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 interface DrivenValue<T>
        Overrides:
        getAndClear in class LockGuardedDrivenValue<T>
        Returns:
        An Optional containing the current driven value, if present, or an empty Optional if the driven value is null / not present.