Class AbstractMetaTransformer<M extends Model>

  • 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 the Template.getExcludeTemplates() to restrict use of some templates. Created: 20 déc. 2009
    Since:
    2.0.0
    Author:
    Tony Chemit - chemit@codelutin.com
    • Field Detail

      • transformerTypes

        protected Class<? extends Transformer<M extends Model,​M extends Model>>[] transformerTypes
        Transformers to apply before using templates. It will replace each time the input model by the generated output model.
        Since:
        2.3
      • templateTypes

        protected Class<? extends Template<M extends Model>>[] templateTypes
        Templates to apply to the model.
        Since:
        2.3, replace the old transformers field.
    • Method Detail

      • validateModel

        protected abstract boolean validateModel​(M model)
        Validates the incoming given model. Note : If model is not valid, then nothing will be apply on the model (no transformer nor templates) in the applyTemplate(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()
      • getTemplateTypes

        public Class<? extends Template<M>>[] getTemplateTypes()
      • setTransformerTypes

        public void setTransformerTypes​(Class<? extends Transformer<M,​M>>... transformerTypes)
      • setTemplateTypes

        public void setTemplateTypes​(Class<? extends Template<M>>... templateTypes)
      • applyTransformers

        protected M applyTransformers​(M model,
                                      List<? extends Transformer<M,​M>> transformers)
        given an incoming model, chain transformations of the mode using the given transformers. 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 transform
        transformers - 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 given destination directory using the given templates on the incoming given model.
        Parameters:
        model - the incoming model to be used by templates
        templates - templates to apply the incoming model
        destDir - the destination directory where to generate
        Throws:
        IOException - if any IO errors while generating files
        Since:
        2.3
      • getInstances

        protected <T extends Template<M>> List<T> getInstances​(Class<? extends T>[] types)