Annotation Interface ELExpression
@Documented
@Retention(RUNTIME)
@Target({TYPE,ANNOTATION_TYPE,FIELD,METHOD,PARAMETER})
@Repeatable(ELExpressions.class)
public @interface ELExpression
Declares a Jakarta Expression Language value expression to be compiled at compilation time.
A jakarta.el.ValueExpression implementation is generated for the expression, so that no
parsing, no abstract syntax tree traversal and, whenever the types are known, no reflective
resolution happens at runtime.
An expression declared on a field, a method or a parameter is compiled into the registry of the declaring class, exactly as one declared on the class itself. This is how an annotation processor routes the expressions of other annotations, which live on the members, to the compiler.
- Since:
- 1.0
- Author:
- Denis Stepanov
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<?> The expected type the evaluation result is coerced to.The expression, which can be an eval-expression such as${user.name}, a literal-expression or a composite expression as defined by the Jakarta Expression Language specification.
-
Element Details
-
value
String valueThe expression, which can be an eval-expression such as${user.name}, a literal-expression or a composite expression as defined by the Jakarta Expression Language specification.- Returns:
- The expression
- Default:
""
-
expression
-
expectedType
Class<?> expectedTypeThe expected type the evaluation result is coerced to. When it is not declared, the compiler infers it from the static type of the expression:${book.discounted(10)}is aDoublebecausediscountedreturns one, and an expression whose type the compiler does not know is anObject. The generatedExpressionFactorythen serves the expression for the inferred type and forObject.class.- Returns:
- The expected type
- Default:
java.lang.Object.class
-
name
String name- Returns:
- The name of the generated constant, derived from the expression when not specified
- Default:
""
-