Class 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 Detail

      • ExpressionTemplate

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

      • expression

        public abstract T expression()
                              throws java.lang.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:
        java.lang.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()