Class LockGuardedDrivenValue<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Object lock  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected LockGuardedDrivenValue​(java.lang.Object lock)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<T> getAndClear()
      Fetch the current driven value
      protected abstract java.util.Optional<T> getAndClearInternal()
      Called after asserting that the calling thread holds the injected lock.
      boolean isDirty()  
      protected abstract boolean isDirtyInternal()
      Called after asserting that the calling thread holds the injected lock.
      boolean isReady()  
      protected abstract boolean isReadyInternal()
      Called after asserting that the calling thread holds the injected lock.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • lock

        protected final java.lang.Object lock
    • Constructor Detail

      • LockGuardedDrivenValue

        protected LockGuardedDrivenValue​(@Nonnull
                                         java.lang.Object lock)
    • Method Detail

      • isReadyInternal

        protected abstract boolean isReadyInternal()
        Called after asserting that the calling thread holds the injected lock.
        See Also:
        isReady()
      • isReady

        public boolean isReady()
        Specified by:
        isReady in interface DrivenValue<T>
        Returns:
        true if the driven value is ready to fetch
      • isDirtyInternal

        protected abstract boolean isDirtyInternal()
        Called after asserting that the calling thread holds the injected lock.
        See Also:
        isDirty()
      • isDirty

        public boolean isDirty()
        Specified by:
        isDirty in interface DrivenValue<T>
        Returns:
        true if the driven value has changed since the last time it was fetched
      • getAndClearInternal

        @Nonnull
        protected abstract java.util.Optional<T> getAndClearInternal()
        Called after asserting that the calling thread holds the injected lock.
        See Also:
        getAndClear()
      • 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>
        Returns:
        An Optional containing the current driven value, if present, or an empty Optional if the driven value is null / not present.