Module jakarta.cdi

Class AnnotationLiteral<T extends Annotation>

java.lang.Object
jakarta.enterprise.util.AnnotationLiteral<T>
Type Parameters:
T - the annotation type
All Implemented Interfaces:
Serializable, Annotation
Direct Known Subclasses:
Alternative.Literal, Any.Literal, ApplicationScoped.Literal, BeforeDestroyed.Literal, ConversationScoped.Literal, Default.Literal, Dependent.Literal, Destroyed.Literal, Initialized.Literal, InjectLiteral, NamedLiteral, Nonbinding.Literal, QualifierLiteral, RequestScoped.Literal, SessionScoped.Literal, SingletonLiteral, Specializes.Literal, TransientReference.Literal, Typed.Literal, Vetoed.Literal

public abstract class AnnotationLiteral<T extends Annotation> extends Object implements Annotation, Serializable

Supports inline instantiation of annotation type instances.

Reflection operations are using SecurityActions utility class to support security manager.

An instance of an annotation type may be obtained by subclassing AnnotationLiteral. The subclass must implement the annotation interface to satisfy the Annotation contract.

 public abstract class PayByQualifier extends AnnotationLiteral<PayBy> implements PayBy {
 }
 
 PayBy payByCheque = new PayByQualifier() {
     public PaymentMethod value() {
         return CHEQUE;
     }
 };
 
See Also: