public class TransformedCollection extends AbstractSerializableCollectionDecorator
Collection
to transform objects that are added.
The add methods are affected by this class. Thus objects must be removed or searched for using their transformed form. For example, if the transformation converts Strings to Integers, you must use the Integer form to remove objects.
This class is Serializable from Commons Collections 3.1.
Modifier and Type | Field and Description |
---|---|
protected Transformer |
transformer
The transformer to use
|
collection
Modifier | Constructor and Description |
---|---|
protected |
TransformedCollection(Collection coll,
Transformer transformer)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(Object object) |
boolean |
addAll(Collection coll) |
static Collection |
decorate(Collection coll,
Transformer transformer)
Factory method to create a transforming collection.
|
protected Collection |
transform(Collection coll)
Transforms a collection.
|
protected Object |
transform(Object object)
Transforms an object.
|
protected final Transformer transformer
protected TransformedCollection(Collection coll, Transformer transformer)
If there are any elements already in the collection being decorated, they are NOT transformed.
coll
- the collection to decorate, must not be nulltransformer
- the transformer to use for conversion, must not be nullIllegalArgumentException
- if collection or transformer is nullpublic static Collection decorate(Collection coll, Transformer transformer)
If there are any elements already in the collection being decorated, they are NOT transformed.
coll
- the collection to decorate, must not be nulltransformer
- the transformer to use for conversion, must not be nullIllegalArgumentException
- if collection or transformer is nullprotected Object transform(Object object)
The transformer itself may throw an exception if necessary.
object
- the object to transformprotected Collection transform(Collection coll)
The transformer itself may throw an exception if necessary.
coll
- the collection to transformpublic boolean add(Object object)
add
in interface Collection
add
in class AbstractCollectionDecorator
public boolean addAll(Collection coll)
addAll
in interface Collection
addAll
in class AbstractCollectionDecorator
Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.