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 AbstractCollection<T>
Modifier and Type | Class and Description |
---|---|
private class |
SubclassFilteredCollection.FilterIterator |
Modifier and Type | Field and Description |
---|---|
private Collection<? extends S> |
collection |
private Predicate<? super S> |
predicate |
private int |
size |
Constructor and Description |
---|
SubclassFilteredCollection(Collection<? extends S> collection,
Predicate<? super S> predicate)
Constructs a new
SubclassFilteredCollection . |
Modifier and Type | Method and Description |
---|---|
boolean |
isEmpty() |
Iterator<T> |
iterator() |
int |
size() |
add, addAll, clear, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode, parallelStream, removeIf, spliterator, stream
private final Collection<? extends S> collection
private int size
public SubclassFilteredCollection(Collection<? extends S> collection, Predicate<? super S> predicate)
SubclassFilteredCollection
.collection
- The base collection to filterpredicate
- The predicate to use as filterpublic int size()
size
in interface Collection<T extends S>
size
in class AbstractCollection<T extends S>
public boolean isEmpty()
isEmpty
in interface Collection<T extends S>
isEmpty
in class AbstractCollection<T extends S>