Class 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 Detail

      • 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
      • removeAnnotation

        public boolean removeAnnotation​(javax.lang.model.element.AnnotationMirror a)
        Description copied from class: AnnotatedTypeMirror
        Removes a primary annotation from the type.
        Overrides:
        removeAnnotation in class AnnotatedTypeMirror
        Parameters:
        a - the annotation to remove
        Returns:
        true if the annotation was removed, false if the type's annotations were unchanged
      • 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
      • 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 javax.lang.model.type.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
      • 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
      • 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.
      • 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:
        https://docs.oracle.com/javase/specs/jls/se17/html/jls-4.html#jls-4.6