Class ObservableSet<T>

  • Type Parameters:
    T - the type of element in this set
    All Implemented Interfaces:
    Iterable<T>, Collection<T>, Set<T>


    public class ObservableSet<T>
    extends Object
    implements Set<T>
    A Set that allows listeners.

    This class is just a wrapper that manages the listeners; the actual work is done by another Set of your choice.

    The synchronization model here is similar to (but not as thorough as) the architecture used for the ObservableList.

    • Field Detail

      • readSemaphore

        protected final Semaphore readSemaphore
    • Constructor Detail

      • ObservableSet

        public ObservableSet(Class<T> componentType)
        Create an ObservableSet that uses a HashSet.
        Parameters:
        componentType - the component type to be used when converting this set to an array.
      • ObservableSet

        public ObservableSet(Class<T> componentType,
                             Set<T> s)
        Parameters:
        componentType - the component type to be used when converting this set to an array.
        s - the model used for data storage.
    • Method Detail

      • size

        public int size()
      • isEmpty

        public boolean isEmpty()
      • contains

        public boolean contains(Object o)
      • fireAllListeners

        protected void fireAllListeners(ObservableSet.SetDataEvent<T> event)
        This fires first the Listeners, and then the ChangeListeners.
      • toArray

        public Object[] toArray()
      • toArray

        public <S> S[] toArray(S[] a)
      • execute

        protected <R> R execute(com.bric.util.ObservableSet.Operation<R> op)
      • add

        public boolean add(T e)
      • remove

        public boolean remove(Object o)
      • containsAll

        public boolean containsAll(Collection<?> c)
      • addAll

        public boolean addAll(Collection<? extends T> c)
      • retainAll

        public boolean retainAll(Collection<?> c)
      • removeAll

        public boolean removeAll(Collection<?> c)
      • clear

        public void clear()
      • equals

        public boolean equals(Object o)
      • hashCode

        public int hashCode()
      • toComponentArray

        public T[] toComponentArray()
        Create an array returning all the elements of this set.

        This method uses the existing read/write locking architecture the ObservableSet uses, so it is safer than synchronizing this list to extract the elements separately.

        Returns:
        an array representation of all elements in this set.
      • addChangeListener

        public void addChangeListener(ChangeListener changeListener)
      • removeChangeListener

        public void removeChangeListener(ChangeListener changeListener)