E
- The element type of the ObservableMultiset
.public abstract static class MultisetChangeListener.Change<E>
extends java.lang.Object
ObservableMultiset
, i.e. a
change resulting from a single method invocation on an
ObservableMultiset
.
The change may internally consist of several elementary sub-changes,
which are related to changes of a single element. That is, a call to
Multiset.add(Object)
or
Multiset.setCount(Object, int)
will lead to an atomic
change that comprises only a single elementary sub-change, while a call
to Collection.clear()
will potentially lead to several
elementary sub-changes (one for each element contained in the Multiset).
The comprised elementary sub-changes need to be navigated using
next()
, the relevant information can then be retrieved via
getElement()
, getAddCount()
, and
getRemoveCount()
(for the current elementary sub-change the
internal cursor currently points at). Initially, the internal cursor is
set to point before the first elementary sub-change, so that an initial
call to next()
is required to access the first elementary
sub-change, while reset()
can be used to reset the cursor to
this initial state before the first elementary sub-change.
The getMultiset()
returns the source ObservableMultiset
that was changed (in the state after the atomic change was applied). The
previous contents of the source ObservableMultiset
(in the state
before the atomic change was applied) can be obtained via
getPreviousContents()
. Both are independent of the state of the
internal cursor and may be accessed at any time.
Constructor and Description |
---|
Change(ObservableMultiset<E> source)
Creates a new (atomic) change associated with the given source
ObservableMultiset . |
Modifier and Type | Method and Description |
---|---|
abstract int |
getAddCount()
Returns how often an element has been added in the current elementary
sub-change, if one has been added.
|
abstract E |
getElement()
Retrieves the element that was altered in the current elementary
sub-change.
|
ObservableMultiset<E> |
getMultiset()
The source
ObservableMultiset this atomic change is
associated with. |
abstract Multiset<E> |
getPreviousContents()
Returns an unmodifiable
Multiset that contains the previous
contents of the source ObservableMultiset before the atomic
change was applied. |
abstract int |
getRemoveCount()
Returns how often an element has been removed in the current
elementary sub-change, if one has been removed.
|
abstract boolean |
next()
Places the internal cursor on the next elementary sub-change, so that
it be processed using
getElement() , getAddCount() ,
and getRemoveCount() . |
abstract void |
reset()
Reset the internal cursor to the initial state, so that the first
elementary sub-change can be accessed by calling
next() . |
public Change(ObservableMultiset<E> source)
ObservableMultiset
.source
- The source of the change.public abstract boolean next()
getElement()
, getAddCount()
,
and getRemoveCount()
. This method has to be called initially
to have the internal cursor point to the first elementary sub-change
that is comprised.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.public abstract void reset()
next()
.public ObservableMultiset<E> getMultiset()
ObservableMultiset
this atomic change is
associated with.
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.
ObservableMultiset
.public abstract Multiset<E> getPreviousContents()
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.
Multiset
representing the contents of
the ObservableMultiset
before the change.public abstract int getAddCount()
This method depends on the state of the internal cursor that can be
manipulated via next()
and reset()
.
public abstract int getRemoveCount()
This method depends on the state of the internal cursor that can be
manipulated via next()
and reset()
.
Copyright (c) 2014 itemis AG and others. All rights reserved.