Class AnnotationMirrors
AnnotationMirrors, ExecutableElements,
and AnnotationValues.- Author:
- Laird Nelson
-
Method Summary
Modifier and TypeMethodDescriptionstatic final List<? extends AnnotationMirror> Returns a determinate, non-null, immutableListofAnnotationMirrors present on the suppliedElement.static final SequencedMap<ExecutableElement, AnnotationValue> For the suppliedAnnotationMirror, returns an immutable, determinateMapofAnnotationValueinstances indexed by itsExecutableElements to which they apply.static final Objectget(Map<? extends ExecutableElement, ? extends AnnotationValue> values, CharSequence name) A convenience method that returns a value for an annotation interface element named by the suppliedCharSequenceand found in the suppliedMap, ornullif no such value exists.static final AnnotationMirrorget(AnnotatedConstruct ac, CharSequence name) Returns the (determinate)AnnotationMirrordirectly present on the suppliedAnnotatedConstructwhose annotation type'sTypeElementbears the suppliedfullyQualifiedName, ornullif no suchAnnotationMirrorexists.static final Objectget(AnnotationMirror am, CharSequence name) A convenience method that returns a value for an annotation interface element named by the suppliedCharSequenceand logically owned by the suppliedAnnotationMirror, ornullif no such value exists.static final booleanReturnstrueif and only if the suppliedAnnotationMirror's annotation type is declared by an element that has been (meta-) annotated withInherited.static final booleaninherited(TypeElement annotationInterface) Returnstrueif and only if the suppliedTypeElementrepresents an annotation interface and if it has been (meta-) annotated withInherited.static final RetentionPolicyReturns aRetentionPolicyfor the suppliedAnnotationMirror, orRetentionPolicy.CLASSif, for any reason, a retention policy cannot be found or computed.static final RetentionPolicyretentionPolicy(TypeElement annotationInterface) Returns aRetentionPolicyfor the suppliedTypeElementrepresenting an annotation interface, orRetentionPolicy.CLASSif, for any reason, a retention policy cannot be found or computed.static final booleansameAnnotation(AnnotationMirror am0, AnnotationMirror am1) Determines whether the twoAnnotationMirrors represent the same (otherwise opaque) annotation.static final booleansameAnnotation(AnnotationMirror am0, AnnotationMirror am1, Predicate<? super ExecutableElement> p) Determines whether the twoAnnotationMirrors represent the same (underlying, otherwise opaque) annotation.static final Stream<AnnotationMirror> streamBreadthFirst(Collection<? extends AnnotationMirror> ams) Returns a non-null, sequential,Streamthat traverses the suppliedAnnotationMirrors, and their (meta-) annotations, in breadth-first order.static final Stream<AnnotationMirror> streamBreadthFirst(Collection<? extends AnnotationMirror> ams, Predicate<? super ExecutableElement> p) Returns a non-null, sequential,Streamthat traverses the suppliedAnnotationMirrors, and their (meta-) annotations, in breadth-first order.static final Stream<AnnotationMirror> Returns a non-null, sequential,Streamthat traverses the suppliedAnnotatedConstruct's annotations, and their (meta-) annotations, in breadth-first order.static final Stream<AnnotationMirror> streamBreadthFirst(AnnotatedConstruct ac, Predicate<? super ExecutableElement> p) Returns a non-null, sequential,Streamthat traverses the suppliedAnnotatedConstruct's annotations, and their (meta-) annotations, in breadth-first order.static final Stream<AnnotationMirror> streamDepthFirst(Collection<? extends AnnotationMirror> ams) Returns a non-null, sequentialStreamthat traverses the suppliedAnnotationMirrors, and their (meta-) annotations, in depth-first order.static final Stream<AnnotationMirror> streamDepthFirst(Collection<? extends AnnotationMirror> ams, Predicate<? super ExecutableElement> p) Returns a non-null, sequentialStreamthat traverses the suppliedAnnotationMirrors, and their (meta-) annotations, in depth-first order.static final Stream<AnnotationMirror> Returns a non-null, sequentialStreamthat traverses the suppliedAnnotatedConstruct's annotations, and their (meta-) annotations, in depth-first order.static final Stream<AnnotationMirror> streamDepthFirst(AnnotatedConstruct ac, Predicate<? super ExecutableElement> p) Returns a non-null, sequentialStreamthat traverses the suppliedAnnotatedConstruct's annotations, and their (meta-) annotations, in depth-first order.static final Set<ElementType> Returns a non-null, determinate, immutableSetofElementTypes describing restrictions concerning where the annotation interface represented by the suppliedAnnotationMirrormay be applied.static final Set<ElementType> targetElementTypes(TypeElement annotationInterface) Returns a non-null, determinate, immutableSetofElementTypes describing restrictions concerning where the supplied annotation interface may be applied.static final booleanReturnstrueif and only if the suppliedExecutableElementrepresents a valid annotation interface element as defined by the Java Language Specification.static final booleanReturnstrueif and only if the suppliedTypeMirroris a valid type for an annotation interface element as defined by the Java Language Specification.
-
Method Details
-
allAnnotationMirrors
Returns a determinate, non-null, immutableListofAnnotationMirrors present on the suppliedElement.This method is a more capable, better-typed replacement of the
Elements.getAllAnnotationMirrors(Element)method, and should be preferred.- Parameters:
e- anElement; must not benull- Returns:
- a determinate, non-
null, immutableListofAnnotationMirrors present on the suppliedElement - Throws:
NullPointerException- ifeisnull- See Also:
-
allAnnotationValues
public static final SequencedMap<ExecutableElement, AnnotationValue> allAnnotationValues(AnnotationMirror a) For the suppliedAnnotationMirror, returns an immutable, determinateMapofAnnotationValueinstances indexed by itsExecutableElements to which they apply.Each
ExecutableElementrepresents an annotation interface element and meets the requirements of such an element.Each
AnnotationValuerepresents the value of an annotation interface element and meets the requirements for annotation values.This method is a more capable, better-typed replacement of the
Elements.getElementValuesWithDefaults(AnnotationMirror)method, and should be preferred.- Parameters:
a- anAnnotationMirror; may benullin which case an empty, immutable, determinateMapwill be returned- Returns:
- an immutable, determinate
MapofAnnotationValueinstances indexed byExecutableElements - See Also:
- External Specifications
-
get
Returns the (determinate)AnnotationMirrordirectly present on the suppliedAnnotatedConstructwhose annotation type'sTypeElementbears the suppliedfullyQualifiedName, ornullif no suchAnnotationMirrorexists.- Parameters:
ac- anAnnotatedConstruct; must not benullname- aCharSequence; may benullin which casenullwill be returned- Returns:
- an
AnnotationMirror, ornull - Throws:
NullPointerException- ifacisnull- See Also:
-
get
A convenience method that returns a value for an annotation interface element named by the suppliedCharSequenceand logically owned by the suppliedAnnotationMirror, ornullif no such value exists.- Parameters:
am- anAnnotationMirror; must not benullname- aCharSequence; may benullin which casenullwill be returned- Returns:
- the result of invoking
getValue()on anAnnotationValue, ornull - Throws:
NullPointerException- ifamisnull- See Also:
-
get
public static final Object get(Map<? extends ExecutableElement, ? extends AnnotationValue> values, CharSequence name) A convenience method that returns a value for an annotation interface element named by the suppliedCharSequenceand found in the suppliedMap, ornullif no such value exists.- Parameters:
values- aMapas returned by theallAnnotationValues(AnnotationMirror)method; must not benullname- aCharSequence; may benullin which casenullwill be returned- Returns:
- the result of invoking
getValue()on a suitableAnnotationValuefound in the suppliedMap, ornull - Throws:
NullPointerException- ifvaluesisnull- See Also:
-
inherited
Returnstrueif and only if the suppliedAnnotationMirror's annotation type is declared by an element that has been (meta-) annotated withInherited.- Parameters:
a- anAnnotationMirror; must not benull- Returns:
trueif and only if the suppliedAnnotationMirror's annotation type is declared by an element that has been (meta-) annotated withInherited- Throws:
NullPointerException- ifaisnull- See Also:
-
inherited
Returnstrueif and only if the suppliedTypeElementrepresents an annotation interface and if it has been (meta-) annotated withInherited.- Parameters:
annotationInterface- aTypeElementrepresenting an annotation interface; must not benull- Returns:
trueif and only if the suppliedTypeElementrepresents an annotation interface and if it has been (meta-) annotated withInherited- Throws:
NullPointerException- ifannotationInterfaceisnull- External Specifications
-
retentionPolicy
Returns aRetentionPolicyfor the suppliedAnnotationMirror, orRetentionPolicy.CLASSif, for any reason, a retention policy cannot be found or computed.- Parameters:
a- anAnnotationMirror; must not benull- Returns:
- the
RetentionPolicyfor the suppliedAnnotationMirror; nevernull - Throws:
NullPointerException- ifaisnull- See Also:
-
retentionPolicy
Returns aRetentionPolicyfor the suppliedTypeElementrepresenting an annotation interface, orRetentionPolicy.CLASSif, for any reason, a retention policy cannot be found or computed.- Parameters:
annotationInterface- aTypeElement; must be non-nulland should represent an annotation interface- Returns:
- the
RetentionPolicyfor the suppliedTypeElement; nevernull - Throws:
NullPointerException- ifannotationInterfaceisnull- See Also:
- External Specifications
-
sameAnnotation
Determines whether the twoAnnotationMirrors represent the same (otherwise opaque) annotation.- Parameters:
am0- anAnnotationMirror; may benullam1- anAnnotationMirror; may benull- Returns:
trueif the suppliedAnnotationMirrors represent the same (otherwise opaque) annotation;falseotherwise- See Also:
-
sameAnnotation
public static final boolean sameAnnotation(AnnotationMirror am0, AnnotationMirror am1, Predicate<? super ExecutableElement> p) Determines whether the twoAnnotationMirrors represent the same (underlying, otherwise opaque) annotation.- Parameters:
am0- anAnnotationMirror; may benullam1- anAnnotationMirror; may benullp- aPredicatethat returnstrueif a givenExecutableElement, representing an annotation interface element, is to be included in the computation; may benullin which case it is as if()-> truewere supplied instead- Returns:
trueif the suppliedAnnotationMirrors represent the same (underlying, otherwise opaque) annotation;falseotherwise- See Also:
-
streamBreadthFirst
Returns a non-null, sequential,Streamthat traverses the suppliedAnnotatedConstruct's annotations, and their (meta-) annotations, in breadth-first order.Cycles are avoided via usage of the
sameAnnotation(AnnotationMirror, AnnotationMirror)method.- Parameters:
ac- anAnnotatedConstruct; must not benull- Returns:
- a non-
nullStreamofAnnotationMirrors - Throws:
NullPointerException- ifacisnull- See Also:
-
streamBreadthFirst
public static final Stream<AnnotationMirror> streamBreadthFirst(AnnotatedConstruct ac, Predicate<? super ExecutableElement> p) Returns a non-null, sequential,Streamthat traverses the suppliedAnnotatedConstruct's annotations, and their (meta-) annotations, in breadth-first order.Cycles and duplicates are avoided via usage of the
sameAnnotation(AnnotationMirror, AnnotationMirror, Predicate)method.- Parameters:
ac- anAnnotatedConstruct; must not benullp- aPredicatethat returnstrueif a givenExecutableElement, representing an annotation interface element, is to be included in comparison operations; may benullin which case it is as if()-> truewere supplied instead- Returns:
- a non-
nullStreamofAnnotationMirrors - Throws:
NullPointerException- ifacisnull- See Also:
-
streamBreadthFirst
public static final Stream<AnnotationMirror> streamBreadthFirst(Collection<? extends AnnotationMirror> ams) Returns a non-null, sequential,Streamthat traverses the suppliedAnnotationMirrors, and their (meta-) annotations, in breadth-first order.Cycles and duplicates are avoided via usage of the
sameAnnotation(AnnotationMirror, AnnotationMirror)method. Consequently the returnedStreamyields only semantically distinct elements.- Parameters:
ams- aCollectionofAnnotationMirrors; must not benull- Returns:
- a non-
nullStreamof (distinct)AnnotationMirrors - Throws:
NullPointerException- ifamsisnull- See Also:
-
streamBreadthFirst
public static final Stream<AnnotationMirror> streamBreadthFirst(Collection<? extends AnnotationMirror> ams, Predicate<? super ExecutableElement> p) Returns a non-null, sequential,Streamthat traverses the suppliedAnnotationMirrors, and their (meta-) annotations, in breadth-first order.Cycles and duplicates are avoided via usage of the
sameAnnotation(AnnotationMirror, AnnotationMirror, Predicate)method. Consequently the returnedStreamyields only semantically distinct elements.- Parameters:
ams- aCollectionofAnnotationMirrors; must not benullp- aPredicatethat returnstrueif a givenExecutableElement, representing an annotation element, is to be included in comparison operations; may benullin which case it is as if()-> truewere supplied instead- Returns:
- a non-
nullStreamof (distinct)AnnotationMirrors - Throws:
NullPointerException- ifamsisnull- See Also:
-
streamDepthFirst
Returns a non-null, sequentialStreamthat traverses the suppliedAnnotatedConstruct's annotations, and their (meta-) annotations, in depth-first order.Cycles are avoided via usage of the
sameAnnotation(AnnotationMirror, AnnotationMirror)method.- Parameters:
ac- anAnnotatedConstruct; must not benull- Returns:
- a non-
nullStreamofAnnotationMirrors - Throws:
NullPointerException- ifacisnull- See Also:
-
streamDepthFirst
public static final Stream<AnnotationMirror> streamDepthFirst(AnnotatedConstruct ac, Predicate<? super ExecutableElement> p) Returns a non-null, sequentialStreamthat traverses the suppliedAnnotatedConstruct's annotations, and their (meta-) annotations, in depth-first order.Cycles and duplicates are avoided via usage of the
sameAnnotation(AnnotationMirror, AnnotationMirror, Predicate)method.- Parameters:
ac- anAnnotatedConstruct; must not benullp- aPredicatethat returnstrueif a givenExecutableElement, representing an annotation element, is to be included in comparison operations; may benullin which case it is as if()-> truewere supplied instead- Returns:
- a non-
nullStreamofAnnotationMirrors - Throws:
NullPointerException- ifacisnull- See Also:
-
streamDepthFirst
public static final Stream<AnnotationMirror> streamDepthFirst(Collection<? extends AnnotationMirror> ams) Returns a non-null, sequentialStreamthat traverses the suppliedAnnotationMirrors, and their (meta-) annotations, in depth-first order.Cycles and duplicates are avoided via usage of the
sameAnnotation(AnnotationMirror, AnnotationMirror)method.- Parameters:
ams- a non-nullCollectionofAnnotationMirrors- Returns:
- a non-
nullStreamofAnnotationMirrors - Throws:
NullPointerException- ifamsisnull- See Also:
-
streamDepthFirst
public static final Stream<AnnotationMirror> streamDepthFirst(Collection<? extends AnnotationMirror> ams, Predicate<? super ExecutableElement> p) Returns a non-null, sequentialStreamthat traverses the suppliedAnnotationMirrors, and their (meta-) annotations, in depth-first order.Cycles and duplicates are avoided via usage of the
sameAnnotation(AnnotationMirror, AnnotationMirror, Predicate)method.- Parameters:
ams- a non-nullCollectionofAnnotationMirrorsp- aPredicatethat returnstrueif a givenExecutableElement, representing an annotation element, is to be included in comparison operations; may benullin which case it is as if()-> truewere supplied instead- Returns:
- a non-
nullStreamofAnnotationMirrors - Throws:
NullPointerException- ifamsisnull- See Also:
-
targetElementTypes
Returns a non-null, determinate, immutableSetofElementTypes describing restrictions concerning where the annotation interface represented by the suppliedAnnotationMirrormay be applied.- Parameters:
a- anAnnotationMirror; must not benull- Returns:
- a non-
null, determinate, immutableSetofElementTypes describing restrictions concerning where the annotation interface represented by the suppliedAnnotationMirrormay be applied - Throws:
NullPointerException- ifaisnull
-
targetElementTypes
Returns a non-null, determinate, immutableSetofElementTypes describing restrictions concerning where the supplied annotation interface may be applied.- Parameters:
annotationInterface- aTypeElementrepresenting an annotation interface; must not benull- Returns:
- a non-
null, determinate, immutableSetofElementTypes describing restrictions concerning where the supplied annotation interface may be applied - Throws:
NullPointerException- ifannotationInterfaceisnull- See Also:
- External Specifications
-
validAnnotationInterfaceElement
Returnstrueif and only if the suppliedExecutableElementrepresents a valid annotation interface element as defined by the Java Language Specification.- Parameters:
e- anExecutableElement; must not benull- Returns:
trueif and only if the suppliedExecutableElementrepresents a valid annotation interface element as defined by the Java Language Specification- Throws:
NullPointerException- ifeisnull- External Specifications
-
validAnnotationInterfaceElementType
Returnstrueif and only if the suppliedTypeMirroris a valid type for an annotation interface element as defined by the Java Language Specification.- Parameters:
t- aTypeMirror; must not benull- Returns:
trueif and only if the suppliedTypeMirroris a valid type for an annotation interface element as defined by the Java Language Specification- Throws:
NullPointerException- iftisnull- External Specifications
-