public class MultiStepCollectionTransformer<S,D> extends java.lang.Object implements CollectionTransformer<S,D>
This class is abstract since it doesn't know which type of collection
to use in the intermediary steps. Subclasses need to implement createTempCollection(CollectionTransformer)
that should create a new
collection in each step.
Modifier and Type | Field and Description |
---|---|
private java.util.List<CollectionTransformer<?,?>> |
steps |
Constructor and Description |
---|
MultiStepCollectionTransformer(java.util.List<CollectionTransformer<?,?>> steps) |
Modifier and Type | Method and Description |
---|---|
protected java.util.Collection<?> |
createTempCollection(CollectionTransformer<?,?> transformer)
Create a temporary collection that is suitable for holding an intermediary
result.
|
java.lang.String |
toString() |
int |
transform(java.util.Collection<? extends S> source,
java.util.Collection<? super D> destination)
Transform the source collection into the destination collection
by applying all intermediate transformers specified in the
constructor.
|
private final java.util.List<CollectionTransformer<?,?>> steps
public MultiStepCollectionTransformer(java.util.List<CollectionTransformer<?,?>> steps)
public int transform(java.util.Collection<? extends S> source, java.util.Collection<? super D> destination)
transform
in interface CollectionTransformer<S,D>
source
- The source collectiondestination
- The destination collectionprotected java.util.Collection<?> createTempCollection(CollectionTransformer<?,?> transformer)
CollectionTransformer.transform(Collection, Collection)
.
The default implementation always create HashSet
collections. If
a different type of collection is needed, a subclass that overrides this method
should be used.
NOTE! Each call to this method should create a new collection.
public java.lang.String toString()
toString
in class java.lang.Object