Class Transformer<I extends Model,​O extends Model>

  • Type Parameters:
    I - input model to transform
    O - 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 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
      • outputModel

        protected O extends Model outputModel
        Output model.
      • outputProperties

        protected Properties outputProperties
        Properties for output generator.
    • Constructor Detail

      • Transformer

        public Transformer()
    • 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 now addOutputProperty(String, Object)
        Output properties for output generator. Initially set from build configuration.
        Returns:
        output properties
        Since:
        2.0.0
      • addOutputProperty

        public void addOutputProperty​(String key,
                                      Object value)
      • getOutputTemplate

        public Template<O> getOutputTemplate()
      • 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 overriding initPreviousTransformer() 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 override initOutputModel() and initOutputTemplate() methods to initialize output model and output template to apply (generally a generator).
        Specified by:
        applyTemplate in class Template<I extends Model>
        Parameters:
        model - input model to transform and generate
        destDir - 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