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 Summary
Modifier and TypeMethodDescription<T extends CtType<?>>
TGenerates a type with qualified name `typeQualifiedName` by replacing the generator parameters with the arguments given in `params`.Main method to generate a new AST made from substituting of parameters by the values in `params`generate(ImmutableMap params)
Utility method that provides the same feature asgenerate(Map)
, but with aImmutableMap
as parameter (a Spoon elegant utility type)
-
Method Details
-
getFactory
Factory getFactory()- Returns:
- a
Factory
, which has to be used to generate instances
-
generate
Main method to generate a new AST made from substituting of parameters by the values in `params`- Parameters:
params
- - the substitution parameters, it can be CtElement, primitive literals like String, Integer, ... and or List or Set of them.- Returns:
- List of generated elements
-
generate
Utility method that provides the same feature asgenerate(Map)
, but with aImmutableMap
as parameter (a Spoon elegant utility type) -
generate
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.- Parameters:
typeQualifiedName
- the qualified name of to be generated typeparams
- the pattern parameters- Returns:
- the generated type
-