Class DefaultQualifierForUseTypeAnnotator

All Implemented Interfaces:
AnnotatedTypeVisitor<Void,Void>

public class DefaultQualifierForUseTypeAnnotator extends TypeAnnotator
Implements support for DefaultQualifierForUse and NoDefaultQualifierForUse. Adds default annotations on types that have no annotation.
  • Field Details

    • elementToDefaults

      protected final Map<Element,AnnotationMirrorSet> elementToDefaults
      Cache of elements to the set of annotations that should be applied to unannotated uses of the element.
  • Constructor Details

    • DefaultQualifierForUseTypeAnnotator

      public DefaultQualifierForUseTypeAnnotator(AnnotatedTypeFactory typeFactory)
      Creates an DefaultQualifierForUseTypeAnnotator for typeFactory.
      Parameters:
      typeFactory - the type factory
  • Method Details

    • visitDeclared

      public Void visitDeclared(AnnotatedTypeMirror.AnnotatedDeclaredType type, Void aVoid)
      Description copied from interface: AnnotatedTypeVisitor
      Visits a declared type.
      Specified by:
      visitDeclared in interface AnnotatedTypeVisitor<Void,Void>
      Overrides:
      visitDeclared in class AnnotatedTypeScanner<Void,Void>
      Parameters:
      type - the type to visit
      aVoid - a visitor-specified parameter
      Returns:
      a visitor-specified result
    • clearCache

      public void clearCache()
      Clears all caches.
    • getDefaultAnnosForUses

      protected AnnotationMirrorSet getDefaultAnnosForUses(Element element)
      Returns the set of qualifiers that should be applied to unannotated uses of the given element
      Parameters:
      element - the element for which to determine default qualifiers
      Returns:
      the set of qualifiers that should be applied to unannotated uses of element
    • getExplicitAnnos

      protected AnnotationMirrorSet getExplicitAnnos(Element element)
      Return the annotations explicitly written on the element.
      Parameters:
      element - an element
      Returns:
      the annotations explicitly written on the element
    • getDefaultQualifierForUses

      protected AnnotationMirrorSet getDefaultQualifierForUses(Element element)
      Return the default qualifiers for uses of element as specified by a DefaultQualifierForUse annotation.

      Subclasses may override to use an annotation other than DefaultQualifierForUse.

      Parameters:
      element - an element
      Returns:
      the default qualifiers for uses of element
    • getHierarchiesNoDefault

      protected AnnotationMirrorSet getHierarchiesNoDefault(Element element)
      Returns top annotations in hierarchies for which no default for use qualifier should be added.
      Parameters:
      element - an element
      Returns:
      top annotations in hierarchies for which no default for use qualifier should be added
    • supportedAnnosFromAnnotationMirror

      protected final AnnotationMirrorSet supportedAnnosFromAnnotationMirror(List<@CanonicalName Name> annoClassNames)
      Returns the set of qualifiers supported by this type system from the value element of annotationMirror.
      Parameters:
      annoClassNames - a list of annotation class names
      Returns:
      the set of qualifiers supported by this type system from the value element of annotationMirror