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, determinateSequencedMapofAnnotationValueinstances indexed by theExecutableElements to which they apply.static final booleancontains(Collection<? extends AnnotationMirror> c, AnnotationMirror a) Returnstrueif and only if the suppliedCollectionofAnnotationMirrors contains anAnnotationMirrorthat is the same as the suppliedAnnotationMirror.static final booleancontains(Collection<? extends AnnotationMirror> c, AnnotationMirror a, Predicate<? super ExecutableElement> p) Returnstrueif and only if the suppliedCollectionofAnnotationMirrors contains anAnnotationMirrorthat is the same as the suppliedAnnotationMirror.static final booleancontainsAll(Collection<? extends AnnotationMirror> c0, Collection<? extends AnnotationMirror> c1) static final booleancontainsAll(Collection<? extends AnnotationMirror> c0, Collection<? extends AnnotationMirror> c1, Predicate<? super ExecutableElement> p) 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 intAn experimental method that returns a hashcode for anAnnotationMirroraccording as much as possible to the rules described in theAnnotation.hashCode()contract.static final inthashCode(AnnotationMirror a, Predicate<? super ExecutableElement> p) An experimental method that returns a hashcode for anAnnotationMirroraccording as much as possible to the rules described in theAnnotation.hashCode()contract.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 booleansameAnnotations(Collection<? extends AnnotationMirror> c0, Collection<? extends AnnotationMirror> c1) Returnstrueifc0has all the same annotations asc1, and ifc1has all the same annotations asc0.static final booleansameAnnotations(Collection<? extends AnnotationMirror> c0, Collection<? extends AnnotationMirror> c1, Predicate<? super ExecutableElement> p) Returnstrueifc0has all the same annotations asc1, and ifc1has all the same annotations asc0.static final Stream<AnnotationMirror> streamBreadthFirst(Collection<? extends AnnotationMirror> ams) Returns a non-null, sequentialStreamthat 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, sequentialStreamthat traverses the suppliedAnnotationMirrors, and their (meta-) annotations, in breadth-first order.static final Stream<AnnotationMirror> Returns a non-null, sequentialStreamthat 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, sequentialStreamthat 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, determinateSequencedMapofAnnotationValueinstances indexed by theExecutableElements 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 of such a value.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, determinateSequencedMapwill be returned- Returns:
- an immutable, determinate
MapofAnnotationValueinstances indexed byExecutableElements - See Also:
- External Specifications
-
contains
Returnstrueif and only if the suppliedCollectionofAnnotationMirrors contains anAnnotationMirrorthat is the same as the suppliedAnnotationMirror.- Parameters:
c- a non-nullCollectionofAnnotationMirrorsa- a non-nullAnnotationMirror- Returns:
trueif and only if the suppliedCollectionofAnnotationMirrors contains anAnnotationMirrorthat is the same as the suppliedAnnotationMirror- Throws:
NullPointerException- ifcoraisnull- See Also:
-
contains
public static final boolean contains(Collection<? extends AnnotationMirror> c, AnnotationMirror a, Predicate<? super ExecutableElement> p) Returnstrueif and only if the suppliedCollectionofAnnotationMirrors contains anAnnotationMirrorthat is the same as the suppliedAnnotationMirror.- Parameters:
c- a non-nullCollectionofAnnotationMirrorsa- a non-nullAnnotationMirrorp- aPredicatethat returnstrueif a givenExecutableElement, representing an annotation element, is to be included in comparison operations; may benullin which case it is as ife -> truewere supplied instead- Returns:
trueif and only if the suppliedCollectionofAnnotationMirrors contains anAnnotationMirrorthat is the same as the suppliedAnnotationMirror- Throws:
NullPointerException- ifcoraisnull- See Also:
-
containsAll
public static final boolean containsAll(Collection<? extends AnnotationMirror> c0, Collection<? extends AnnotationMirror> c1) - Parameters:
c0- a non-nullCollectionofAnnotationMirrorsc1- a non-nullCollectionofAnnotationMirrors- Returns:
trueif and only ifc0contains all the sameAnnotationMirrors as are found inc1- Throws:
NullPointerException- if eitherc0orc1isnull- See Also:
-
containsAll
public static final boolean containsAll(Collection<? extends AnnotationMirror> c0, Collection<? extends AnnotationMirror> c1, Predicate<? super ExecutableElement> p) - Parameters:
c0- a non-nullCollectionofAnnotationMirrorsc1- 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 ife -> truewere supplied instead- Returns:
trueif and only ifc0contains all the sameAnnotationMirrors as are found inc1- Throws:
NullPointerException- if eitherc0orc1isnull- See Also:
-
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:
-
hashCode
An experimental method that returns a hashcode for anAnnotationMirroraccording as much as possible to the rules described in theAnnotation.hashCode()contract.- Parameters:
a- anAnnotationMirrorfor which a hashcode should be computed; may benullin which case0will be returned- Returns:
- a hashcode for the supplied
AnnotationMirrorcomputed according to the rules described in theAnnotation.hashCode()contract - See Also:
-
hashCode
An experimental method that returns a hashcode for anAnnotationMirroraccording as much as possible to the rules described in theAnnotation.hashCode()contract.- Parameters:
a- anAnnotationMirrorfor which a hashcode should be computed; may benullin which case0will be returnedp- aPredicatethat accepts a (non-null)ExecutableElementrepresenting an annotation element and returnstrueif and only if the element should be included; may benullin which case aPredicatesemantically identical toee -> truewill be used instead- Returns:
- a hashcode for the supplied
AnnotationMirrorcomputed according to the rules described in theAnnotation.hashCode()contract - 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 ife -> truewere supplied instead- Returns:
trueif the suppliedAnnotationMirrors represent the same (underlying, otherwise opaque) annotation;falseotherwise- See Also:
-
sameAnnotations
public static final boolean sameAnnotations(Collection<? extends AnnotationMirror> c0, Collection<? extends AnnotationMirror> c1) Returnstrueifc0has all the same annotations asc1, and ifc1has all the same annotations asc0.- Parameters:
c0- a non-nullCollectionofAnnotationMirrorsc1- a non-nullCollectionofAnnotationMirrors- Returns:
trueifc0has all the same annotations asc1, and ifc1has all the same annotations asc0- Throws:
NullPointerException- if eitherc0orc1isnull- See Also:
-
sameAnnotations
public static final boolean sameAnnotations(Collection<? extends AnnotationMirror> c0, Collection<? extends AnnotationMirror> c1, Predicate<? super ExecutableElement> p) Returnstrueifc0has all the same annotations asc1, and ifc1has all the same annotations asc0.- Parameters:
c0- a non-nullCollectionofAnnotationMirrorsc1- a non-nullCollectionofAnnotationMirrorsp- aPredicatethat returnstrueif a givenExecutableElement, representing an annotation interface element, is to be included in the computation; may benullin which case it is as ife -> truewere supplied instead- Returns:
trueifc0has all the same annotations asc1, and ifc1has all the same annotations asc0- Throws:
NullPointerException- if eitherc0orc1isnull- See Also:
-
streamBreadthFirst
Returns a non-null, sequentialStreamthat 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)method. Consequently the returnedStreamyields only semantically distinct elements.- 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, sequentialStreamthat 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. Consequently the returnedStreamyields only semantically distinct elements.- 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 ife -> 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, sequentialStreamthat 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, sequentialStreamthat 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 ife -> 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 and duplicates are avoided via usage of the
sameAnnotation(AnnotationMirror, AnnotationMirror)method. Consequently the returnedStreamyields only semantically distinct elements.- 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. Consequently the returnedStreamyields only semantically distinct elements.- 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 ife -> truewere supplied instead- Returns:
- a non-
null, sequentialStreamofAnnotationMirrors - 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. Consequently the returnedStreamyields only semantically distinct elements.- Parameters:
ams- a non-nullCollectionofAnnotationMirrors- Returns:
- a non-
null, seqwuentialStreamofAnnotationMirrors - 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. Consequently the returnedStreamyields only semantically distinct elements.- 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 ife -> truewere supplied instead- Returns:
- a non-
null, sequentialStreamofAnnotationMirrors - 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
-