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:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.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(java.util.Collection<? extends E> c, java.lang.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, java.util.Collection<? extends E> c, java.lang.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(java.util.Collection<? extends E> c)protected voidaddListener(java.lang.Object listenerType, IObservablesListener listener)voidclear()protected java.lang.Objectclone()protected voidfireEvent(ObservableEvent event)protected voidfirstListenerAdded()RealmgetRealm()protected booleanhasListeners()protected voidlastListenerRemoved()booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)protected voidremoveListener(java.lang.Object listenerType, IObservablesListener listener)booleanretainAll(java.util.Collection<?> c)static <E> WritableSet<E>withElementType(java.lang.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 org.eclipse.core.databinding.observable.IObservable
addChangeListener, addDisposeListener, addStaleListener, dispose, getRealm, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
-
-
-
-
Constructor Detail
-
WritableSet
public WritableSet()
Constructs a new empty instance in the default realm with anullelement type.
-
WritableSet
public WritableSet(java.util.Collection<? extends E> c, java.lang.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, java.util.Collection<? extends E> c, java.lang.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 interfacejava.util.Collection<E>- Specified by:
addin interfaceIObservableSet<E>- Specified by:
addin interfacejava.util.Set<E>- Overrides:
addin classObservableSet<E>
-
addAll
public boolean addAll(java.util.Collection<? extends E> c)
- Specified by:
addAllin interfacejava.util.Collection<E>- Specified by:
addAllin interfaceIObservableSet<E>- Specified by:
addAllin interfacejava.util.Set<E>- Overrides:
addAllin classObservableSet<E>
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
removein interfacejava.util.Collection<E>- Specified by:
removein interfaceIObservableSet<E>- Specified by:
removein interfacejava.util.Set<E>- Overrides:
removein classObservableSet<E>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
- Specified by:
removeAllin interfacejava.util.Collection<E>- Specified by:
removeAllin interfaceIObservableSet<E>- Specified by:
removeAllin interfacejava.util.Set<E>- Overrides:
removeAllin classObservableSet<E>
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
- Specified by:
retainAllin interfacejava.util.Collection<E>- Specified by:
retainAllin interfaceIObservableSet<E>- Specified by:
retainAllin interfacejava.util.Set<E>- Overrides:
retainAllin classObservableSet<E>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<E>- Specified by:
clearin interfacejava.util.Set<E>- Overrides:
clearin classObservableSet<E>
-
withElementType
public static <E> WritableSet<E> withElementType(java.lang.Object elementType)
- Parameters:
elementType- can benull- Returns:
- new instance with the default realm
-
addListener
protected void addListener(java.lang.Object listenerType, IObservablesListener listener)- Parameters:
listenerType- arbitrary object to identify a type of the listenerlistener- the listener to add; notnull
-
removeListener
protected void removeListener(java.lang.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 java.lang.Object clone() throws java.lang.CloneNotSupportedException- Overrides:
clonein classjava.lang.Object- Throws:
java.lang.CloneNotSupportedException
-
-