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 |
|---|---|
| private static final long | serialVersionUID
Hides org. |
| protected final Transformer | transformer
The transformer to use |
| Access | Constructor and Description |
|---|---|
| protected | TransformedCollection(final Collection<E>
the collection to decorate, must not be null coll, final Transformer<? super E, ? extends E> the transformer to use for conversion, must not be null transformer)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(final E
element whose presence in this collection is to be ensured object)Overrides org. Implements java. |
| public boolean | addAll(final Collection<? extends E>
collection containing elements to be added to this collection coll)Overrides org. Implements java. |
| protected E | |
| protected Collection | Returns: a transformed objectthe collection to transform coll)Transforms a collection. |
| public static < the type of the elements in the collection E> TransformedCollection | Returns: a new transformed Collectionthe collection to decorate, must not be null collection, final Transformer<? super E, ? extends E> the transformer to use for conversion, must not be null transformer)Factory method to create a transforming collection that will transform existing contents of the specified collection. |
| public static < the type of the elements in the collection E> TransformedCollection | Returns: a new transformed collectionthe collection to decorate, must not be null coll, final Transformer<? super E, ? extends E> the transformer to use for conversion, must not be null transformer)Factory method to create a transforming collection. |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| transformer | back to summary |
|---|---|
| protected final Transformer<? super E, ? extends E> transformer The transformer to use | |
| TransformedCollection | back to summary |
|---|---|
| protected TransformedCollection(final Collection<E> coll, final Transformer<? super E, ? extends E> transformer) Constructor that wraps (not copies). If there are any elements already in the collection being decorated, they are NOT transformed.
| |
| add | back to summary |
|---|---|
| public boolean add(final E object) Overrides org. Implements java. Doc from java. Ensures that this collection contains the specified element (optional
operation). Returns
Collections that support this operation may place limitations on what
elements may be added to this collection. In particular, some
collections will refuse to add
If a collection refuses to add a particular element for any reason
other than that it already contains the element, it must throw
an exception (rather than returning
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(final Collection<? extends E> coll) Overrides org. Implements java. Doc from java. Adds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.) If the specified collection has a defined encounter order, processing of its elements generally occurs in that order.
| |
| transform | back to summary |
|---|---|
| protected E transform(final E object) Transforms an object. The transformer itself may throw an exception if necessary.
| |
| transform | back to summary |
|---|---|
| protected Collection Transforms a collection. The transformer itself may throw an exception if necessary.
| |
| transformedCollection | back to summary |
|---|---|
| public static <E> TransformedCollection Factory method to create a transforming collection that will transform existing contents of the specified collection.
If there are any elements already in the collection being decorated, they
will be transformed by this method.
Contrast this with
| |
| transformingCollection | back to summary |
|---|---|
| public static <E> TransformedCollection Factory method to create a transforming collection.
If there are any elements already in the collection being decorated, they
are NOT transformed.
Contrast this with
| |