S - element type of the underlying collectionT - element type of filtered collection (and subclass of S). The predicate
must accept only objects of type T.public class SubclassFilteredCollection<S,T extends S> extends java.util.AbstractCollection<T>
The behaviour of this class is undefined if the underlying collection is changed.
| Modifier and Type | Class and Description |
|---|---|
private class |
SubclassFilteredCollection.FilterIterator |
| Modifier and Type | Field and Description |
|---|---|
private java.util.Collection<? extends S> |
collection |
private java.util.function.Predicate<? super S> |
predicate |
private int |
size |
| Constructor and Description |
|---|
SubclassFilteredCollection(java.util.Collection<? extends S> collection,
java.util.function.Predicate<? super S> predicate)
Constructs a new
SubclassFilteredCollection. |
| Modifier and Type | Method and Description |
|---|---|
static <T> SubclassFilteredCollection<T,T> |
filter(java.util.Collection<? extends T> collection,
java.util.function.Predicate<T> predicate)
Create a new filtered collection without any constraints on the predicate type.
|
boolean |
isEmpty() |
java.util.Iterator<T> |
iterator() |
int |
size() |
add, addAll, clear, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitprivate final java.util.Collection<? extends S> collection
private int size
public SubclassFilteredCollection(java.util.Collection<? extends S> collection, java.util.function.Predicate<? super S> predicate)
SubclassFilteredCollection.collection - The base collection to filterpredicate - The predicate to use as filterfor an alternative way to construct this.public int size()
public boolean isEmpty()
public static <T> SubclassFilteredCollection<T,T> filter(java.util.Collection<? extends T> collection, java.util.function.Predicate<T> predicate)
T - The collection type.collection - The collection to filter.predicate - The predicate to filter for.Collection<T>.