Class MultisetListenerHelper.AtomicChange<E>
- java.lang.Object
-
- org.eclipse.gef.common.collections.MultisetChangeListener.Change<E>
-
- org.eclipse.gef.common.collections.MultisetListenerHelper.AtomicChange<E>
-
- Type Parameters:
E
- The element type of the sourceObservableMultiset
.
- Enclosing class:
- MultisetListenerHelper<E>
public static class MultisetListenerHelper.AtomicChange<E> extends MultisetChangeListener.Change<E>
A simple implementation of anMultisetChangeListener.Change
.
-
-
Constructor Summary
Constructors Constructor Description AtomicChange(ObservableMultiset<E> source, Multiset<E> previousContents, java.util.List<MultisetListenerHelper.ElementarySubChange<E>> elementarySubChanges)
Creates a newMultisetListenerHelper.AtomicChange
that represents a change comprising multiple elementary sub-changesO.AtomicChange(ObservableMultiset<E> source, Multiset<E> previousContents, MultisetListenerHelper.ElementarySubChange<E> elementarySubChange)
Creates a newMultisetListenerHelper.AtomicChange
that represents a change comprising a single elementary sub-change.AtomicChange(ObservableMultiset<E> source, MultisetChangeListener.Change<? extends E> 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 int
getAddCount()
Returns how often an element has been added in the current elementary sub-change, if one has been added.E
getElement()
Retrieves the element that was altered in the current elementary sub-change.Multiset<E>
getPreviousContents()
Returns an unmodifiableMultiset
that contains the previous contents of the sourceObservableMultiset
before the atomic change was applied.int
getRemoveCount()
Returns how often an element has been removed in the current elementary sub-change, if one has been removed.boolean
next()
Places the internal cursor on the next elementary sub-change, so that it be processed usingMultisetChangeListener.Change.getElement()
,MultisetChangeListener.Change.getAddCount()
, andMultisetChangeListener.Change.getRemoveCount()
.void
reset()
Reset the internal cursor to the initial state, so that the first elementary sub-change can be accessed by callingMultisetChangeListener.Change.next()
.java.lang.String
toString()
-
Methods inherited from class org.eclipse.gef.common.collections.MultisetChangeListener.Change
getMultiset
-
-
-
-
Constructor Detail
-
AtomicChange
public AtomicChange(ObservableMultiset<E> source, Multiset<E> previousContents, MultisetListenerHelper.ElementarySubChange<E> elementarySubChange)
Creates a newMultisetListenerHelper.AtomicChange
that represents a change comprising a single elementary sub-change.- Parameters:
source
- The sourceObservableMultiset
from which the change originated.previousContents
- The previous contents of theObservableMultiset
before the change was applied.elementarySubChange
- The elementary sub-change that has been applied.
-
AtomicChange
public AtomicChange(ObservableMultiset<E> source, Multiset<E> previousContents, java.util.List<MultisetListenerHelper.ElementarySubChange<E>> 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(ObservableMultiset<E> source, MultisetChangeListener.Change<? extends E> 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
-
getAddCount
public int getAddCount()
Description copied from class:MultisetChangeListener.Change
Returns how often an element has been added in the current elementary sub-change, if one has been added.This method depends on the state of the internal cursor that can be manipulated via
MultisetChangeListener.Change.next()
andMultisetChangeListener.Change.reset()
.- Specified by:
getAddCount
in classMultisetChangeListener.Change<E>
- Returns:
- The number of occurrences that have been added.
-
getElement
public E getElement()
Description copied from class:MultisetChangeListener.Change
Retrieves the element that was altered in the current elementary sub-change.This method depends on the state of the internal cursor that can be manipulated via
MultisetChangeListener.Change.next()
andMultisetChangeListener.Change.reset()
.- Specified by:
getElement
in classMultisetChangeListener.Change<E>
- Returns:
- The added element in case an element was added.
-
getPreviousContents
public Multiset<E> getPreviousContents()
Description copied from class:MultisetChangeListener.Change
Returns an unmodifiableMultiset
that contains the previous contents of the sourceObservableMultiset
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 classMultisetChangeListener.Change<E>
- Returns:
- An unmodifiable
Multiset
representing the contents of theObservableMultiset
before the change.
-
getRemoveCount
public int getRemoveCount()
Description copied from class:MultisetChangeListener.Change
Returns how often an element has been removed in the current elementary sub-change, if one has been removed.This method depends on the state of the internal cursor that can be manipulated via
MultisetChangeListener.Change.next()
andMultisetChangeListener.Change.reset()
.- Specified by:
getRemoveCount
in classMultisetChangeListener.Change<E>
- Returns:
- The number of occurrences that have been removed.
-
next
public boolean next()
Description copied from class:MultisetChangeListener.Change
Places the internal cursor on the next elementary sub-change, so that it be processed usingMultisetChangeListener.Change.getElement()
,MultisetChangeListener.Change.getAddCount()
, andMultisetChangeListener.Change.getRemoveCount()
. 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 classMultisetChangeListener.Change<E>
- 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:MultisetChangeListener.Change
Reset the internal cursor to the initial state, so that the first elementary sub-change can be accessed by callingMultisetChangeListener.Change.next()
.- Specified by:
reset
in classMultisetChangeListener.Change<E>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-