I - Input super-typeP - Productpublic abstract class CompositeClassBasedTransformer<I,P> extends Object implements InputClassBasedTransformer<I,I,P>, AggregateTransformer<I,P>
InputClassBasedTransformer.
The transformation process is driven by Class of input. The selection
of used InputClassBasedTransformer is done by using the Class
of input as a key to select the transformer.
This approach provides quick resolution of transformer, but does not support
registering a super type of input to provide transformation support for all
subclasses, one must register a new instance of transformer for each valid
input class.
If you need more flexible selection of transformation consider using
CompositeConditionalTransformer which is slower but most flexible or
RuleBasedTransformer which provides declarative approach for
transformation.
See transform(Object) for more information about tranformation
process.| Constructor and Description |
|---|
CompositeClassBasedTransformer() |
| Modifier and Type | Method and Description |
|---|---|
void |
addTransformer(InputClassBasedTransformer<I,? extends I,P> transformer)
Registers a new transformer.
|
void |
removeTransformer(InputClassBasedTransformer<I,? extends I,P> transformer)
Removes an registered transformer.
|
P |
transform(I input)
Transforms an input into instance of Product class.
|
Collection<P> |
transformAll(Collection<? extends I> inputs) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInputClasspublic P transform(I input)
input.getClass() == transformer.getInputClass()
This means that transformers are not resolved by class hierarchy, only
selected based on final class of the input. If you need more flexible
selection of transformation consider using
CompositeConditionalTransformer which is slower but more
flexible.transform in interface Transformer<I,P>input - Input which drives transformationpublic void addTransformer(InputClassBasedTransformer<I,? extends I,P> transformer) throws IllegalStateException
InputClassBasedTransformer.getInputClass(). Only one transformer
can be registered for particular input class.IllegalStateExceptionpublic void removeTransformer(InputClassBasedTransformer<I,? extends I,P> transformer) throws IllegalArgumentException
transformer - Tranformer to be removed.IllegalArgumentException - If the provided transformer is null or is not registered.public Collection<P> transformAll(Collection<? extends I> inputs)
transformAll in interface AggregateTransformer<I,P>Copyright © 2015. All Rights Reserved.