- 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>
public final class FilteredList<E> extends TransformationList<E,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:
TransformationList
-
-
Property Summary
Properties Type Property Description ObjectProperty<Predicate<? super E>>
predicate
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
Constructors Constructor Description FilteredList(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description E
get(int index)
Returns the element at the specified position in this list.Predicate<? super E>
getPredicate()
Gets the value of the property predicate.ObjectProperty<Predicate<? super E>>
predicateProperty()
The predicate that will match the elements that will be in this FilteredList.void
setPredicate(Predicate<? super E> predicate)
Sets the value of the property predicate.int
size()
Returns the number of elements in this list.-
Methods declared in class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods declared in class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods declared in interface java.util.Collection
parallelStream, removeIf, stream
-
Methods 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, toArray
-
Methods declared in class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods declared in interface javafx.beans.Observable
addListener, removeListener
-
Methods declared in interface javafx.collections.ObservableList
addAll, addListener, filtered, remove, removeAll, removeListener, retainAll, setAll, setAll, sorted, sorted
-
Methods declared in class javafx.collections.ObservableListBase
beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate
-
Methods declared in class javafx.collections.transformation.TransformationList
getSource, getSourceIndex, getSourceIndexFor, getViewIndex, isInTransformationChain, sourceChanged
-
-
-
-
Property Detail
-
predicate
public final ObjectProperty<Predicate<? super E>> 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.- See Also:
getPredicate()
,setPredicate(Predicate)
-
-
Constructor Detail
-
FilteredList
public FilteredList(ObservableList<E> source, Predicate<? super E> predicate)
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
public FilteredList(ObservableList<E> source)
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 Detail
-
predicateProperty
public final ObjectProperty<Predicate<? super E>> 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.- See Also:
getPredicate()
,setPredicate(Predicate)
-
getPredicate
public final Predicate<? super E> getPredicate()
Gets the value of the property predicate.- 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.
-
setPredicate
public final void setPredicate(Predicate<? super E> predicate)
Sets the value of the property predicate.- 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.
-
size
public int size()
Returns the number of elements in this list.- Returns:
- the number of elements in this list
-
get
public E get(int index)
Returns the element at the specified position in this list.- Specified by:
get
in interfaceList<E>
- Specified by:
get
in classAbstractList<E>
- Parameters:
index
- index of the element to return- Returns:
- the element at the specified position in this list
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
)
-
-