java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
javafx.collections.ObservableListBase<E>
javafx.collections.transformation.TransformationList<E,E>
javafx.collections.transformation.FilteredList<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>,Observable,ObservableList<E>
Wraps an ObservableList and filters its content using the provided Predicate.
All changes in the ObservableList are propagated immediately
to the FilteredList.
- Since:
- JavaFX 8.0
- See Also:
-
Property Summary
PropertiesTypePropertyDescriptionfinal ObjectProperty<Predicate<? super E>>The predicate that will match the elements that will be in this FilteredList. -
Field Summary
Fields declared in class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionFilteredList(ObservableList<E> source) Constructs a new FilteredList wrapper around the source list.FilteredList(ObservableList<E> source, Predicate<? super E> predicate) Constructs a new FilteredList wrapper around the source list. -
Method Summary
Modifier and TypeMethodDescriptionget(int index) Returns the element at the specified position in this list.Gets the value of thepredicateproperty.intgetSourceIndex(int index) Maps the index of this list's element to an index in the direct source list.intgetViewIndex(int index) Maps the index of the direct source list's element to an index in this list.final ObjectProperty<Predicate<? super E>>The predicate that will match the elements that will be in this FilteredList.final voidsetPredicate(Predicate<? super E> predicate) Sets the value of thepredicateproperty.intsize()Returns the number of elements in this list.protected voidsourceChanged(ListChangeListener.Change<? extends E> c) Called when a change from the source is triggered.Methods declared in class javafx.collections.transformation.TransformationList
getSource, getSourceIndexFor, isInTransformationChainMethods declared in class javafx.collections.ObservableListBase
addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, removeListener, retainAll, setAll, setAllMethods declared in class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods declared in class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods declared in class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods declared in interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods declared in interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray, toArrayMethods declared in interface javafx.beans.Observable
addListener, removeListenerMethods declared in interface javafx.collections.ObservableList
addAll, addListener, filtered, remove, removeAll, removeListener, retainAll, setAll, setAll, sorted, sorted
-
Property Details
-
predicate
The predicate that will match the elements that will be in this FilteredList. Elements not matching the predicate will be filtered-out. Null predicate means "always true" predicate, all elements will be matched.
-
-
Constructor Details
-
FilteredList
Constructs a new FilteredList wrapper around the source list. The provided predicate will match the elements in the source list that will be visible. If the predicate is null, all elements will be matched and the list is equal to the source list.- Parameters:
source- the source listpredicate- the predicate to match the elements or null to match all elements.
-
FilteredList
Constructs a new FilteredList wrapper around the source list. This list has an "always true" predicate, containing all the elements of the source list.This constructor might be useful if you want to bind
predicateProperty()of this list.- Parameters:
source- the source list
-
-
Method Details
-
predicateProperty
The predicate that will match the elements that will be in this FilteredList. Elements not matching the predicate will be filtered-out. Null predicate means "always true" predicate, all elements will be matched.- Returns:
- the
predicateproperty - See Also:
-
getPredicate
Gets the value of thepredicateproperty.- Property description:
- The predicate that will match the elements that will be in this FilteredList. Elements not matching the predicate will be filtered-out. Null predicate means "always true" predicate, all elements will be matched.
- Returns:
- the value of the
predicateproperty - See Also:
-
setPredicate
Sets the value of thepredicateproperty.- Property description:
- The predicate that will match the elements that will be in this FilteredList. Elements not matching the predicate will be filtered-out. Null predicate means "always true" predicate, all elements will be matched.
- Parameters:
predicate- the value for thepredicateproperty- See Also:
-
sourceChanged
Description copied from class:TransformationListCalled when a change from the source is triggered.- Specified by:
sourceChangedin classTransformationList<E,E> - Parameters:
c- the change
-
size
public int size()Returns the number of elements in this list.- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceList<E>- Specified by:
sizein classAbstractCollection<E>- Returns:
- the number of elements in this list
-
get
Returns the element at the specified position in this list.- Specified by:
getin interfaceList<E>- Specified by:
getin classAbstractList<E>- Parameters:
index- index of the element to return- Returns:
- the element at the specified position in this list
- Throws:
IndexOutOfBoundsException
-
getSourceIndex
public int getSourceIndex(int index) Description copied from class:TransformationListMaps the index of this list's element to an index in the direct source list.- Specified by:
getSourceIndexin classTransformationList<E,E> - Parameters:
index- the index in this list- Returns:
- the index of the element's origin in the source list
- See Also:
-
getViewIndex
public int getViewIndex(int index) Description copied from class:TransformationListMaps the index of the direct source list's element to an index in this list.- Specified by:
getViewIndexin classTransformationList<E,E> - 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
- See Also:
-