Package org.nuiton.eugene
Class Transformer<I extends Model,O extends Model>
- java.lang.Object
-
- org.nuiton.eugene.Template<I>
-
- org.nuiton.eugene.Transformer<I,O>
-
- Type Parameters:
I
- input model to transformO
- output model transformed
- All Implemented Interfaces:
TemplateConfiguration
- Direct Known Subclasses:
ObjectModelTransformer
public abstract class Transformer<I extends Model,O extends Model> extends Template<I>
Transformer Created: 28 oct. 2009- Author:
- Florian Desbois - desbois@codelutin.com
-
-
Field Summary
Fields Modifier and Type Field Description protected O
outputModel
Output model.protected Properties
outputProperties
Properties for output generator.protected Template<O>
outputTemplate
Output generator, to generate files from Output model.protected Transformer<I,I>
previousTransformer
Previous transformer to modify input model-
Fields inherited from class org.nuiton.eugene.Template
configuration, excludeTemplates, generatedPackages, model, resourcesHelper
-
Fields inherited from interface org.nuiton.eugene.TemplateConfiguration
PROP_CLASS_LOADER, PROP_DEFAULT_PACKAGE, PROP_ENCODING, PROP_EXCLUDE_TEMPLATES, PROP_GENERATED_PACKAGES, PROP_LAST_MODIFIED_SOURCE, PROP_OVERWRITE, PROP_VERBOSE, PROP_WRITER_REPORT
-
-
Constructor Summary
Constructors Constructor Description Transformer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addOutputProperty(String key, Object value)
void
applyTemplate(I model, File destDir)
This method apply the current transformation.String
getDefaultPackageName()
O
getOutputModel()
protected Properties
getOutputProperties()
Deprecated.since 2.9, wille be removed in version 3.0, prefer use nowaddOutputProperty(String, Object)
Template<O>
getOutputTemplate()
protected void
init(I model)
Initialization of the Transformer :protected abstract O
initOutputModel()
Initialization of the Output model.protected abstract Template<O>
initOutputTemplate()
Initialization of the Output generator.protected Transformer<I,I>
initPreviousTransformer()
protected abstract void
transform()
Method to override for the transformation.void
transform(I model)
Transformation method from an input Model.-
Methods inherited from class org.nuiton.eugene.Template
getClassLoader, getConfiguration, getEncoding, getExcludeTemplates, getGeneratedPackages, getLastModifiedSource, getModel, getOverwrite, getProperties, getProperty, getProperty, getResourcesHelper, getWriterReport, isOverwrite, isVerbose, setConfiguration, setProperty
-
-
-
-
Field Detail
-
outputTemplate
protected Template<O extends Model> outputTemplate
Output generator, to generate files from Output model. Could be an other Transformer.
-
previousTransformer
protected Transformer<I extends Model,I extends Model> previousTransformer
Previous transformer to modify input model
-
outputProperties
protected Properties outputProperties
Properties for output generator.
-
-
Method Detail
-
init
protected void init(I model)
Initialization of the Transformer :- initOutputModel : default, do nothing - initOutputGenerator : must be override to instanciate output Generator - initOutputModel : must be override to instanciate output Model
- Parameters:
model
- input model- Since:
- 2.0.0
-
initPreviousTransformer
protected Transformer<I,I> initPreviousTransformer()
-
initOutputTemplate
protected abstract Template<O> initOutputTemplate()
Initialization of the Output generator. Must be override to instanciate the Generator that will make the generation of the Output model.- Returns:
- the output generator
- Since:
- 2.0.0
-
initOutputModel
protected abstract O initOutputModel()
Initialization of the Output model. Must be override to instanciate and initialize the output model. For ObjectModel you can use, ObjectModelBuilder to build easily an empty ObjectModel.- Returns:
- the output model
- Since:
- 2.0.0
-
getOutputProperties
@Deprecated protected Properties getOutputProperties()
Deprecated.since 2.9, wille be removed in version 3.0, prefer use nowaddOutputProperty(String, Object)
Output properties for output generator. Initially set from build configuration.- Returns:
- output properties
- Since:
- 2.0.0
-
getOutputModel
public O getOutputModel()
-
getDefaultPackageName
public String getDefaultPackageName()
-
applyTemplate
public void applyTemplate(I model, File destDir) throws IOException
This method apply the current transformation. You can use an other transformer for previous transformation by overridinginitPreviousTransformer()
method. In this case, the current transformation will be apply on the output model of the previous one. In the simple other case, the current transformation transform the input model into an output model. You must overrideinitOutputModel()
andinitOutputTemplate()
methods to initialize output model and output template to apply (generally a generator).- Specified by:
applyTemplate
in classTemplate<I extends Model>
- Parameters:
model
- input model to transform and generatedestDir
- destination directory to put generated files- Throws:
IOException
- if any IO problems while applying template- Since:
- 2.0.0
-
transform
public void transform(I model)
Transformation method from an input Model. This method also initialize previous transformer, output model and output generator with $init(Model)
method.- Parameters:
model
- input model- Since:
- 2.0.0
-
transform
protected abstract void transform()
Method to override for the transformation. Initialization (PreviousTransformer, OutputModel, OutputGenerator) is made before transformation call. This method only transform an input model into an output model. No generation is done neither outputGenerator call.- Since:
- 2.0.0
-
-