Class AnnotationMetadata
java.lang.Object
be.imgn.inject.context.AnnotationMetadata
The framework-related annotations captured at an injection point or provision definition: every annotation whose type
carries
InjectingAnnotation, QualifyingAnnotation, or
ScopingAnnotation.
Annotations are held as AnnotationValue data computed at compile time, so inspection needs no reflection:
metadata.get(Named.class).flatMap(AnnotationValue::stringValue); // by type
metadata.byStereotype(QualifyingAnnotation.class); // every qualifier at this site
At most one annotation per annotation type is held, matching the language rule for non-repeatable annotations.
-
Method Summary
Modifier and TypeMethodDescriptionbyStereotype(Class<? extends Annotation> stereotype) Returns every annotation at the site whose type carriesstereotype.static AnnotationMetadataempty()Returns the shared empty metadata instance.get(Class<? extends Annotation> type) Returns the annotation oftypepresent at the site, if any.booleanhasStereotype(Class<? extends Annotation> stereotype) Returns whether any annotation at the site carriesstereotype.booleanisEmpty()Returns whether no framework-related annotation was present at the site.booleanisPresent(Class<? extends Annotation> type) Returns whether an annotation oftypeis present at the site.static AnnotationMetadataof(AnnotationValue... annotations) Returns metadata holdingannotations, keyed by annotation type.toString()Set<Class<? extends Annotation>> types()Returns the annotation types present at the site.
-
Method Details
-
empty
Returns the shared empty metadata instance.- Returns:
- the shared empty metadata instance
-
of
Returns metadata holdingannotations, keyed by annotation type.- Parameters:
annotations- the framework-related annotations present at the site; later entries win for a repeated type- Returns:
- metadata holding
annotations, keyed by annotation type
-
get
Returns the annotation oftypepresent at the site, if any.- Parameters:
type- the annotation type to look up- Returns:
- the annotation of
typepresent at the site, if any
-
isPresent
Returns whether an annotation oftypeis present at the site.- Parameters:
type- the annotation type to test- Returns:
- whether an annotation of
typeis present at the site
-
byStereotype
Returns every annotation at the site whose type carriesstereotype.- Parameters:
stereotype- the meta-annotation to filter by, such asQualifyingAnnotation.class- Returns:
- every annotation at the site whose type carries
stereotype
-
hasStereotype
Returns whether any annotation at the site carriesstereotype.- Parameters:
stereotype- the meta-annotation to test- Returns:
- whether any annotation at the site carries
stereotype
-
types
Returns the annotation types present at the site.- Returns:
- the annotation types present at the site
-
isEmpty
public boolean isEmpty()Returns whether no framework-related annotation was present at the site.- Returns:
- whether no framework-related annotation was present at the site
-
toString
-