Class ExpressionMarker

java.lang.Object
org.springframework.data.repository.aot.generate.ExpressionMarker

public class ExpressionMarker extends Object
ExpressionMarker is used to add a dedicated type to AOT generated methods that can be used to determine the current method by calling Class.getEnclosingMethod() on it. This can be useful when working with expressions (eg. SpEL) that need to be evaluated in a given context.

ExpressionMarker is intended to be used via AotQueryMethodGenerationContext to maintain usage info, making sure the code is only added (isInUse()) when enclosingMethod() was called for generating code.

ExpressionMarker marker = context.getExpressionMarker();
CodeBlock.builder().add("evaluate($L, $S, $L)", marker.enclosingMethod(), queryString, parameters);
Since:
4.0
Author:
Christoph Strobl
  • Method Details

    • marker

      public org.springframework.javapoet.CodeBlock marker()
      Calling this method sets the ExpressionMarker as in-use.
      Returns:
      ExpressionMarker.class.
    • enclosingMethod

      public org.springframework.javapoet.CodeBlock enclosingMethod()
      Calling this method sets the ExpressionMarker as in-use.
      Returns:
      ExpressionMarker.class.getEnclosingMethod()
    • isInUse

      public boolean isInUse()
      Returns:
      if the marker is in use.