Package spoon.pattern

Interface Generator

All Known Implementing Classes:
DefaultGenerator, PatternPrinter

public interface Generator
Generates code from patterns. The core idea is to replace pattern parameters by objects.
  • Method Details

    • getFactory

      Factory getFactory()
      a Factory, which has to be used to generate instances
    • generate

      <T extends CtElement> List<T> generate(Map<String,​Object> params)
      Main method to generate a new AST made from substituting of parameters by the values in `params`
      params - - the substitution parameters, it can be CtElement, primitive literals like String, Integer, ... and or List or Set of them.
      List of generated elements
    • generate

      <T extends CtElement> List<T> generate(ImmutableMap params)
      Utility method that provides the same feature as generate(Map), but with a ImmutableMap as parameter (a Spoon elegant utility type)
    • generate

      <T extends CtType<?>> T generate(String typeQualifiedName, Map<String,​Object> params)
      Generates a type with qualified name `typeQualifiedName` by replacing the generator parameters with the arguments given in `params`. Note: the root element of pattern must be a CtType.
      typeQualifiedName - the qualified name of to be generated type
      params - the pattern parameters
      the generated type