Class WritableSet<E>
- java.lang.Object
-
- org.eclipse.core.databinding.observable.AbstractObservable
-
- org.eclipse.core.databinding.observable.set.ObservableSet<E>
-
- org.eclipse.core.databinding.observable.set.WritableSet<E>
-
- Type Parameters:
E- the type of elements in this set
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>,IObservable,IObservableCollection<E>,IObservableSet<E>
public class WritableSet<E> extends ObservableSet<E>
Mutable (writable) implementation ofIObservableSet.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
-
-
Field Summary
-
Fields inherited from class org.eclipse.core.databinding.observable.set.ObservableSet
elementType, wrappedSet
-
-
Constructor Summary
Constructors Constructor Description WritableSet()Constructs a new empty instance in the default realm with anullelement type.WritableSet(Collection<? extends E> c, Object elementType)Constructs a new instance in the default realm containing the elements of the given collection.WritableSet(Realm realm)Constructs a new empty instance in the given realm and anullelement type.WritableSet(Realm realm, Collection<? extends E> c, Object elementType)Constructs a new instance in the default realm with the given element type, containing the elements of the given collection.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E o)booleanaddAll(Collection<? extends E> c)protected voidaddListener(Object listenerType, IObservablesListener listener)voidclear()protected Objectclone()protected voidfireEvent(ObservableEvent event)protected voidfirstListenerAdded()RealmgetRealm()protected booleanhasListeners()protected voidlastListenerRemoved()booleanremove(Object o)booleanremoveAll(Collection<?> c)protected voidremoveListener(Object listenerType, IObservablesListener listener)booleanretainAll(Collection<?> c)static <E> WritableSet<E>withElementType(Object elementType)-
Methods inherited from class org.eclipse.core.databinding.observable.set.ObservableSet
addSetChangeListener, contains, containsAll, equals, fireChange, fireSetChange, getElementType, getterCalled, hashCode, isEmpty, isStale, iterator, removeSetChangeListener, setStale, setWrappedSet, size, toArray, toArray, toString
-
Methods inherited from class org.eclipse.core.databinding.observable.AbstractObservable
addChangeListener, addDisposeListener, addStaleListener, checkRealm, dispose, fireStale, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface org.eclipse.core.databinding.observable.IObservable
addChangeListener, addDisposeListener, addStaleListener, dispose, getRealm, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
-
Methods inherited from interface java.util.Set
spliterator
-
-
-
-
Constructor Detail
-
WritableSet
public WritableSet()
Constructs a new empty instance in the default realm with anullelement type.
-
WritableSet
public WritableSet(Collection<? extends E> c, Object elementType)
Constructs a new instance in the default realm containing the elements of the given collection. Changes to the given collection after calling this method do not affect the contents of the created WritableSet.- Parameters:
c- elements to initialize this set withelementType- can benull
-
WritableSet
public WritableSet(Realm realm)
Constructs a new empty instance in the given realm and anullelement type.- Parameters:
realm- the realm
-
WritableSet
public WritableSet(Realm realm, Collection<? extends E> c, Object elementType)
Constructs a new instance in the default realm with the given element type, containing the elements of the given collection. Changes to the given collection after calling this method do not affect the contents of the created WritableSet.- Parameters:
realm- the realmc- elements to initialize this set withelementType- can benull
-
-
Method Detail
-
add
public boolean add(E o)
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceIObservableSet<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin classObservableSet<E>
-
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceIObservableSet<E>- Specified by:
addAllin interfaceSet<E>- Overrides:
addAllin classObservableSet<E>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceIObservableSet<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classObservableSet<E>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceIObservableSet<E>- Specified by:
removeAllin interfaceSet<E>- Overrides:
removeAllin classObservableSet<E>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceIObservableSet<E>- Specified by:
retainAllin interfaceSet<E>- Overrides:
retainAllin classObservableSet<E>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classObservableSet<E>
-
withElementType
public static <E> WritableSet<E> withElementType(Object elementType)
- Parameters:
elementType- can benull- Returns:
- new instance with the default realm
-
addListener
protected void addListener(Object listenerType, IObservablesListener listener)
- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to add; notnull
-
removeListener
protected void removeListener(Object listenerType, IObservablesListener listener)
- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to remove; notnull
-
hasListeners
protected boolean hasListeners()
-
fireEvent
protected void fireEvent(ObservableEvent event)
-
firstListenerAdded
protected void firstListenerAdded()
-
lastListenerRemoved
protected void lastListenerRemoved()
-
getRealm
public Realm getRealm()
- Returns:
- Returns the realm.
-
clone
protected Object clone() throws CloneNotSupportedException
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
-