Package org.nuiton.eugene
Class AbstractMetaTransformer<M extends Model>
- java.lang.Object
-
- org.nuiton.eugene.Template<M>
-
- org.nuiton.eugene.AbstractGenerator<M>
-
- org.nuiton.eugene.AbstractMetaTransformer<M>
-
- Type Parameters:
M
- type of Model
- All Implemented Interfaces:
TemplateConfiguration
public abstract class AbstractMetaTransformer<M extends Model> extends AbstractGenerator<M>
Abstract meta transformer which contains some templates to apply to an incoming model. Using theTemplate.getExcludeTemplates()
to restrict use of some templates. Created: 20 déc. 2009- Since:
- 2.0.0
- Author:
- Tony Chemit - chemit@codelutin.com
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<? extends Template<M>>[]
templateTypes
Templates to apply to the model.protected Class<? extends Transformer<M,M>>[]
transformerTypes
Transformers to apply before using templates.-
Fields inherited from class org.nuiton.eugene.AbstractGenerator
parent
-
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 Modifier Constructor Description protected
AbstractMetaTransformer()
AbstractMetaTransformer(Class<? extends Template<M>>... templateTypes)
Deprecated.since 2.3, prefer use the default constructor, the invoke setterssetTemplateTypes(Class[])
andsetTransformerTypes(Class[])
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
applyTemplate(M model, File destDir)
protected void
applyTemplates(M model, List<? extends Template<M>> templates, File destDir)
Generates to the givendestination directory
using the given templates on the incoming givenmodel
.protected M
applyTransformers(M model, List<? extends Transformer<M,M>> transformers)
given an incomingmodel
, chain transformations of the mode using the giventransformers
.protected <T extends Template<M>>
List<T>getInstances(Class<? extends T>[] types)
protected List<Template<M>>
getTemplates()
Deprecated.since 2.3, prefer use thegetInstances(Class[])
Class<? extends Template<M>>[]
getTemplateTypes()
Class<? extends Template<M>>[]
getTransformers()
Deprecated.since 2.3, use the methodgetTemplateTypes()
instead.Class<? extends Transformer<M,M>>[]
getTransformerTypes()
void
setTemplateTypes(Class<? extends Template<M>>... templateTypes)
void
setTransformerTypes(Class<? extends Transformer<M,M>>... transformerTypes)
protected abstract boolean
validateModel(M model)
Validates the incoming givenmodel
.-
Methods inherited from class org.nuiton.eugene.AbstractGenerator
canGeneratePackage, getDestinationFile, getEncoding, getLastModifiedSource, getProperty, getProperty, getWriter, isNewerThanSource, isOverwrite, setParent, write
-
Methods inherited from class org.nuiton.eugene.Template
getClassLoader, getConfiguration, getExcludeTemplates, getGeneratedPackages, getModel, getOverwrite, getProperties, getResourcesHelper, getWriterReport, isVerbose, setConfiguration, setProperty
-
-
-
-
Constructor Detail
-
AbstractMetaTransformer
protected AbstractMetaTransformer()
-
AbstractMetaTransformer
@Deprecated public AbstractMetaTransformer(Class<? extends Template<M>>... templateTypes)
Deprecated.since 2.3, prefer use the default constructor, the invoke setterssetTemplateTypes(Class[])
andsetTransformerTypes(Class[])
.- Parameters:
templateTypes
- templates to apply on model
-
-
Method Detail
-
validateModel
protected abstract boolean validateModel(M model)
Validates the incoming givenmodel
. Note : If model is not valid, then nothing will be apply on the model (no transformer nor templates) in theapplyTemplate(Model, File)
.- Parameters:
model
- the incoming model to validate- Returns:
true
if model is valid,false
otherwise.
-
getTransformerTypes
public Class<? extends Transformer<M,M>>[] getTransformerTypes()
-
setTransformerTypes
public void setTransformerTypes(Class<? extends Transformer<M,M>>... transformerTypes)
-
applyTemplate
public void applyTemplate(M model, File destDir) throws IOException
- Specified by:
applyTemplate
in classTemplate<M extends Model>
- Throws:
IOException
-
applyTransformers
protected M applyTransformers(M model, List<? extends Transformer<M,M>> transformers)
given an incomingmodel
, chain transformations of the mode using the giventransformers
. Will aplly the transformers in the order given by the list, using as incoming model to a transformer the last (or incoming for the first transformer) model.- Parameters:
model
- incoming model to transformtransformers
- list of transformers to apply to the model- Returns:
- the final transformed model
- Since:
- 2.3
-
applyTemplates
protected void applyTemplates(M model, List<? extends Template<M>> templates, File destDir) throws IOException
Generates to the givendestination directory
using the given templates on the incoming givenmodel
.- Parameters:
model
- the incoming model to be used by templatestemplates
- templates to apply the incoming modeldestDir
- the destination directory where to generate- Throws:
IOException
- if any IO errors while generating files- Since:
- 2.3
-
getTemplates
@Deprecated protected List<Template<M>> getTemplates()
Deprecated.since 2.3, prefer use thegetInstances(Class[])
- Returns:
- the instances of templates to apply to the model.
-
getTransformers
@Deprecated public Class<? extends Template<M>>[] getTransformers()
Deprecated.since 2.3, use the methodgetTemplateTypes()
instead.- Returns:
- the template types to apply
-
-