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 anull
element 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 anull
element 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 boolean
add(E o)
boolean
addAll(Collection<? extends E> c)
protected void
addListener(Object listenerType, IObservablesListener listener)
void
clear()
protected Object
clone()
protected void
fireEvent(ObservableEvent event)
protected void
firstListenerAdded()
Realm
getRealm()
protected boolean
hasListeners()
protected void
lastListenerRemoved()
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
protected void
removeListener(Object listenerType, IObservablesListener listener)
boolean
retainAll(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 anull
element 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 anull
element 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:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceIObservableSet<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classObservableSet<E>
-
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceIObservableSet<E>
- Specified by:
addAll
in interfaceSet<E>
- Overrides:
addAll
in classObservableSet<E>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceIObservableSet<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classObservableSet<E>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceIObservableSet<E>
- Specified by:
removeAll
in interfaceSet<E>
- Overrides:
removeAll
in classObservableSet<E>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceIObservableSet<E>
- Specified by:
retainAll
in interfaceSet<E>
- Overrides:
retainAll
in classObservableSet<E>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Overrides:
clear
in 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:
clone
in classObject
- Throws:
CloneNotSupportedException
-
-