Class SetMultimapListenerHelper.AtomicChange<K,V>
- java.lang.Object
-
- org.eclipse.gef.common.collections.SetMultimapChangeListener.Change<K,V>
-
- org.eclipse.gef.common.collections.SetMultimapListenerHelper.AtomicChange<K,V>
-
- Type Parameters:
K
- The key type of the sourceObservableSetMultimap
.V
- The value type of the sourceObservableSetMultimap
.
- Enclosing class:
- SetMultimapListenerHelper<K,V>
public static class SetMultimapListenerHelper.AtomicChange<K,V> extends SetMultimapChangeListener.Change<K,V>
A simple implementation of anSetMultimapChangeListener.Change
.
-
-
Constructor Summary
Constructors Constructor Description AtomicChange(ObservableSetMultimap<K,V> source, SetMultimap<K,V> previousContents, java.util.List<SetMultimapListenerHelper.ElementarySubChange<K,V>> elementarySubChanges)
Creates a newMultisetListenerHelper.AtomicChange
that represents a change comprising multiple elementary sub-changesO.AtomicChange(ObservableSetMultimap<K,V> source, SetMultimap<K,V> previousContents, SetMultimapListenerHelper.ElementarySubChange<K,V> elementarySubChange)
Creates a newSetMultimapListenerHelper.AtomicChange
that represents a change comprising a single elementary sub-change.AtomicChange(ObservableSetMultimap<K,V> source, SetMultimapChangeListener.Change<? extends K,? extends V> change)
Creates a newMultisetListenerHelper.AtomicChange
for the passed in source, based on the data provided in the passed-in change.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description K
getKey()
The key associated with the current elementary sub-change.SetMultimap<K,V>
getPreviousContents()
Returns an unmodifiableSetMultimap
that contains the previous contents of the sourceObservableSetMultimap
before the atomic change was applied.java.util.Set<V>
getValuesAdded()
Retrieves the values that were added for the given key in the current elementary sub-change.java.util.Set<V>
getValuesRemoved()
Retrieves the values that were removed for the given key in the current elementary sub-change.boolean
next()
Places the internal cursor on the next elementary sub-change, so that it be processed usingSetMultimapChangeListener.Change.getKey()
,SetMultimapChangeListener.Change.getValuesAdded()
, andSetMultimapChangeListener.Change.getValuesRemoved()
,SetMultimapChangeListener.Change.wasAdded()
, andSetMultimapChangeListener.Change.wasRemoved()
.void
reset()
Reset the internal cursor to the initial state, so that the first elementary sub-change can be accessed by callingSetMultimapChangeListener.Change.next()
.java.lang.String
toString()
boolean
wasAdded()
Indicates whether elements were added to theObservableSetMultimap
during this elementary sub-change.boolean
wasRemoved()
Indicates whether elements were removed from theObservableSetMultimap
in the current elementary sub-change.-
Methods inherited from class org.eclipse.gef.common.collections.SetMultimapChangeListener.Change
getSetMultimap
-
-
-
-
Constructor Detail
-
AtomicChange
public AtomicChange(ObservableSetMultimap<K,V> source, SetMultimap<K,V> previousContents, SetMultimapListenerHelper.ElementarySubChange<K,V> elementarySubChange)
Creates a newSetMultimapListenerHelper.AtomicChange
that represents a change comprising a single elementary sub-change.- Parameters:
source
- The sourceObservableSetMultimap
from which the change originated.previousContents
- The previous contents of theObservableSetMultimap
before the change was applied.elementarySubChange
- The elementary sub-change that has been applied.
-
AtomicChange
public AtomicChange(ObservableSetMultimap<K,V> source, SetMultimap<K,V> previousContents, java.util.List<SetMultimapListenerHelper.ElementarySubChange<K,V>> elementarySubChanges)
Creates a newMultisetListenerHelper.AtomicChange
that represents a change comprising multiple elementary sub-changesO.- Parameters:
source
- The sourceObservableMultiset
from which the change originated.previousContents
- The previous contents of theObservableMultiset
before the change was applied.elementarySubChanges
- The elementary sub-changes that have been applied as part of this change.
-
AtomicChange
public AtomicChange(ObservableSetMultimap<K,V> source, SetMultimapChangeListener.Change<? extends K,? extends V> change)
Creates a newMultisetListenerHelper.AtomicChange
for the passed in source, based on the data provided in the passed-in change.This is basically used to allow properties wrapping an
ObservableMultiset
to re-fire change events of their wrappedObservableMultiset
with themselves as source.- Parameters:
source
- The new sourceObservableMultiset
.change
- The change to infer a new change from. It is expected that the change is in initial state. In either case it will be reset to initial state.
-
-
Method Detail
-
getKey
public K getKey()
Description copied from class:SetMultimapChangeListener.Change
The key associated with the current elementary sub-change.This method depends on the state of the internal cursor that can be manipulated via
SetMultimapChangeListener.Change.next()
andSetMultimapChangeListener.Change.reset()
.- Specified by:
getKey
in classSetMultimapChangeListener.Change<K,V>
- Returns:
- The key for which values were added or removed.
-
getPreviousContents
public SetMultimap<K,V> getPreviousContents()
Description copied from class:SetMultimapChangeListener.Change
Returns an unmodifiableSetMultimap
that contains the previous contents of the sourceObservableSetMultimap
before the atomic change was applied.This method does not depend on the state of the internal cursor, may thus be accessed independent on which elementary sub-change is currently processed.
- Specified by:
getPreviousContents
in classSetMultimapChangeListener.Change<K,V>
- Returns:
- An unmodifiable
SetMultimap
representing the contents of theObservableSetMultimap
before the change.
-
getValuesAdded
public java.util.Set<V> getValuesAdded()
Description copied from class:SetMultimapChangeListener.Change
Retrieves the values that were added for the given key in the current elementary sub-change.This method depends on the state of the internal cursor that can be manipulated via
SetMultimapChangeListener.Change.next()
andSetMultimapChangeListener.Change.reset()
.- Specified by:
getValuesAdded
in classSetMultimapChangeListener.Change<K,V>
- Returns:
- The values that have become associated with the key.
-
getValuesRemoved
public java.util.Set<V> getValuesRemoved()
Description copied from class:SetMultimapChangeListener.Change
Retrieves the values that were removed for the given key in the current elementary sub-change.This method depends on the state of the internal cursor that can be manipulated via
SetMultimapChangeListener.Change.next()
andSetMultimapChangeListener.Change.reset()
.- Specified by:
getValuesRemoved
in classSetMultimapChangeListener.Change<K,V>
- Returns:
- The values previously associated with the key.
-
next
public boolean next()
Description copied from class:SetMultimapChangeListener.Change
Places the internal cursor on the next elementary sub-change, so that it be processed usingSetMultimapChangeListener.Change.getKey()
,SetMultimapChangeListener.Change.getValuesAdded()
, andSetMultimapChangeListener.Change.getValuesRemoved()
,SetMultimapChangeListener.Change.wasAdded()
, andSetMultimapChangeListener.Change.wasRemoved()
. This method has to be called initially to have the internal cursor point to the first elementary sub-change that is comprised.- Specified by:
next
in classSetMultimapChangeListener.Change<K,V>
- Returns:
true
if the internal cursor could be switched to the next elementary sub-change,false
if the current elementary sub-change was the last change that is comprised.
-
reset
public void reset()
Description copied from class:SetMultimapChangeListener.Change
Reset the internal cursor to the initial state, so that the first elementary sub-change can be accessed by callingSetMultimapChangeListener.Change.next()
.- Specified by:
reset
in classSetMultimapChangeListener.Change<K,V>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
wasAdded
public boolean wasAdded()
Description copied from class:SetMultimapChangeListener.Change
Indicates whether elements were added to theObservableSetMultimap
during this elementary sub-change.This method depends on the state of the internal cursor that can be manipulated via
SetMultimapChangeListener.Change.next()
andSetMultimapChangeListener.Change.reset()
.- Specified by:
wasAdded
in classSetMultimapChangeListener.Change<K,V>
- Returns:
true
if new values or (key-value) entries were added to theObservableSetMultimap
,false
otherwise.
-
wasRemoved
public boolean wasRemoved()
Description copied from class:SetMultimapChangeListener.Change
Indicates whether elements were removed from theObservableSetMultimap
in the current elementary sub-change.This method depends on the state of the internal cursor that can be manipulated via
SetMultimapChangeListener.Change.next()
andSetMultimapChangeListener.Change.reset()
.- Specified by:
wasRemoved
in classSetMultimapChangeListener.Change<K,V>
- Returns:
true
if old values or (key-value) entries were removed from theObservableSetMultimap
,false
otherwise.
-
-