Class QualifierHierarchy

  • Direct Known Subclasses:
    ElementQualifierHierarchy, NoElementQualifierHierarchy

    @AnnotatedFor("nullness")
    public abstract class QualifierHierarchy
    extends java.lang.Object
    Represents multiple type qualifier hierarchies. getWidth() gives the number of hierarchies that this object represents. Each hierarchy has its own top and bottom, and subtyping relationships exist only within each hierarchy.

    Note the distinction in terminology between a qualifier hierarchy, which has one top and one bottom, and a QualifierHierarchy, which represents multiple qualifier hierarchies.

    All type annotations need to be type qualifiers recognized within this hierarchy.

    This assumes that every annotated type in a program is annotated with exactly one qualifier from each hierarchy.

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static void assertSameSize​(java.util.Collection<? extends java.lang.Object> c1, java.util.Collection<? extends java.lang.Object> c2, java.util.Collection<? extends java.lang.Object> result)
      Throws an exception if the result and the inputs do not all have the same size.
      static void assertSameSize​(java.util.Collection<?> c1, java.util.Collection<?> c2)
      Throws an exception if the given collections do not have the same size.
      static boolean canHaveEmptyAnnotationSet​(AnnotatedTypeMirror type)
      Returns true if and only if AnnotatedTypeMirror.getAnnotations() can return a set with fewer qualifiers than the width of the QualifierHierarchy.
      @Nullable javax.lang.model.element.AnnotationMirror findAnnotationInHierarchy​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers, javax.lang.model.element.AnnotationMirror top)
      Returns the annotation in qualifiers that is in the hierarchy for which top is top.
      @Nullable javax.lang.model.element.AnnotationMirror findAnnotationInSameHierarchy​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers, javax.lang.model.element.AnnotationMirror qualifier)
      Returns the annotation in qualifiers that is in the same hierarchy as qualifier.
      abstract javax.lang.model.element.AnnotationMirror getBottomAnnotation​(javax.lang.model.element.AnnotationMirror qualifier)
      Return the bottom for the given qualifier, that is, the qualifier that is a subtype of qualifier but no further subtypes exist.
      abstract AnnotationMirrorSet getBottomAnnotations()
      Returns the bottom type qualifiers in the hierarchy.
      abstract @Nullable javax.lang.model.element.AnnotationMirror getPolymorphicAnnotation​(javax.lang.model.element.AnnotationMirror qualifier)
      Returns the polymorphic qualifier for the hierarchy containing qualifier, or null if there is no polymorphic qualifier in that hierarchy.
      abstract javax.lang.model.element.AnnotationMirror getTopAnnotation​(javax.lang.model.element.AnnotationMirror qualifier)
      Return the top qualifier for the given qualifier, that is, the qualifier that is a supertype of qualifier but no further supertypes exist.
      abstract AnnotationMirrorSet getTopAnnotations()
      Returns the top (ultimate super) type qualifiers in the type system.
      int getWidth()
      Returns the width of this hierarchy, i.e.
      protected abstract @Nullable javax.lang.model.element.AnnotationMirror greatestLowerBoundQualifiers​(javax.lang.model.element.AnnotationMirror qualifier1, javax.lang.model.element.AnnotationMirror qualifier2)
      Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.
      @Nullable javax.lang.model.element.AnnotationMirror greatestLowerBoundQualifiersOnly​(javax.lang.model.element.AnnotationMirror qualifier1, javax.lang.model.element.AnnotationMirror qualifier2)
      Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.
      @Nullable javax.lang.model.element.AnnotationMirror greatestLowerBoundShallow​(javax.lang.model.element.AnnotationMirror qualifier1, javax.lang.model.type.TypeMirror tm1, javax.lang.model.element.AnnotationMirror qualifier2, javax.lang.model.type.TypeMirror tm2)
      Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2.
      java.util.Set<? extends javax.lang.model.element.AnnotationMirror> greatestLowerBoundsShallow​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers1, javax.lang.model.type.TypeMirror tm1, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers2, javax.lang.model.type.TypeMirror tm2)
      Returns the greatest lower bound of the two sets of qualifiers.
      abstract boolean isPolymorphicQualifier​(javax.lang.model.element.AnnotationMirror qualifier)
      Returns true if the qualifier is a polymorphic qualifier; otherwise, returns false.
      protected abstract boolean isSubtypeQualifiers​(javax.lang.model.element.AnnotationMirror subQualifier, javax.lang.model.element.AnnotationMirror superQualifier)
      Tests whether subQualifier is equal to or a sub-qualifier of superQualifier, according to the type qualifier hierarchy, ignoring Java basetypes.
      boolean isSubtypeQualifiersOnly​(javax.lang.model.element.AnnotationMirror subQualifier, javax.lang.model.element.AnnotationMirror superQualifier)
      Tests whether subQualifier is equal to or a sub-qualifier of superQualifier, according to the type qualifier hierarchy, ignoring Java basetypes.
      boolean isSubtypeShallow​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> subQualifiers, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> superQualifiers, javax.lang.model.type.TypeMirror typeMirror)
      Tests whether all qualifiers in subQualifiers are a subqualifier of or equal to the qualifier in the same hierarchy in superQualifiers.
      boolean isSubtypeShallow​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> subQualifiers, javax.lang.model.type.TypeMirror subType, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> superQualifiers, javax.lang.model.type.TypeMirror superType)
      Tests whether all qualifiers in subQualifiers are a subqualifier or equal to the qualifier in the same hierarchy in superQualifiers.
      boolean isSubtypeShallow​(javax.lang.model.element.AnnotationMirror subQualifier, javax.lang.model.element.AnnotationMirror superQualifier, javax.lang.model.type.TypeMirror typeMirror)
      Tests whether subQualifier is equal to or a sub-qualifier of superQualifier, according to the type qualifier hierarchy.
      boolean isSubtypeShallow​(javax.lang.model.element.AnnotationMirror subQualifier, javax.lang.model.type.TypeMirror subType, javax.lang.model.element.AnnotationMirror superQualifier, javax.lang.model.type.TypeMirror superType)
      Tests whether subQualifier is equal to or a sub-qualifier of superQualifier, according to the type qualifier hierarchy.
      boolean isValid()
      Determine whether this is valid.
      protected abstract @Nullable javax.lang.model.element.AnnotationMirror leastUpperBoundQualifiers​(javax.lang.model.element.AnnotationMirror qualifier1, javax.lang.model.element.AnnotationMirror qualifier2)
      Returns the least upper bound (LUB) of the qualifiers qualifier1 and qualifier2.
      @Nullable javax.lang.model.element.AnnotationMirror leastUpperBoundQualifiersOnly​(javax.lang.model.element.AnnotationMirror qualifier1, javax.lang.model.element.AnnotationMirror qualifier2)
      Returns the least upper bound (LUB) of the qualifiers qualifier1 and qualifier2.
      @Nullable javax.lang.model.element.AnnotationMirror leastUpperBoundShallow​(javax.lang.model.element.AnnotationMirror qualifier1, javax.lang.model.type.TypeMirror tm1, javax.lang.model.element.AnnotationMirror qualifier2, javax.lang.model.type.TypeMirror tm2)
      Returns the least upper bound (LUB) of the qualifiers qualifier1 and qualifier2.
      java.util.Set<? extends javax.lang.model.element.AnnotationMirror> leastUpperBoundsShallow​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers1, javax.lang.model.type.TypeMirror tm1, java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers2, javax.lang.model.type.TypeMirror tm2)
      Returns the least upper bound of the two sets of qualifiers.
      int numberOfIterationsBeforeWidening()
      Returns the number of iterations dataflow should perform before widenedUpperBound(AnnotationMirror, AnnotationMirror) is called or -1 if it should never be called.
      <T> boolean updateMappingToMutableSet​(java.util.Map<T,​AnnotationMirrorSet> map, T key, javax.lang.model.element.AnnotationMirror qualifier)
      Update a mapping from key to a set of AnnotationMirrors.
      javax.lang.model.element.AnnotationMirror widenedUpperBound​(javax.lang.model.element.AnnotationMirror newQualifier, javax.lang.model.element.AnnotationMirror previousQualifier)
      If the qualifier hierarchy has an infinite ascending chain, then the dataflow analysis might never reach a fixed point.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • atypeFactory

        protected GenericAnnotatedTypeFactory<?,​?,​?,​?> atypeFactory
        The associated type factory. This is used only for checking whether types are relevant.
    • Constructor Detail

      • QualifierHierarchy

        public QualifierHierarchy​(GenericAnnotatedTypeFactory<?,​?,​?,​?> atypeFactory)
        Creates a new QualifierHierarchy.
        Parameters:
        atypeFactory - the associated type factory
    • Method Detail

      • isValid

        public boolean isValid()
        Determine whether this is valid.
        Returns:
        true if this is valid
      • getWidth

        public int getWidth()
        Returns the width of this hierarchy, i.e. the expected number of annotations on any valid type.
        Returns:
        the width of this QualifierHierarchy
      • getTopAnnotations

        public abstract AnnotationMirrorSet getTopAnnotations()
        Returns the top (ultimate super) type qualifiers in the type system. The size of this set is equal to getWidth().
        Returns:
        the top (ultimate super) type qualifiers in the type system
      • getTopAnnotation

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

        public abstract AnnotationMirrorSet getBottomAnnotations()
        Returns the bottom type qualifiers in the hierarchy. The size of this set is equal to getWidth().
        Returns:
        the bottom type qualifiers in the hierarchy
      • getBottomAnnotation

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

        public abstract @Nullable javax.lang.model.element.AnnotationMirror getPolymorphicAnnotation​(javax.lang.model.element.AnnotationMirror qualifier)
        Returns the polymorphic qualifier for the hierarchy containing qualifier, or null if there is no polymorphic qualifier in that hierarchy.
        Parameters:
        qualifier - 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 abstract boolean isPolymorphicQualifier​(javax.lang.model.element.AnnotationMirror qualifier)
        Returns true if the qualifier is a polymorphic qualifier; otherwise, returns false.
        Parameters:
        qualifier - qualifier
        Returns:
        true if the qualifier is a polymorphic qualifier; otherwise, returns false.
      • isSubtypeQualifiersOnly

        public final boolean isSubtypeQualifiersOnly​(javax.lang.model.element.AnnotationMirror subQualifier,
                                                     javax.lang.model.element.AnnotationMirror superQualifier)
        Tests whether subQualifier is equal to or a sub-qualifier of superQualifier, according to the type qualifier hierarchy, ignoring Java basetypes.

        This method is for clients outside the framework, and should not be used by framework code.

        Parameters:
        subQualifier - possible subqualifier
        superQualifier - possible superqualifier
        Returns:
        true iff subQualifier is a subqualifier of, or equal to, superQualifier
      • isSubtypeShallow

        public boolean isSubtypeShallow​(javax.lang.model.element.AnnotationMirror subQualifier,
                                        javax.lang.model.type.TypeMirror subType,
                                        javax.lang.model.element.AnnotationMirror superQualifier,
                                        javax.lang.model.type.TypeMirror superType)
        Tests whether subQualifier is equal to or a sub-qualifier of superQualifier, according to the type qualifier hierarchy. The types subType and superType are not necessarily in a Java subtyping relationship with one another and are only used by this method for special cases when qualifier subtyping depends on the Java basetype.

        Clients should usually call isSubtypeShallow() (this method). Rarely, to ignore the Java basetype, a client can call isSubtypeQualifiersOnly(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror).

        Subtypes should override isSubtypeQualifiers(javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationMirror) (not this method), unless qualifier subtyping depends on Java basetypes.

        Parameters:
        subQualifier - possible subqualifier
        subType - the Java basetype associated with subQualifier
        superQualifier - possible superqualifier
        superType - the Java basetype associated with superQualifier
        Returns:
        true iff subQualifier is a subqualifier of, or equal to, superQualifier
      • isSubtypeShallow

        public final boolean isSubtypeShallow​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> subQualifiers,
                                              javax.lang.model.type.TypeMirror subType,
                                              java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> superQualifiers,
                                              javax.lang.model.type.TypeMirror superType)
        Tests whether all qualifiers in subQualifiers are a subqualifier or equal to the qualifier in the same hierarchy in superQualifiers. The types subType and superType are not necessarily in a Java subtyping relationship with one another and are only used by this method for special cases when qualifier subtyping depends on the Java basetype.

        Subtypes more often override isSubtypeShallow(AnnotationMirror, TypeMirror, AnnotationMirror, TypeMirror) than this method.

        Parameters:
        subQualifiers - set of qualifiers; exactly one per hierarchy
        subType - the type associated with subQualifiers
        superQualifiers - set of qualifiers; exactly one per hierarchy
        superType - the type associated with superQualifiers
        Returns:
        true iff all qualifiers in subQualifiers are a subqualifier or equal to the qualifier in the same hierarchy in superQualifiers
      • isSubtypeShallow

        public final boolean isSubtypeShallow​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> subQualifiers,
                                              java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> superQualifiers,
                                              javax.lang.model.type.TypeMirror typeMirror)
        Tests whether all qualifiers in subQualifiers are a subqualifier of or equal to the qualifier in the same hierarchy in superQualifiers. The type typeMirror is only used by this method for special cases when qualifier subtyping depends on the Java basetype.

        Subtypes more often override isSubtypeShallow(AnnotationMirror, TypeMirror, AnnotationMirror, TypeMirror) than this method.

        Parameters:
        subQualifiers - a set of qualifiers; exactly one per hierarchy
        superQualifiers - a set of qualifiers; exactly one per hierarchy
        typeMirror - the type associated with both sets of qualifiers
        Returns:
        true iff all qualifiers in subQualifiers are a subqualifier or equal to the qualifier in the same hierarchy in superQualifiers
      • leastUpperBoundQualifiers

        protected abstract @Nullable javax.lang.model.element.AnnotationMirror leastUpperBoundQualifiers​(javax.lang.model.element.AnnotationMirror qualifier1,
                                                                                                         javax.lang.model.element.AnnotationMirror qualifier2)
        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
        Parameters:
        qualifier1 - the first qualifier; may not be in the same hierarchy as qualifier2
        qualifier2 - 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
      • leastUpperBoundQualifiersOnly

        public final @Nullable javax.lang.model.element.AnnotationMirror leastUpperBoundQualifiersOnly​(javax.lang.model.element.AnnotationMirror qualifier1,
                                                                                                       javax.lang.model.element.AnnotationMirror qualifier2)
        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
        Parameters:
        qualifier1 - the first qualifier; may not be in the same hierarchy as qualifier2
        qualifier2 - 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
      • leastUpperBoundShallow

        public @Nullable javax.lang.model.element.AnnotationMirror leastUpperBoundShallow​(javax.lang.model.element.AnnotationMirror qualifier1,
                                                                                          javax.lang.model.type.TypeMirror tm1,
                                                                                          javax.lang.model.element.AnnotationMirror qualifier2,
                                                                                          javax.lang.model.type.TypeMirror tm2)
        Returns the least upper bound (LUB) of the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.

        Examples:

        • leastUpperBound('Nullable', 'NonNull') ⇒ Nullable
        Parameters:
        qualifier1 - the first qualifier; may not be in the same hierarchy as qualifier2
        tm1 - the type on which qualifier1 appears
        qualifier2 - the second qualifier; may not be in the same hierarchy as qualifier1
        tm2 - the type on which qualifier2 appears
        Returns:
        the least upper bound of the qualifiers, or null if the qualifiers are from different hierarchies
      • leastUpperBoundsShallow

        public final java.util.Set<? extends javax.lang.model.element.AnnotationMirror> leastUpperBoundsShallow​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers1,
                                                                                                                javax.lang.model.type.TypeMirror tm1,
                                                                                                                java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers2,
                                                                                                                javax.lang.model.type.TypeMirror tm2)
        Returns the least upper bound of the two sets of qualifiers. The result is the lub of the qualifier for the same hierarchy in each set.
        Parameters:
        qualifiers1 - set of qualifiers; exactly one per hierarchy
        tm1 - the type on which qualifiers1 appear
        qualifiers2 - set of qualifiers; exactly one per hierarchy
        tm2 - the type on which qualifiers2 appear
        Returns:
        the least upper bound of the two sets of qualifiers
      • widenedUpperBound

        public javax.lang.model.element.AnnotationMirror widenedUpperBound​(javax.lang.model.element.AnnotationMirror newQualifier,
                                                                           javax.lang.model.element.AnnotationMirror previousQualifier)
        If the qualifier hierarchy has an infinite ascending chain, then the dataflow analysis might never reach a fixed point. To prevent this, implement this method such that it returns an upper bound for the two qualifiers that is a strict super type of the least upper bound. If this method is implemented, also override numberOfIterationsBeforeWidening() to return a positive number.

        newQualifier is newest qualifier dataflow computed for some expression and previousQualifier is the qualifier dataflow computed on the last iteration.

        If the qualifier hierarchy has no infinite ascending chain, returns the least upper bound of the two annotations.

        Parameters:
        newQualifier - new qualifier dataflow computed for some expression; must be in the same hierarchy as previousQualifier
        previousQualifier - the previous qualifier dataflow computed on the last iteration; must be in the same hierarchy as previousQualifier
        Returns:
        an upper bound that is higher than the least upper bound of newQualifier and previousQualifier (or the lub if the qualifier hierarchy does not require this)
      • greatestLowerBoundQualifiers

        protected abstract @Nullable javax.lang.model.element.AnnotationMirror greatestLowerBoundQualifiers​(javax.lang.model.element.AnnotationMirror qualifier1,
                                                                                                            javax.lang.model.element.AnnotationMirror qualifier2)
        Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.
        Parameters:
        qualifier1 - first qualifier
        qualifier2 - second qualifier
        Returns:
        greatest lower bound of the two annotations, or null if the two annotations are not from the same hierarchy
      • greatestLowerBoundQualifiersOnly

        public final @Nullable javax.lang.model.element.AnnotationMirror greatestLowerBoundQualifiersOnly​(javax.lang.model.element.AnnotationMirror qualifier1,
                                                                                                          javax.lang.model.element.AnnotationMirror qualifier2)
        Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.
        Parameters:
        qualifier1 - first qualifier
        qualifier2 - second qualifier
        Returns:
        greatest lower bound of the two annotations, or null if the two annotations are not from the same hierarchy
      • greatestLowerBoundShallow

        public @Nullable javax.lang.model.element.AnnotationMirror greatestLowerBoundShallow​(javax.lang.model.element.AnnotationMirror qualifier1,
                                                                                             javax.lang.model.type.TypeMirror tm1,
                                                                                             javax.lang.model.element.AnnotationMirror qualifier2,
                                                                                             javax.lang.model.type.TypeMirror tm2)
        Returns the greatest lower bound for the qualifiers qualifier1 and qualifier2. Returns null if the qualifiers are not from the same qualifier hierarchy.
        Parameters:
        qualifier1 - first qualifier
        tm1 - the type that is annotated by qualifier1
        qualifier2 - second qualifier
        tm2 - the type that is annotated by qualifier2
        Returns:
        greatest lower bound of the two annotations, or null if the two annotations are not from the same hierarchy
      • greatestLowerBoundsShallow

        public final java.util.Set<? extends javax.lang.model.element.AnnotationMirror> greatestLowerBoundsShallow​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers1,
                                                                                                                   javax.lang.model.type.TypeMirror tm1,
                                                                                                                   java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers2,
                                                                                                                   javax.lang.model.type.TypeMirror tm2)
        Returns the greatest lower bound of the two sets of qualifiers. The result is the lub of the qualifier for the same hierarchy in each set.
        Parameters:
        qualifiers1 - set of qualifiers; exactly one per hierarchy
        tm1 - the type that is annotated by qualifier1
        qualifiers2 - set of qualifiers; exactly one per hierarchy
        tm2 - the type that is annotated by qualifier2
        Returns:
        the greatest lower bound of the two sets of qualifiers
      • findAnnotationInSameHierarchy

        public @Nullable javax.lang.model.element.AnnotationMirror findAnnotationInSameHierarchy​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers,
                                                                                                 javax.lang.model.element.AnnotationMirror qualifier)
        Returns the annotation in qualifiers that is in the same hierarchy as qualifier.

        The default implementation calls getTopAnnotation(AnnotationMirror) and then calls findAnnotationInHierarchy(Collection, AnnotationMirror). So, if qualifier is a top qualifier, then call findAnnotationInHierarchy(Collection, AnnotationMirror) directly is faster.

        Parameters:
        qualifiers - set of annotations to search
        qualifier - annotation that is in the same hierarchy as the returned annotation
        Returns:
        annotation in the same hierarchy as qualifier, or null if one is not found
      • findAnnotationInHierarchy

        public @Nullable javax.lang.model.element.AnnotationMirror findAnnotationInHierarchy​(java.util.Collection<? extends javax.lang.model.element.AnnotationMirror> qualifiers,
                                                                                             javax.lang.model.element.AnnotationMirror top)
        Returns the annotation in qualifiers that is in the hierarchy for which top is top.
        Parameters:
        qualifiers - 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
      • updateMappingToMutableSet

        public <T> boolean updateMappingToMutableSet​(java.util.Map<T,​AnnotationMirrorSet> map,
                                                     T key,
                                                     javax.lang.model.element.AnnotationMirror qualifier)
        Update a mapping from key to a set of AnnotationMirrors. If key is not already in the map, then put it in the map with a value of a new set containing qualifier. If the map contains key, then add qualifier to the set to which key maps. If that set contains a qualifier in the same hierarchy as qualifier, then don't add it and return false.
        Type Parameters:
        T - type of the map's keys
        Parameters:
        map - the mapping to modify
        key - the key to update or add
        qualifier - the value to update or add
        Returns:
        true if the update was done; false if there was a qualifier hierarchy collision
      • assertSameSize

        public static void assertSameSize​(java.util.Collection<?> c1,
                                          java.util.Collection<?> c2)
        Throws an exception if the given collections do not have the same size.
        Parameters:
        c1 - the first collection
        c2 - the second collection
      • assertSameSize

        public static void assertSameSize​(java.util.Collection<? extends java.lang.Object> c1,
                                          java.util.Collection<? extends java.lang.Object> c2,
                                          java.util.Collection<? extends java.lang.Object> result)
        Throws an exception if the result and the inputs do not all have the same size.
        Parameters:
        c1 - the first collection
        c2 - the second collection
        result - the result collection