Class AnnotatedTypeMirror.AnnotatedDeclaredType

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

        public AnnotatedTypeMirror.AnnotatedDeclaredType 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
      • 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
      • setTypeArguments

        public void setTypeArguments​(java.util.List<? extends AnnotatedTypeMirror> ts)
        Sets the type arguments on this type.
        Parameters:
        ts - a list of type arguments to be captured by this method
      • getTypeArguments

        public java.util.List<AnnotatedTypeMirror> getTypeArguments()
        Returns the type argument for this type.
        Returns:
        the type argument for this type
      • isUnderlyingTypeRaw

        public boolean isUnderlyingTypeRaw()
        Returns true if the underlying type is raw. The receiver of this method is not raw, however; its annotated type arguments have been inferred.
        Returns:
        true iff the type was raw
      • wasRaw

        @Deprecated
        public boolean wasRaw()
        Deprecated.
        Returns true if the underlying type is raw. The receiver of this method is not raw, however; its annotated type arguments have been inferred.
        Returns:
        true iff the type was raw
      • setIsUnderlyingTypeRaw

        protected void setIsUnderlyingTypeRaw()
        Set the isUnderlyingTypeRaw flag to true. This should only be necessary when determining the supertypes of a raw type.
      • setWasRaw

        @Deprecated
        protected void setWasRaw()
        Deprecated.
        Set the isUnderlyingTypeRaw flag to true. This should only be necessary when determining the supertypes of a raw type.
      • getUnderlyingType

        public javax.lang.model.type.DeclaredType getUnderlyingType()
        Description copied from class: AnnotatedTypeMirror
        Returns the underlying unannotated Java type, which this wraps.
        Overrides:
        getUnderlyingType in class AnnotatedTypeMirror
        Returns:
        the underlying type
      • directSupertypes

        public java.util.List<AnnotatedTypeMirror.AnnotatedDeclaredType> directSupertypes()
        Description copied from class: AnnotatedTypeMirror
        This method returns a list of AnnotatedTypeMirrors where the Java type of each ATM is an immediate supertype (class or interface) of the Java type of this. The interface types, if any, appear at the end of the list. If the directSuperType has type arguments, then the annotations on those type arguments are taken with proper translation from the declaration of the Java type of this.

        For example,

         class B<T> { ... } 
         class A extends B<@NonNull String> { ... } 
         @Nullable A a;
         
        The direct supertype of the ATM @Nullable A is @Nullable B<@NonNull String>.

        An example with more complex type arguments:

         class D<Q,R> { ... } 
         class A<T,S> extends D<S,T> { ... } 
         @Nullable A<@NonNull String, @NonNull Object> a;
         
        The direct supertype of the ATM @Nullable A<@NonNull String, @NonNull Object> is @Nullable B<@NonNull Object, @NonNull String>.

        An example with more than one direct supertype:

         class B<T> implements List<Integer> { ... } 
         class A extends B<@NonNull String> implements List<Integer> { ... } 
         @Nullable A a;
         
        The direct supertypes of the ATM @Nullable A are @Nullable B <@NonNull String> and @Nullable List<@NonNull Integer>.
        Overrides:
        directSupertypes in class AnnotatedTypeMirror
        Returns:
        the immediate supertypes of this
        See Also:
        Types.directSupertypes(TypeMirror)
      • shallowCopy

        public AnnotatedTypeMirror.AnnotatedDeclaredType 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.
      • getEnclosingType

        public @Nullable AnnotatedTypeMirror.AnnotatedDeclaredType getEnclosingType()
        Returns the enclosing type, as in the type of A in the type A.B. May return null.
        Returns:
        enclosingType the enclosing type, or null if this is a top-level type