Package spoon.template
Class ExpressionTemplate<T>
- java.lang.Object
-
- spoon.template.AbstractTemplate<CtExpression<T>>
-
- spoon.template.ExpressionTemplate<T>
-
- All Implemented Interfaces:
Template<CtExpression<T>>
public abstract class ExpressionTemplate<T> extends AbstractTemplate<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 aCtExpression
.
-
-
Constructor Summary
Constructors Constructor Description ExpressionTemplate()
Creates a new expression template parameter.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CtExpression<T>
apply(CtType<?> targetType)
Returns the code which results from applying the template.abstract T
expression()
This method must be implemented to define the template expression.static <T> CtExpression<T>
getExpression(CtClass<? extends ExpressionTemplate<?>> p)
Returns the expression.T
S()
-
Methods inherited from class spoon.template.AbstractTemplate
addGeneratedBy, getFactory, isAddGeneratedBy, isValid, isWellFormed, withPartialEvaluation
-
-
-
-
Method Detail
-
getExpression
public static <T> CtExpression<T> getExpression(CtClass<? extends ExpressionTemplate<?>> p)
Returns the expression.
-
expression
public abstract T expression() throws Throwable
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
public CtExpression<T> apply(CtType<?> targetType)
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
public T S()
-
-