Class AnnotatedTypeMirror.AnnotatedTypeVariable

java.lang.Object
org.checkerframework.framework.type.AnnotatedTypeMirror
org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedTypeVariable
All Implemented Interfaces:
org.plumelib.util.DeepCopyable<AnnotatedTypeMirror>
Enclosing class:
AnnotatedTypeMirror

public static class AnnotatedTypeMirror.AnnotatedTypeVariable extends AnnotatedTypeMirror
Represents a type variable. A type variable may be explicitly declared by a type parameter of a type, method, or constructor. A type variable may also be declared implicitly, as by the capture conversion of a wildcard type argument (see chapter 5 of The Java Language Specification, Third Edition).
  • Method Details

    • isDeclaration

      public boolean isDeclaration()
      Description copied from class: AnnotatedTypeMirror
      Returns true if this type mirror represents a declaration, rather than a use, of a type.

      For example, class List<T> { ... } declares a new type List<T>, while List<Integer> is a use of the type.

      Overrides:
      isDeclaration in class AnnotatedTypeMirror
      Returns:
      true if this represents a declaration
    • addAnnotation

      public void addAnnotation(AnnotationMirror annotation)
      Description copied from class: AnnotatedTypeMirror
      Adds the canonical version of annotation as a primary annotation of this type and, in the case of AnnotatedTypeMirror.AnnotatedTypeVariables, AnnotatedTypeMirror.AnnotatedWildcardTypes, and AnnotatedTypeMirror.AnnotatedIntersectionTypes, adds it to all bounds. (The canonical version is found via AnnotatedTypeFactory.canonicalAnnotation(javax.lang.model.element.AnnotationMirror).) If the canonical version of annotation is not a supported qualifier, then no annotation is added. If this type already has annotation in the same hierarchy as annotation, the behavior of this method is undefined.
      Overrides:
      addAnnotation in class AnnotatedTypeMirror
      Parameters:
      annotation - the annotation to add
    • setDeclaration

      public void setDeclaration(boolean declaration)
      Change whether this AnnotatedTypeVariable is considered a use or a declaration (use this method with caution).
      Parameters:
      declaration - true if this type variable should be considered a declaration
    • asUse

      Overrides:
      asUse in class AnnotatedTypeMirror
    • accept

      public <R, P> R accept(AnnotatedTypeVisitor<R,P> v, P p)
      Description copied from class: AnnotatedTypeMirror
      Applies a visitor to this type.
      Specified by:
      accept in class AnnotatedTypeMirror
      Type Parameters:
      R - the return type of the visitor's methods
      P - the type of the additional parameter to the visitor's methods
      Parameters:
      v - the visitor operating on this type
      p - additional parameter to the visitor
      Returns:
      a visitor-specified result
    • getUnderlyingType

      public TypeVariable getUnderlyingType()
      Description copied from class: AnnotatedTypeMirror
      Returns the underlying unannotated Java type, which this wraps.
      Overrides:
      getUnderlyingType in class AnnotatedTypeMirror
      Returns:
      the underlying type
    • getLowerBoundField

      public AnnotatedTypeMirror getLowerBoundField()
      Get the lower bound field directly, bypassing any lazy initialization. This method is necessary to prevent infinite recursions in initialization. In general, prefer getLowerBound.
      Returns:
      the lower bound field
    • getLowerBound

      public AnnotatedTypeMirror getLowerBound()
      Returns the lower bound type of this type variable.
      Returns:
      the lower bound type of this type variable
    • getUpperBoundField

      public AnnotatedTypeMirror getUpperBoundField()
      Get the upper bound field directly, bypassing any lazy initialization. This method is necessary to prevent infinite recursions in initialization. In general, prefer getUpperBound.
      Returns:
      the upper bound field
    • getUpperBound

      public AnnotatedTypeMirror getUpperBound()
      Get the upper bound of the type variable, possibly lazily initializing it. Attention: If the upper bound is lazily initialized, it will not contain any annotations! Callers of the method have to make sure that an AnnotatedTypeFactory first processed the bound.
      Returns:
      the upper bound type of this type variable
    • getBounds

      public AnnotatedTypeParameterBounds getBounds()
    • getBoundFields

      public AnnotatedTypeParameterBounds getBoundFields()
    • deepCopy

      public AnnotatedTypeMirror.AnnotatedTypeVariable deepCopy(boolean copyAnnotations)
      Description copied from class: AnnotatedTypeMirror
      Returns a deep copy of this type. A deep copy implies that each component type is copied recursively and the returned type refers to those copies in its component locations.

      Note: deepCopy provides two important properties in the returned copy:

      1. Structure preservation -- The exact structure of the original AnnotatedTypeMirror is preserved in the copy including all component types.
      2. Annotation preservation -- All of the annotations from the original AnnotatedTypeMirror and its components have been copied to the new type.
      If copyAnnotations is set to false, the second property, Annotation preservation, is removed. This is useful for cases in which the user may want to copy the structure of a type exactly but NOT its annotations.
      Specified by:
      deepCopy in class AnnotatedTypeMirror
      Returns:
      a deep copy
    • deepCopy

      Description copied from class: AnnotatedTypeMirror
      Returns a deep copy of this type with annotations.

      Each subclass implements this method with the subclass return type. The method body must always be a call to deepCopy(true).

      Specified by:
      deepCopy in interface org.plumelib.util.DeepCopyable<AnnotatedTypeMirror>
      Specified by:
      deepCopy in class AnnotatedTypeMirror
      Returns:
      a deep copy of this type with annotations
      See Also:
    • shallowCopy

      public AnnotatedTypeMirror.AnnotatedTypeVariable shallowCopy(boolean copyAnnotations)
      Description copied from class: AnnotatedTypeMirror
      Returns a shallow copy of this type. A shallow copy implies that each component type in the output copy refers to the same object as the object being copied.
      Specified by:
      shallowCopy in class AnnotatedTypeMirror
      Parameters:
      copyAnnotations - whether copy should have annotations, i.e. whether field annotations should be copied.
    • shallowCopy

      Description copied from class: AnnotatedTypeMirror
      Returns a shallow copy of this type with annotations.

      Each subclass implements this method with the subclass return type. The method body must always be a call to shallowCopy(true).

      Specified by:
      shallowCopy in class AnnotatedTypeMirror
      Returns:
      a shallow copy of this type with annotations
      See Also:
    • getErased

      public AnnotatedTypeMirror getErased()
      This method will traverse the upper bound of this type variable calling getErased until it finds the concrete upper bound. e.g.
       <E extends T>, T extends S, S extends List<String>>
      A call to getErased will return the type List
      Overrides:
      getErased in class AnnotatedTypeMirror
      Returns:
      the erasure of the upper bound of this type

      IMPORTANT NOTE: getErased should always return a FRESH object. This will occur for type variables if all other getErased methods are implemented appropriately. Therefore, to avoid extra copy calls, this method will not call deepCopy on getUpperBound

      See Also: