Package spoon.template
Class ExpressionTemplate<T>
- All Implemented Interfaces:
Template<CtExpression<T>>
This class represents an expression template parameter expressed in Java.
To define a new expression template parameter, you must subclass this class
and implement the expression()
method, which actually defines the
Java expression. It corresponds to a CtExpression
.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the code which results from applying the template.abstract T
This method must be implemented to define the template expression.static <T> CtExpression<T>
getExpression(CtClass<? extends ExpressionTemplate<?>> p)
Returns the expression.S()
Methods inherited from class spoon.template.AbstractTemplate
addGeneratedBy, getFactory, isAddGeneratedBy, isValid, isWellFormed, withPartialEvaluation
-
Constructor Details
-
ExpressionTemplate
public ExpressionTemplate()Creates a new expression template parameter.
-
-
Method Details
-
getExpression
Returns the expression. -
expression
This method must be implemented to define the template expression. The convention is that the defined expression corresponds to the expression returned by the return statement of the method.- Throws:
Throwable
-
apply
Description copied from interface:Template
Returns the code which results from applying the template.- Parameters:
targetType
- the type that defines the context of the substitution. It may be null for templates with no context.
-
S
-