Package net.sf.basedb.util.collections
Class MultiStepCollectionTransformer<S,D>
java.lang.Object
net.sf.basedb.util.collections.MultiStepCollectionTransformer<S,D>
- All Implemented Interfaces:
CollectionTransformer<S,
D>
public class MultiStepCollectionTransformer<S,D>
extends Object
implements CollectionTransformer<S,D>
Collection transformer implementation that transforms a source
collection into the destination collection using multiple steps.
Each transformation step is delegated to a transformer that
is specified in the constructor. Source and destination collection
types must match between each step. Eg. the destination collection
from the first step is used as the source collection in the second
step, the destination from the second step is used as source in
the third step, and so on.
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.
- Version:
- 2.10
- Author:
- Nicklas
- Last modified
- $Date: 2015-04-20 11:08:18 +0200 (må, 20 apr 2015) $
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Collection<?>
createTempCollection
(CollectionTransformer<?, ?> transformer) Create a temporary collection that is suitable for holding an intermediary result.toString()
int
transform
(Collection<? extends S> source, Collection<? super D> destination) Transform the source collection into the destination collection by applying all intermediate transformers specified in the constructor.
-
Field Details
-
steps
-
-
Constructor Details
-
MultiStepCollectionTransformer
-
-
Method Details
-
transform
Transform the source collection into the destination collection by applying all intermediate transformers specified in the constructor.- Specified by:
transform
in interfaceCollectionTransformer<S,
D> - Parameters:
source
- The source collectiondestination
- The destination collection- Returns:
- The result of the last transformation step
-
createTempCollection
Create a temporary collection that is suitable for holding an intermediary result. The returned collection will be used as the destination collection when callingCollectionTransformer.transform(Collection, Collection)
. The default implementation always createHashSet
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.
-
toString
-