Class AbstractObservableValue<T>

    • Constructor Detail

      • AbstractObservableValue

        public AbstractObservableValue()
        Constructs a new instance with the default realm.
      • AbstractObservableValue

        public AbstractObservableValue​(Realm realm)
        Parameters:
        realm - the realm to use; not null
    • Method Detail

      • setValue

        public final void setValue​(T value)
        Description copied from interface: IObservableValue
        Sets the value. Must be invoked in the Realm of the observable.
        Specified by:
        setValue in interface IObservableValue<T>
        Parameters:
        value - the value to set
      • doSetValue

        protected void doSetValue​(T value)
        Template method for setting the value of the observable. By default the method throws an UnsupportedOperationException.
        Parameters:
        value - the value to set
      • fireValueChange

        protected void fireValueChange​(ValueDiff<T> diff)
      • getValue

        public final T getValue()
        Description copied from interface: IObservableValue
        Returns the value. Must be invoked in the Realm of the observable.
        Specified by:
        getValue in interface IObservableValue<T>
        Returns:
        the current value
      • doGetValue

        protected abstract T doGetValue()
      • isStale

        public boolean isStale()
        Description copied from interface: IObservable
        Returns whether the state of this observable is stale and is expected to change soon. A non-stale observable that becomes stale will notify its stale listeners. A stale object that becomes non-stale does so by changing its state and notifying its change listeners, it does not notify its stale listeners about becoming non-stale. Clients that do not expect asynchronous changes may ignore staleness of observable objects.
        Specified by:
        isStale in interface IObservable
        Returns:
        true if this observable's state is stale and will change soon.
      • addListener

        protected void addListener​(Object listenerType,
                                   IObservablesListener listener)
        Parameters:
        listenerType - arbitrary object to identify a type of the listener
        listener - the listener to add; not null
      • removeListener

        protected void removeListener​(Object listenerType,
                                      IObservablesListener listener)
        Parameters:
        listenerType - arbitrary object to identify a type of the listener
        listener - the listener to remove; not null
      • hasListeners

        protected boolean hasListeners()
      • firstListenerAdded

        protected void firstListenerAdded()
      • lastListenerRemoved

        protected void lastListenerRemoved()
      • getRealm

        public Realm getRealm()
        Returns:
        Returns the realm.