Class TransformationList<E,F>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
javafx.collections.ObservableListBase<E>
javafx.collections.transformation.TransformationList<E,F>
- Type Parameters:
E- the type parameter of this listF- the upper bound of the type of the source list
- All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>, Observable, ObservableList<E>
- Direct Known Subclasses:
FilteredList, SortedList
A base class for all lists that wrap another list in a way that changes
(transforms) the wrapped list's elements, order, size, or structure.
If the source list is observable, a listener is automatically added to it
and the events are delegated to
sourceChanged(javafx.collections.ListChangeListener.Change).- Since:
- JavaFX 8.0
-
Field Summary
Fields declared in class AbstractList
modCount -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTransformationList(ObservableList<? extends F> source) Creates a new Transformation list wrapped around the source list. -
Method Summary
Modifier and TypeMethodDescriptionfinal ObservableList<? extends F> The source list specified in the constructor of this transformation list.abstract intgetSourceIndex(int index) Maps the index of this list's element to an index in the direct source list.final intgetSourceIndexFor(ObservableList<?> list, int index) Maps the index of this list's element to an index of the providedlist.abstract intgetViewIndex(int index) Maps the index of the direct source list's element to an index in this list.final booleanisInTransformationChain(ObservableList<?> list) Checks whether the provided list is in the chain under thisTransformationList.protected abstract voidsourceChanged(ListChangeListener.Change<? extends F> c) Called when a change from the source is triggered.Methods declared in class ObservableListBase
addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, removeListener, retainAll, setAll, setAllModifier and TypeMethodDescriptionbooleanA convenience method for var-arg addition of elements.final voidaddListener(InvalidationListener listener) Adds anInvalidationListenerwhich will be notified whenever theObservablebecomes invalid.final voidaddListener(ListChangeListener<? super E> listener) Add a listener to this observable list.protected final voidBegins a change block.protected final voidEnds the change block.protected final voidfireChange(ListChangeListener.Change<? extends E> change) Notifies all listeners of a changeprotected final booleanReturns true if there are some listeners registered for this list.protected final voidnextAdd(int from, int to) Adds a new add operation to the change.protected final voidnextPermutation(int from, int to, int[] perm) Adds a new permutation operation to the change.protected final voidnextRemove(int idx, E removed) Adds a new remove operation to the change with single item removed.protected final voidnextRemove(int idx, List<? extends E> removed) Adds a new remove operation to the change with multiple items removed.protected final voidnextReplace(int from, int to, List<? extends E> removed) Adds a new replace operation to the change.protected final voidAdds a new set operation to the change.protected final voidnextUpdate(int pos) Adds a new update operation to the change.voidremove(int from, int to) A simplified way of callingsublist(from, to).clear().booleanA convenience method for var-arg usage of theremoveAllmethod.final voidremoveListener(InvalidationListener listener) Removes the given listener from the list of listeners, that are notified whenever the value of theObservablebecomes invalid.final voidremoveListener(ListChangeListener<? super E> listener) Tries to remove a listener from this observable list.booleanA convenience method for var-arg usage of theretainAllmethod.booleanClears the ObservableList and adds all the elements passed as var-args.booleansetAll(Collection<? extends E> col) Clears the ObservableList and adds all elements from the collection.Methods declared in class AbstractList
add, add, addAll, clear, equals, get, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods declared in class AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, size, toArray, toArray, toStringMethods declared in interface Collection
parallelStream, removeIf, stream, toArrayMethods declared in interface List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, isEmpty, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, size, sort, spliterator, toArray, toArrayMethods declared in interface Observable
subscribeModifier and TypeMethodDescriptiondefault SubscriptionCreates aSubscriptionon thisObservablewhich callsinvalidationSubscriberwhenever it becomes invalid.Methods declared in interface ObservableList
filtered, replaceRange, sorted, sortedModifier and TypeMethodDescriptiondefault FilteredList<E> Creates aFilteredListwrapper of this list using the specified predicate.default booleanreplaceRange(int from, int to, Collection<? extends E> col) Replaces the elements in the range[from, to)with the elements from the given collection.default SortedList<E> sorted()Creates aSortedListwrapper of this list with the natural ordering.default SortedList<E> sorted(Comparator<E> comparator) Creates aSortedListwrapper of this list using the specified comparator.
-
Constructor Details
-
TransformationList
Creates a new Transformation list wrapped around the source list.- Parameters:
source- the wrapped list
-
-
Method Details
-
getSource
The source list specified in the constructor of this transformation list.- Returns:
- The List that is directly wrapped by this TransformationList
-
isInTransformationChain
Checks whether the provided list is in the chain under thisTransformationList. This means the list is either the direct source as returned bygetSource()or the direct source is aTransformationList, and the list is in it's transformation chain.- Parameters:
list- the list to check- Returns:
- true if the list is in the transformation chain as specified above.
-
sourceChanged
Called when a change from the source is triggered.- Parameters:
c- the change
-
getSourceIndex
public abstract int getSourceIndex(int index) Maps the index of this list's element to an index in the direct source list.- Parameters:
index- the index in this list- Returns:
- the index of the element's origin in the source list
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= size())- See Also:
-
getSourceIndexFor
Maps the index of this list's element to an index of the providedlist. Thelistmust be in the transformation chain.- Parameters:
list- a list from the transformation chainindex- the index of an element in this list- Returns:
- the index of the element's origin in the provided list
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= size())- See Also:
-
getViewIndex
public abstract int getViewIndex(int index) Maps the index of the direct source list's element to an index in this list.- Parameters:
index- the index in the source list- Returns:
- the index of the element in this list if it is contained in this list or negative value otherwise
- Throws:
IndexOutOfBoundsException- if the index is out of range (index < 0 || index >= getSource().size())- Since:
- 9
- See Also:
-