Class ObservableSet<E>
- java.lang.Object
-
- org.eclipse.core.databinding.observable.AbstractObservable
-
- org.eclipse.core.databinding.observable.set.ObservableSet<E>
-
- Type Parameters:
E
- the type of elements in this collection
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
,IObservable
,IObservableCollection<E>
,IObservableSet<E>
- Direct Known Subclasses:
ListToSetAdapter
,MappedSet
,UnionSet
,WritableSet
public abstract class ObservableSet<E> extends AbstractObservable implements IObservableSet<E>
Abstract 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 Modifier and Type Field Description protected Object
elementType
protected Set<E>
wrappedSet
-
Constructor Summary
Constructors Modifier Constructor Description protected
ObservableSet(Set<E> wrappedSet, Object elementType)
protected
ObservableSet(Realm realm, Set<E> wrappedSet, Object elementType)
-
Method Summary
All 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
addSetChangeListener(ISetChangeListener<? super E> listener)
void
clear()
protected Object
clone()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
void
dispose()
Disposes of this observable object, removing all listeners registered with this object, and all listeners this object might have registered on other objects.boolean
equals(Object o)
protected void
fireChange()
protected void
fireEvent(ObservableEvent event)
protected void
fireSetChange(SetDiff<E> diff)
protected void
firstListenerAdded()
Object
getElementType()
Returns the element type of this observable collection, ornull
if this observable collection is untyped.Realm
getRealm()
protected void
getterCalled()
int
hashCode()
protected boolean
hasListeners()
boolean
isEmpty()
boolean
isStale()
Returns whether the state of this observable is stale and is expected to change soon.Iterator<E>
iterator()
protected void
lastListenerRemoved()
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
protected void
removeListener(Object listenerType, IObservablesListener listener)
void
removeSetChangeListener(ISetChangeListener<? super E> listener)
boolean
retainAll(Collection<?> c)
void
setStale(boolean stale)
protected void
setWrappedSet(Set<E> wrappedSet)
int
size()
Object[]
toArray()
<T> T[]
toArray(T[] a)
String
toString()
-
Methods inherited from class org.eclipse.core.databinding.observable.AbstractObservable
addChangeListener, addDisposeListener, addStaleListener, checkRealm, 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, getRealm, isDisposed, removeChangeListener, removeDisposeListener, removeStaleListener
-
Methods inherited from interface java.util.Set
spliterator
-
-
-
-
Method Detail
-
addSetChangeListener
public void addSetChangeListener(ISetChangeListener<? super E> listener)
- Specified by:
addSetChangeListener
in interfaceIObservableSet<E>
-
removeSetChangeListener
public void removeSetChangeListener(ISetChangeListener<? super E> listener)
- Specified by:
removeSetChangeListener
in interfaceIObservableSet<E>
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceIObservableSet<E>
- Specified by:
contains
in interfaceSet<E>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceIObservableSet<E>
- Specified by:
containsAll
in interfaceSet<E>
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceIObservableSet<E>
- Specified by:
isEmpty
in interfaceSet<E>
-
size
public int size()
- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceIObservableSet<E>
- Specified by:
size
in interfaceSet<E>
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceIObservableSet<E>
- Specified by:
toArray
in interfaceSet<E>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceIObservableSet<E>
- Specified by:
toArray
in interfaceSet<E>
-
getterCalled
protected void getterCalled()
-
add
public boolean add(E o)
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceIObservableSet<E>
- Specified by:
add
in interfaceSet<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>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceIObservableSet<E>
- Specified by:
remove
in interfaceSet<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>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceIObservableSet<E>
- Specified by:
retainAll
in interfaceSet<E>
-
clear
public void clear()
-
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 interfaceIObservable
- 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.
-
setWrappedSet
protected void setWrappedSet(Set<E> wrappedSet)
- Parameters:
wrappedSet
- The wrappedSet to set.
-
fireChange
protected void fireChange()
- Overrides:
fireChange
in classAbstractObservable
-
dispose
public void dispose()
Description copied from interface:IObservable
Disposes of this observable object, removing all listeners registered with this object, and all listeners this object might have registered on other objects.- Specified by:
dispose
in interfaceIObservable
- Overrides:
dispose
in classAbstractObservable
-
getElementType
public Object getElementType()
Description copied from interface:IObservableCollection
Returns the element type of this observable collection, ornull
if this observable collection is untyped.- Specified by:
getElementType
in interfaceIObservableCollection<E>
- Specified by:
getElementType
in interfaceIObservableSet<E>
- Returns:
- the element type or
null
if untyped
-
addListener
protected void addListener(Object listenerType, IObservablesListener listener)
- Parameters:
listenerType
-listener
-
-
removeListener
protected void removeListener(Object listenerType, IObservablesListener listener)
- Parameters:
listenerType
-listener
-
-
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
-
-