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 - dev@tchemit.fr
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<? extends Template<M>>[]templateTypesTemplates to apply to the model.protected Class<? extends Transformer<M,M>>[]transformerTypesTransformers 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_I18N_GETTER_FILE, PROP_LAST_MODIFIED_SOURCE, PROP_OUTPUT_DIRECTORY, PROP_OVERWRITE, PROP_RESOURCE_DIRECTORY, PROP_VERBOSE, PROP_WRITER_REPORT
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMetaTransformer()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 voidapplyTemplate(M model, File destDir)protected voidapplyTemplates(M model, List<? extends Template<M>> templates, File destDir)Generates to the givendestination directoryusing the given templates on the incoming givenmodel.protected MapplyTransformers(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()voidsetTemplateTypes(Class<? extends Template<M>>... templateTypes)voidsetTransformerTypes(Class<? extends Transformer<M,M>>... transformerTypes)protected abstract booleanvalidateModel(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, getLog, getModel, getOverwrite, getProperties, getResourcesHelper, getWriterReport, isVerbose, setConfiguration, setLog, setProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuiton.eugene.TemplateConfiguration
getI18nGetterFile, setI18nGetterFile
-
-
-
-
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:
trueif model is valid,falseotherwise.
-
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:
applyTemplatein 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 directoryusing 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
-
-