Class NoElementQualifierHierarchy

    • Field Detail

      • kindToAnnotationMirror

        protected final java.util.Map<QualifierKind,​javax.lang.model.element.AnnotationMirror> kindToAnnotationMirror
        Mapping from QualifierKind to its corresponding AnnotationMirror.
      • qualifiers

        protected final java.util.Set<? extends javax.lang.model.element.AnnotationMirror> qualifiers
        Set of all annotations in all the hierarchies.
    • Constructor Detail

      • NoElementQualifierHierarchy

        public NoElementQualifierHierarchy​(java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> qualifierClasses,
                                           javax.lang.model.util.Elements elements,
                                           GenericAnnotatedTypeFactory<?,​?,​?,​?> atypeFactory)
        Creates a NoElementQualifierHierarchy from the given classes.
        Parameters:
        qualifierClasses - classes of annotations that are the qualifiers
        elements - element utils
        atypeFactory - the associated type factory
    • Method Detail

      • createQualifierKindHierarchy

        protected QualifierKindHierarchy createQualifierKindHierarchy​(@UnderInitialization NoElementQualifierHierarchy this,
                                                                      java.util.Collection<java.lang.Class<? extends java.lang.annotation.Annotation>> qualifierClasses)
        Create the QualifierKindHierarchy. (Subclasses may override to return a subclass of QualifierKindHierarchy.)
        Parameters:
        qualifierClasses - classes of annotations that are the qualifiers
        Returns:
        the newly created qualifier kind hierarchy
      • createAnnotationMirrors

        @RequiresNonNull("this.qualifierKindHierarchy")
        protected java.util.Map<QualifierKind,​javax.lang.model.element.AnnotationMirror> createAnnotationMirrors​(@UnderInitialization NoElementQualifierHierarchy this,
                                                                                                                       javax.lang.model.util.Elements elements)
        Creates and returns a mapping from qualifier kind to an annotation mirror created from the qualifier kind's annotation class.
        Parameters:
        elements - element utils
        Returns:
        a mapping from qualifier kind to its annotation mirror
      • createTops

        @RequiresNonNull({"this.kindToAnnotationMirror","this.qualifierKindHierarchy"})
        protected AnnotationMirrorSet createTops​(@UnderInitialization NoElementQualifierHierarchy this)
        Creates and returns the unmodifiable set of top AnnotationMirrors.
        Returns:
        the unmodifiable set of top AnnotationMirrors
      • createBottoms

        @RequiresNonNull({"this.kindToAnnotationMirror","this.qualifierKindHierarchy"})
        protected AnnotationMirrorSet createBottoms​(@UnderInitialization NoElementQualifierHierarchy this)
        Creates and returns the unmodifiable set of bottom AnnotationMirrors.
        Returns:
        the unmodifiable set of bottom AnnotationMirrors
      • getQualifierKind

        protected QualifierKind getQualifierKind​(javax.lang.model.element.AnnotationMirror anno)
        Returns the QualifierKind for the given annotation.
        Parameters:
        anno - an annotation that is a qualifier in this
        Returns:
        the QualifierKind for the given annotation
      • findAnnotationInHierarchy

        public @Nullable javax.lang.model.element.AnnotationMirror findAnnotationInHierarchy​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> annos,
                                                                                             javax.lang.model.element.AnnotationMirror top)
        Description copied from class: QualifierHierarchy
        Returns the annotation in qualifiers that is in the hierarchy for which top is top.
        Overrides:
        findAnnotationInHierarchy in class QualifierHierarchy
        Parameters:
        annos - set of annotations to search
        top - the top annotation in the hierarchy to which the returned annotation belongs
        Returns:
        annotation in the same hierarchy as annotationMirror, or null if one is not found
      • getTopAnnotation

        public javax.lang.model.element.AnnotationMirror getTopAnnotation​(javax.lang.model.element.AnnotationMirror start)
        Description copied from class: QualifierHierarchy
        Return the top qualifier for the given qualifier, that is, the qualifier that is a supertype of qualifier but no further supertypes exist.
        Specified by:
        getTopAnnotation in class QualifierHierarchy
        Parameters:
        start - any qualifier from one of the qualifier hierarchies represented by this
        Returns:
        the top qualifier of qualifier's hierarchy
      • getBottomAnnotation

        public javax.lang.model.element.AnnotationMirror getBottomAnnotation​(javax.lang.model.element.AnnotationMirror start)
        Description copied from class: QualifierHierarchy
        Return the bottom for the given qualifier, that is, the qualifier that is a subtype of qualifier but no further subtypes exist.
        Specified by:
        getBottomAnnotation in class QualifierHierarchy
        Parameters:
        start - any qualifier from one of the qualifier hierarchies represented by this
        Returns:
        the bottom qualifier of qualifier's hierarchy
      • getPolymorphicAnnotation

        public @Nullable javax.lang.model.element.AnnotationMirror getPolymorphicAnnotation​(javax.lang.model.element.AnnotationMirror start)
        Description copied from class: QualifierHierarchy
        Returns the polymorphic qualifier for the hierarchy containing qualifier, or null if there is no polymorphic qualifier in that hierarchy.
        Specified by:
        getPolymorphicAnnotation in class QualifierHierarchy
        Parameters:
        start - any qualifier from one of the qualifier hierarchies represented by this
        Returns:
        the polymorphic qualifier for the hierarchy containing qualifier, or null if there is no polymorphic qualifier in that hierarchy
      • isPolymorphicQualifier

        public boolean isPolymorphicQualifier​(javax.lang.model.element.AnnotationMirror qualifier)
        Description copied from class: QualifierHierarchy
        Returns true if the qualifier is a polymorphic qualifier; otherwise, returns false.
        Specified by:
        isPolymorphicQualifier in class QualifierHierarchy
        Parameters:
        qualifier - qualifier
        Returns:
        true if the qualifier is a polymorphic qualifier; otherwise, returns false.
      • leastUpperBoundQualifiers

        public @Nullable javax.lang.model.element.AnnotationMirror leastUpperBoundQualifiers​(javax.lang.model.element.AnnotationMirror a1,
                                                                                             javax.lang.model.element.AnnotationMirror a2)
        Description copied from class: QualifierHierarchy
        Returns the least upper bound (LUB) of the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy. Ignores Java basetypes.

        Examples:

        • For NonNull, leastUpperBound('Nullable', 'NonNull') ⇒ Nullable
        Specified by:
        leastUpperBoundQualifiers in class QualifierHierarchy
        Parameters:
        a1 - the first qualifier; may not be in the same hierarchy as qualifier2
        a2 - the second qualifier; may not be in the same hierarchy as qualifier1
        Returns:
        the least upper bound of the qualifiers, or null if the qualifiers are from different hierarchies
      • greatestLowerBoundQualifiers

        public @Nullable javax.lang.model.element.AnnotationMirror greatestLowerBoundQualifiers​(javax.lang.model.element.AnnotationMirror a1,
                                                                                                javax.lang.model.element.AnnotationMirror a2)
        Description copied from class: QualifierHierarchy
        Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.
        Specified by:
        greatestLowerBoundQualifiers in class QualifierHierarchy
        Parameters:
        a1 - first qualifier
        a2 - second qualifier
        Returns:
        greatest lower bound of the two annotations, or null if the two annotations are not from the same hierarchy