org.eclipse.gef.common.collections

## 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 source `ObservableMultiset`.

Enclosing class:
  MultisetListenerHelper<E>

    public static class MultisetListenerHelper.AtomicChange<E>
    extends MultisetChangeListener.Change<E>

A simple implementation of an `MultisetChangeListener.Change`.

### Constructor Summary

Constructors
Constructor and Description
`AtomicChange(ObservableMultiset<E> source, com.google.common.collect.Multiset<E> previousContents, java.util.List<MultisetListenerHelper.ElementarySubChange<E>> elementarySubChanges)` Creates a new `MultisetListenerHelper.AtomicChange` that represents a change comprising multiple elementary sub-changesO.
`AtomicChange(ObservableMultiset<E> source, com.google.common.collect.Multiset<E> previousContents, MultisetListenerHelper.ElementarySubChange<E> elementarySubChange)` Creates a new `MultisetListenerHelper.AtomicChange` that represents a change comprising a single elementary sub-change.
`AtomicChange(ObservableMultiset<E> source, MultisetChangeListener.Change<? extends E> change)` Creates a new `MultisetListenerHelper.AtomicChange` for the passed in source, based on the data provided in the passed-in change.

### Method Summary

All Methods Instance Methods Concrete Methods
`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.
`com.google.common.collect.Multiset<E>` `getPreviousContents()` Returns an unmodifiable `Multiset` that contains the previous contents of the source `ObservableMultiset` 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 using `MultisetChangeListener.Change.getElement()`, `MultisetChangeListener.Change.getAddCount()`, and `MultisetChangeListener.Change.getRemoveCount()`.
`void` `reset()` Reset the internal cursor to the initial state, so that the first elementary sub-change can be accessed by calling `MultisetChangeListener.Change.next()`.
`java.lang.String` `toString()`

### Methods inherited from class org.eclipse.gef.common.collections.MultisetChangeListener.Change

`getMultiset`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### AtomicChange

    public AtomicChange(ObservableMultiset<E> source,
                        com.google.common.collect.Multiset<E> previousContents,
                        MultisetListenerHelper.ElementarySubChange<E> elementarySubChange)

Creates a new `MultisetListenerHelper.AtomicChange` that represents a change comprising a single elementary sub-change.

Parameters:
  `source` - The source `ObservableMultiset` from which the change originated.
  `previousContents` - The previous contents of the `ObservableMultiset` before the change was applied.
  `elementarySubChange` - The elementary sub-change that has been applied.

#### AtomicChange

    public AtomicChange(ObservableMultiset<E> source,
                        com.google.common.collect.Multiset<E> previousContents,
                        java.util.List<MultisetListenerHelper.ElementarySubChange<E>> elementarySubChanges)

Creates a new `MultisetListenerHelper.AtomicChange` that represents a change comprising multiple elementary sub-changesO.

Parameters:
  `source` - The source `ObservableMultiset` from which the change originated.
  `previousContents` - The previous contents of the `ObservableMultiset` 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 new `MultisetListenerHelper.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 wrapped `ObservableMultiset` with themselves as source.

Parameters:
  `source` - The new source `ObservableMultiset`.
  `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()` and `MultisetChangeListener.Change.reset()`.

Specified by:
  `getAddCount` in class `MultisetChangeListener.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()` and `MultisetChangeListener.Change.reset()`.

Specified by:
  `getElement` in class `MultisetChangeListener.Change<E>`
Returns:
  The added element in case an element was added.

#### getPreviousContents

    public com.google.common.collect.Multiset<E> getPreviousContents()

Description copied from class: `MultisetChangeListener.Change`
Returns an unmodifiable `Multiset` that contains the previous contents of the source `ObservableMultiset` 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 class `MultisetChangeListener.Change<E>`
Returns:
  An unmodifiable `Multiset` representing the contents of the `ObservableMultiset` 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()` and `MultisetChangeListener.Change.reset()`.

Specified by:
  `getRemoveCount` in class `MultisetChangeListener.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 using `MultisetChangeListener.Change.getElement()`, `MultisetChangeListener.Change.getAddCount()`, and `MultisetChangeListener.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 class `MultisetChangeListener.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 calling `MultisetChangeListener.Change.next()`.

Specified by:
  `reset` in class `MultisetChangeListener.Change<E>`

#### toString

    public java.lang.String toString()

Overrides:
  `toString` in class `java.lang.Object`