Original
- the type of the original elements in the collectionTransformed
- the type of the tranformed elementspublic class Transform<Original,Transformed> extends AbstractCollection<Transformed>
If the transformer returns null for a given original object, then that object will not be included in the transform. Thus the transform might be smaller than the original collection. Note that Transform instances can never contain the null element.
This collection implementation does not support the optional add operation.
Constructor and Description |
---|
Transform(Collection<? extends Original> delegate,
Transformer<Original,Transformed> transformer)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Iterator<Transformed> |
iterator() |
int |
size() |
static <Target> Collection<Target> |
subclasses(Collection<? extends Object> c,
Class<Target> cls)
Returns a transform containing only objects of a given class.
|
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode
public Transform(Collection<? extends Original> delegate, Transformer<Original,Transformed> transformer)
delegate
- The collection whose elements to transform.transformer
- Transforms the elementspublic int size()
size
in interface Collection<Transformed>
size
in class AbstractCollection<Transformed>
public Iterator<Transformed> iterator()
iterator
in interface Iterable<Transformed>
iterator
in interface Collection<Transformed>
iterator
in class AbstractCollection<Transformed>
public static <Target> Collection<Target> subclasses(Collection<? extends Object> c, Class<Target> cls)
Target
- the target classc
- the collection to transformcls
- the class of objects to returnCopyright © 2003-2014 Internet Archive. All Rights Reserved.