Class ExpressionTemplate<T>

All Implemented Interfaces:

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.
    • apply

      public CtExpression<T> apply(CtType<?> targetType)
      Description copied from interface: Template
      Returns the code which results from applying the template.
      targetType - the type that defines the context of the substitution. It may be null for templates with no context.
    • S

      public T S()