org.openstreetmap.josm.tools
Class SubclassFilteredCollection<S,T extends S>

java.lang.Object
  extended by java.util.AbstractCollection<T>
      extended by org.openstreetmap.josm.tools.SubclassFilteredCollection<S,T>
Type Parameters:
S - element type of the underlying collection
T - element type of filtered collection (and subclass of S). The predicate must accept only objects of type T.
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Collection<T>
Direct Known Subclasses:
FilteredCollection

public class SubclassFilteredCollection<S,T extends S>
extends java.util.AbstractCollection<T>

Filtered view of a collection. (read-only collection, but elements can be changed, of course) Lets you iterate through those elements of a given collection that satisfy a certain condition (imposed by a predicate).


Nested Class Summary
private  class SubclassFilteredCollection.FilterIterator
           
 
Field Summary
private  java.util.Collection<? extends S> collection
           
private  Predicate<? super S> predicate
           
(package private)  int size
           
 
Constructor Summary
SubclassFilteredCollection(java.util.Collection<? extends S> collection, Predicate<? super S> predicate)
           
 
Method Summary
 boolean isEmpty()
           
 java.util.Iterator<T> iterator()
           
 int size()
           
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

collection

private final java.util.Collection<? extends S> collection

predicate

private final Predicate<? super S> predicate

size

int size
Constructor Detail

SubclassFilteredCollection

public SubclassFilteredCollection(java.util.Collection<? extends S> collection,
                                  Predicate<? super S> predicate)
Method Detail

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T extends S>
Specified by:
iterator in interface java.util.Collection<T extends S>
Specified by:
iterator in class java.util.AbstractCollection<T extends S>

size

public int size()
Specified by:
size in interface java.util.Collection<T extends S>
Specified by:
size in class java.util.AbstractCollection<T extends S>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<T extends S>
Overrides:
isEmpty in class java.util.AbstractCollection<T extends S>


JOSM