Modifier and Type | Method and Description |
---|---|
static <T extends CtType<?>> |
createTypeFromTemplate(String qualifiedTypeName,
CtType<?> templateOfType,
Map<String,Object> templateParameters)
Generates a type (class, interface, enum, ...) from the template model `templateOfType`
by by substituting all the template parameters by their values.
|
static <T extends Template<?>> |
insertAll(CtType<?> targetType,
T template)
Inserts all the methods, fields, constructors, initialization blocks (if
target is a class), inner types, and super interfaces (except
Template ) from a given template by substituting all the template
parameters by their values. |
static void |
insertAllConstructors(CtType<?> targetType,
Template<?> template)
Inserts all constructors and initialization blocks from a given template
by substituting all the template parameters by their values.
|
static void |
insertAllFields(CtType<?> targetType,
Template<?> template)
Inserts all the fields from a given template by substituting all the
template parameters by their values.
|
static void |
insertAllMethods(CtType<?> targetType,
Template<?> template)
Inserts all the methods from a given template by substituting all the
template parameters by their values.
|
static void |
insertAllNestedTypes(CtType<?> targetType,
Template<?> template)
Inserts all the nested types from a given template by substituting all the
template parameters by their values.
|
static void |
insertAllSuperInterfaces(CtType<?> targetType,
Template<?> template)
Inserts all the super interfaces (except
Template ) from a given
template by substituting all the template parameters by their values. |
static <T> CtConstructor<T> |
insertConstructor(CtClass<T> targetClass,
Template<?> template,
CtConstructor<?> sourceConstructor)
Generates a constructor from a template constructor by substituting all
the template parameters by their values.
|
static <T> CtConstructor<T> |
insertConstructor(CtClass<T> targetClass,
Template<?> template,
CtMethod<?> sourceMethod)
Generates a constructor from a template method by substituting all the
template parameters by their values.
|
static <T> CtField<T> |
insertField(CtType<?> targetType,
Template<?> template,
CtField<T> sourceField)
Generates a field (and its initialization expression) from a template
field by substituting all the template parameters by their values.
|
static <T> CtMethod<T> |
insertMethod(CtType<?> targetType,
Template<?> template,
CtMethod<T> sourceMethod)
Generates a method from a template method by substituting all the
template parameters by their values.
|
static void |
redirectTypeReferences(CtElement element,
CtTypeReference<?> source,
CtTypeReference<?> target)
A helper method that recursively redirects all the type references from a
source type to a target type in the given element.
|
static <E extends CtElement> |
substitute(CtType<?> targetType,
Template<?> template,
E code)
Substitutes all the template parameters in a random piece of code.
|
static <T extends CtType<?>> |
substitute(Template<?> template,
T templateType)
Substitutes all the template parameters in a given template type and
returns the resulting type.
|
static CtExpression<?> |
substituteFieldDefaultExpression(CtType<?> targetType,
Template<?> template,
String fieldName)
Gets a default expression from a template field with all the template
parameters substituted.
|
static CtBlock<?> |
substituteMethodBody(CtClass<?> targetClass,
Template<?> template,
String executableName,
CtTypeReference<?>... parameterTypes)
Gets a body from a template executable with all the template parameters
substituted.
|
static CtStatement |
substituteStatement(CtClass<?> targetClass,
Template<?> template,
int statementIndex,
String executableName,
CtTypeReference<?>... parameterTypes)
Gets a statement from a template executable with all the template
parameters substituted.
|
public static <T extends Template<?>> void insertAll(CtType<?> targetType, T template)
Template
) from a given template by substituting all the template
parameters by their values. Members annotated with
Local
or Parameter
are not inserted.targetType
- the target typetemplate
- the source templatepublic static <T extends CtType<?>> T createTypeFromTemplate(String qualifiedTypeName, CtType<?> templateOfType, Map<String,Object> templateParameters)
Template
, Local
, TemplateParameter
or Parameter
in a special way, it means they all will be added to the generated type too.
If you do not want to add them then clone your templateOfType and remove these nodes from that model before.qualifiedTypeName
- the qualified name of the new typetemplateOfType
- the model used as source of generation.templateParameters
- the substitution parameterspublic static void insertAllSuperInterfaces(CtType<?> targetType, Template<?> template)
Template
) from a given
template by substituting all the template parameters by their values.targetType
- the target typetemplate
- the source templatepublic static void insertAllMethods(CtType<?> targetType, Template<?> template)
Local
or Parameter
are not inserted.targetType
- the target typetemplate
- the source templatepublic static void insertAllFields(CtType<?> targetType, Template<?> template)
Local
or Parameter
are not inserted.targetType
- the target typetemplate
- the source templatepublic static void insertAllNestedTypes(CtType<?> targetType, Template<?> template)
Local
are not inserted.targetType
- the target typetemplate
- the source templatepublic static void insertAllConstructors(CtType<?> targetType, Template<?> template)
Local
or Parameter
are not
inserted.targetType
- the target typetemplate
- the source templatepublic static <T> CtConstructor<T> insertConstructor(CtClass<T> targetClass, Template<?> template, CtMethod<?> sourceMethod)
targetClass
- the target class where to insert the generated constructortemplate
- the template instance that holds the source template method
and that defines the parameter valuessourceMethod
- the source template methodpublic static <T> CtMethod<T> insertMethod(CtType<?> targetType, Template<?> template, CtMethod<T> sourceMethod)
targetType
- the target type where to insert the generated methodtemplate
- the template instance that holds the source template method
and that defines the parameter valuessourceMethod
- the source template methodpublic static <T> CtConstructor<T> insertConstructor(CtClass<T> targetClass, Template<?> template, CtConstructor<?> sourceConstructor)
targetClass
- the target class where to insert the generated constructortemplate
- the template instance that holds the source template
constructor and that defines the parameter valuessourceConstructor
- the source template constructorpublic static CtBlock<?> substituteMethodBody(CtClass<?> targetClass, Template<?> template, String executableName, CtTypeReference<?>... parameterTypes)
targetClass
- the target classtemplate
- the template that holds the executableexecutableName
- the source executable templateparameterTypes
- the parameter types of the source executablepublic static CtStatement substituteStatement(CtClass<?> targetClass, Template<?> template, int statementIndex, String executableName, CtTypeReference<?>... parameterTypes)
targetClass
- the target classtemplate
- the template that holds the executablestatementIndex
- the statement index in the executable's bodyexecutableName
- the source executable templateparameterTypes
- the parameter types of the source executablepublic static CtExpression<?> substituteFieldDefaultExpression(CtType<?> targetType, Template<?> template, String fieldName)
targetType
- the target typetemplate
- the template that holds the fieldfieldName
- the template source fieldpublic static <E extends CtElement> E substitute(CtType<?> targetType, Template<?> template, E code)
targetType
- the target typetemplate
- the template instancecode
- the codepublic static <T extends CtType<?>> T substitute(Template<?> template, T templateType)
template
- the template instance (holds the parameter values)templateType
- the template typepublic static <T> CtField<T> insertField(CtType<?> targetType, Template<?> template, CtField<T> sourceField)
T
- the type of the fieldtargetType
- the target type where the field is insertedtemplate
- the template that defines the source template fieldsourceField
- the source template fieldpublic static void redirectTypeReferences(CtElement element, CtTypeReference<?> source, CtTypeReference<?> target)
Copyright © 2007–2018 Inria. All rights reserved.