Top Description Fields Constructors Methods
com.sun.javafx.scene.control

public Class MultipleAdditionAndRemovedChange<E>

extends ListChangeListener.Change<E>
Class Inheritance
Type Parameters
<E>
The element contained in the underlying list data structure
Imports
javafx.collections.ListChangeListener, .ObservableList, java.util.Collections, .List

Often times there are multiple additions that are applied to a list, but they are not contiguous. This class abstracts away the details and creates the right number of next() iterations to correctly report all changes.

Field Summary

Modifier and TypeField and Description
private final List<E>
private int
private static final int[]
private int
private boolean
private boolean
private final List<E>
private boolean
private int

Constructor Summary

AccessConstructor and Description
public
MultipleAdditionAndRemovedChange(List<E> addedElements, List<E> removedElements, ObservableList<E> list)

Method Summary

Modifier and TypeMethod and Description
private void
public int
getFrom()

Implements abstract javafx.collections.ListChangeListener.Change.getFrom.

If wasAdded() is true, the interval contains all the values that were added.

protected int[]
getPermutation()

Implements abstract javafx.collections.ListChangeListener.Change.getPermutation.

If this change is a permutation, it returns an integer array that describes the permutation.

public List<E>
getRemoved()

Implements abstract javafx.collections.ListChangeListener.Change.getRemoved.

An immutable list of removed/replaced elements.

public int
getTo()

Implements abstract javafx.collections.ListChangeListener.Change.getTo.

The end of the change interval.

public boolean
next()

Implements abstract javafx.collections.ListChangeListener.Change.next.

Goes to the next change.

public void
reset()

Implements abstract javafx.collections.ListChangeListener.Change.reset.

Resets to the initial stage.

public boolean
wasAdded()

Overrides javafx.collections.ListChangeListener.Change.wasAdded.

Indicates if elements were added during this change.

public boolean
wasRemoved()

Overrides javafx.collections.ListChangeListener.Change.wasRemoved.

Indicates if elements were removed during this change.

Inherited from javafx.collections.ListChangeListener.Change:
getAddedSizegetAddedSubListgetListgetPermutationgetRemovedSizewasPermutatedwasReplacedwasUpdated

Field Detail

addedElementsback to summary
private final List<E> addedElements
addedIndexback to summary
private int addedIndex
EMPTY_PERMback to summary
private static final int[] EMPTY_PERM
fromback to summary
private int from
invalidback to summary
private boolean invalid
iteratingThroughAddedback to summary
private boolean iteratingThroughAdded
removedElementsback to summary
private final List<E> removedElements
returnedRemovedElementsback to summary
private boolean returnedRemovedElements
toback to summary
private int to

Constructor Detail

MultipleAdditionAndRemovedChangeback to summary
public MultipleAdditionAndRemovedChange(List<E> addedElements, List<E> removedElements, ObservableList<E> list)

Method Detail

checkStateback to summary
private void checkState()
getFromback to summary
public int getFrom()

Implements abstract javafx.collections.ListChangeListener.Change.getFrom.

Doc from javafx.collections.ListChangeListener.Change.getFrom.

If wasAdded() is true, the interval contains all the values that were added. If wasPermutated() is true, the interval marks the values that were permutated. If wasRemoved() is true and wasAdded is false, getFrom() and getTo() should return the same number - the place where the removed elements were positioned in the list.

Returns:int

a beginning (inclusive) of an interval related to the change

Annotations
@Override
getPermutationback to summary
protected int[] getPermutation()

Implements abstract javafx.collections.ListChangeListener.Change.getPermutation.

Doc from javafx.collections.ListChangeListener.Change.getPermutation.

If this change is a permutation, it returns an integer array that describes the permutation. This array maps directly from the previous indexes to the new ones. This method is not publicly accessible and therefore can return an array safely. The 0 index of the array corresponds to index getFrom() of the list. The same applies for the last index and getTo(). The method is used by wasPermutated() and getPermutation(int) methods.

Returns:int[]

empty array if this is not permutation or an integer array containing the permutation

Annotations
@Override
getRemovedback to summary
public List<E> getRemoved()

Implements abstract javafx.collections.ListChangeListener.Change.getRemoved.

Doc from javafx.collections.ListChangeListener.Change.getRemoved.

An immutable list of removed/replaced elements. If no elements were removed from the list, an empty list is returned.

Returns:List<E>

a list with all the removed elements

Annotations
@Override
getToback to summary
public int getTo()

Implements abstract javafx.collections.ListChangeListener.Change.getTo.

Doc from javafx.collections.ListChangeListener.Change.getTo.

The end of the change interval.

Returns:int

an end (exclusive) of an interval related to the change

Annotations
@Override
nextback to summary
public boolean next()

Implements abstract javafx.collections.ListChangeListener.Change.next.

Doc from javafx.collections.ListChangeListener.Change.next.

Goes to the next change. The Change instance, in its initial state, is invalid and requires a call to next() before calling other methods. The first next() call will make this object represent the first change.

Returns:boolean

true if switched to the next change, false if this is the last change

Annotations
@Override
resetback to summary
public void reset()

Implements abstract javafx.collections.ListChangeListener.Change.reset.

Doc from javafx.collections.ListChangeListener.Change.reset.

Resets to the initial stage. After this call, next() must be called before working with the first change.

Annotations
@Override
wasAddedback to summary
public boolean wasAdded()

Overrides javafx.collections.ListChangeListener.Change.wasAdded.

Doc from javafx.collections.ListChangeListener.Change.wasAdded.

Indicates if elements were added during this change.

Returns:boolean

true if something was added to the list

Annotations
@Override
wasRemovedback to summary
public boolean wasRemoved()

Overrides javafx.collections.ListChangeListener.Change.wasRemoved.

Doc from javafx.collections.ListChangeListener.Change.wasRemoved.

Indicates if elements were removed during this change. Note that using set will also produce a change with wasRemoved() returning true. See wasReplaced().

Returns:boolean

true if something was removed from the list

Annotations
@Override