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 a CtExpression.

  • Constructor Details

    • ExpressionTemplate

      public ExpressionTemplate()
      Creates a new expression template parameter.
  • Method Details

    • 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()