Interface ELExpressionSource


public interface ELExpressionSource
A source of the expressions compiled at compilation time.

An implementation is generated for every type declaring expressions with io.micronaut.el.annotation.ELExpression and is registered as a service, so that CompiledExpressionFactory can return the compiled expression instead of parsing the expression string.

Since:
1.0
Author:
Denis Stepanov
  • Method Summary

    Modifier and Type
    Method
    Description
    default @Nullable jakarta.el.MethodExpression
    createMethodExpression(@Nullable jakarta.el.ELContext context, String expression, @Nullable Class<?> expectedReturnType, Class<?> @Nullable [] expectedParamTypes)
    Creates a compiled method expression and binds its variables against the creation context.
    default @Nullable jakarta.el.MethodExpression
    createMethodExpression(String expression, @Nullable Class<?> expectedReturnType, Class<?> @Nullable [] expectedParamTypes)
     
    default @Nullable jakarta.el.ValueExpression
    createValueExpression(@Nullable jakarta.el.ELContext context, String expression, Class<?> expectedType)
    Creates a compiled value expression and binds its variables against the creation context.
    default @Nullable jakarta.el.ValueExpression
    createValueExpression(String expression, Class<?> expectedType)
     
    default List<String>
    The expression strings this source declares, so that CompiledExpressionFactory can index the sources once and consult only the ones declaring the expression it is asked for.
  • Method Details

    • expressions

      default List<String> expressions()
      The expression strings this source declares, so that CompiledExpressionFactory can index the sources once and consult only the ones declaring the expression it is asked for.

      A source returning an empty list is consulted for every expression, which keeps a source generated before this method existed working, at the cost of a lookup per expression.

      Returns:
      The expression strings, value and method expressions alike
    • createValueExpression

      default @Nullable jakarta.el.ValueExpression createValueExpression(String expression, Class<?> expectedType)
      Parameters:
      expression - The expression string
      expectedType - The expected type
      Returns:
      The compiled value expression or null when this source does not declare it
    • createValueExpression

      default @Nullable jakarta.el.ValueExpression createValueExpression(@Nullable jakarta.el.ELContext context, String expression, Class<?> expectedType)
      Creates a compiled value expression and binds its variables against the creation context.

      The default delegates to the original context-free method so sources generated before this overload existed remain compatible.

      Parameters:
      context - The creation context
      expression - The expression string
      expectedType - The expected type
      Returns:
      The compiled value expression or null when this source does not declare it
      Since:
      1.0.1
    • createMethodExpression

      default @Nullable jakarta.el.MethodExpression createMethodExpression(String expression, @Nullable Class<?> expectedReturnType, Class<?> @Nullable [] expectedParamTypes)
      Parameters:
      expression - The expression string
      expectedReturnType - The expected return type, or null when the caller does not care
      expectedParamTypes - The expected parameter types, or null when the expression provides them
      Returns:
      The compiled method expression or null when this source does not declare it
    • createMethodExpression

      default @Nullable jakarta.el.MethodExpression createMethodExpression(@Nullable jakarta.el.ELContext context, String expression, @Nullable Class<?> expectedReturnType, Class<?> @Nullable [] expectedParamTypes)
      Creates a compiled method expression and binds its variables against the creation context.

      The default delegates to the original context-free method so sources generated before this overload existed remain compatible.

      Parameters:
      context - The creation context
      expression - The expression string
      expectedReturnType - The expected return type, or null when the caller does not care
      expectedParamTypes - The expected parameter types, or null when the expression provides them
      Returns:
      The compiled method expression or null when this source does not declare it
      Since:
      1.0.1