Class AbstractObservableSet<E>

  • Type Parameters:
    E - the type of the elements in this set
    All Implemented Interfaces:
    java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>, IObservable, IObservableCollection<E>, IObservableSet<E>
    Direct Known Subclasses:
    ComputedSet

    public abstract class AbstractObservableSet<E>
    extends AbstractObservable
    implements IObservableSet<E>
    Abstract implementation of IObservableSet.

    This class is thread safe. All state accessing methods must be invoked from the current realm. Methods for adding and removing listeners may be invoked from any thread.

    Since:
    1.0
    Implementation Note:
    If methods are added to the interface which this class implements then implementations of those methods must be added to this class.
    • Constructor Detail

      • AbstractObservableSet

        protected AbstractObservableSet()
      • AbstractObservableSet

        protected AbstractObservableSet​(Realm realm)
    • Method Detail

      • getWrappedSet

        protected abstract java.util.Set<E> getWrappedSet()
      • fireSetChange

        protected void fireSetChange​(SetDiff<E> diff)
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<E>
        Specified by:
        contains in interface IObservableSet<E>
        Specified by:
        contains in interface java.util.Set<E>
      • containsAll

        public boolean containsAll​(java.util.Collection<?> c)
        Specified by:
        containsAll in interface java.util.Collection<E>
        Specified by:
        containsAll in interface IObservableSet<E>
        Specified by:
        containsAll in interface java.util.Set<E>
      • equals

        public boolean equals​(java.lang.Object o)
        Specified by:
        equals in interface java.util.Collection<E>
        Specified by:
        equals in interface IObservableSet<E>
        Specified by:
        equals in interface java.util.Set<E>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Specified by:
        hashCode in interface java.util.Collection<E>
        Specified by:
        hashCode in interface IObservableSet<E>
        Specified by:
        hashCode in interface java.util.Set<E>
        Overrides:
        hashCode in class java.lang.Object
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Collection<E>
        Specified by:
        isEmpty in interface IObservableSet<E>
        Specified by:
        isEmpty in interface java.util.Set<E>
      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.util.Collection<E>
        Specified by:
        iterator in interface IObservableSet<E>
        Specified by:
        iterator in interface java.lang.Iterable<E>
        Specified by:
        iterator in interface java.util.Set<E>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<E>
        Specified by:
        size in interface IObservableSet<E>
        Specified by:
        size in interface java.util.Set<E>
      • toArray

        public java.lang.Object[] toArray()
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface IObservableSet<E>
        Specified by:
        toArray in interface java.util.Set<E>
      • toArray

        public <T> T[] toArray​(T[] a)
        Specified by:
        toArray in interface java.util.Collection<E>
        Specified by:
        toArray in interface IObservableSet<E>
        Specified by:
        toArray in interface java.util.Set<E>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getterCalled

        protected void getterCalled()
      • add

        public boolean add​(E o)
        Specified by:
        add in interface java.util.Collection<E>
        Specified by:
        add in interface IObservableSet<E>
        Specified by:
        add in interface java.util.Set<E>
      • addAll

        public boolean addAll​(java.util.Collection<? extends E> c)
        Specified by:
        addAll in interface java.util.Collection<E>
        Specified by:
        addAll in interface IObservableSet<E>
        Specified by:
        addAll in interface java.util.Set<E>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<E>
        Specified by:
        remove in interface IObservableSet<E>
        Specified by:
        remove in interface java.util.Set<E>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> c)
        Specified by:
        removeAll in interface java.util.Collection<E>
        Specified by:
        removeAll in interface IObservableSet<E>
        Specified by:
        removeAll in interface java.util.Set<E>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> c)
        Specified by:
        retainAll in interface java.util.Collection<E>
        Specified by:
        retainAll in interface IObservableSet<E>
        Specified by:
        retainAll in interface java.util.Set<E>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<E>
        Specified by:
        clear in interface java.util.Set<E>
      • 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:
        Returns the stale state.
      • setStale

        public void setStale​(boolean stale)
        Parameters:
        stale - The stale state to set. This will fire a stale event if the given boolean is true and this observable set was not already stale.
      • addListener

        protected void addListener​(java.lang.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​(java.lang.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.
      • clone

        protected java.lang.Object clone()
                                  throws java.lang.CloneNotSupportedException
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException