Class AnnotatedTypeMirror.AnnotatedTypeVariable
- All Implemented Interfaces:
org.plumelib.util.DeepCopyable<AnnotatedTypeMirror>
- Enclosing class:
- AnnotatedTypeMirror
-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
AnnotatedTypeMirror.AnnotatedArrayType, AnnotatedTypeMirror.AnnotatedDeclaredType, AnnotatedTypeMirror.AnnotatedExecutableType, AnnotatedTypeMirror.AnnotatedIntersectionType, AnnotatedTypeMirror.AnnotatedNoType, AnnotatedTypeMirror.AnnotatedNullType, AnnotatedTypeMirror.AnnotatedPrimitiveType, AnnotatedTypeMirror.AnnotatedTypeVariable, AnnotatedTypeMirror.AnnotatedUnionType, AnnotatedTypeMirror.AnnotatedWildcardType
-
Field Summary
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
atypeFactory, EQUALITY_COMPARER, HASHCODE_VISITOR, primaryAnnotations, underlyingType
-
Method Summary
Modifier and TypeMethodDescription<R,
P> R accept
(AnnotatedTypeVisitor<R, P> v, P p) Applies a visitor to this type.void
addAnnotation
(AnnotationMirror annotation) Adds the canonical version ofannotation
as a primary annotation of this type and, in the case ofAnnotatedTypeMirror.AnnotatedTypeVariable
s,AnnotatedTypeMirror.AnnotatedWildcardType
s, andAnnotatedTypeMirror.AnnotatedIntersectionType
s, adds it to all bounds.asUse()
deepCopy()
Returns a deep copy of this type with annotations.deepCopy
(boolean copyAnnotations) Returns a deep copy of this type.This method will traverse the upper bound of this type variable calling getErased until it finds the concrete upper bound.Returns the lower bound type of this type variable.Get the lower bound field directly, bypassing any lazy initialization.Returns the underlying unannotated Java type, which this wraps.Get the upper bound of the type variable, possibly lazily initializing it.Get the upper bound field directly, bypassing any lazy initialization.boolean
Returns true if this type mirror represents a declaration, rather than a use, of a type.void
setDeclaration
(boolean declaration) Change whether thisAnnotatedTypeVariable
is considered a use or a declaration (use this method with caution).void
Set the lower bound of this variable type.void
Set the upper bound of this variable type.Returns a shallow copy of this type with annotations.shallowCopy
(boolean copyAnnotations) Returns a shallow copy of this type.Methods inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
addAnnotation, addAnnotations, addMissingAnnotation, addMissingAnnotations, clearAnnotations, clearPrimaryAnnotations, containsCapturedTypes, createType, createTypeOfObject, createTypeOfRecord, directSupertypes, equals, getAnnotation, getAnnotation, getAnnotation, getAnnotationInHierarchy, getAnnotations, getAnnotationsField, getEffectiveAnnotation, getEffectiveAnnotation, getEffectiveAnnotationInHierarchy, getEffectiveAnnotations, getExplicitAnnotations, getKind, getPrimaryAnnotation, getPrimaryAnnotation, getPrimaryAnnotation, getPrimaryAnnotationInHierarchy, getPrimaryAnnotations, getPrimaryAnnotationsField, getPrimitiveKind, getUnderlyingTypeHashCode, hasAnnotation, hasAnnotation, hasAnnotationInHierarchy, hasAnnotationRelaxed, hasEffectiveAnnotation, hasEffectiveAnnotation, hasEffectiveAnnotationRelaxed, hasExplicitAnnotation, hasExplicitAnnotation, hasExplicitAnnotationRelaxed, hashCode, hasPrimaryAnnotation, hasPrimaryAnnotation, hasPrimaryAnnotationInHierarchy, hasPrimaryAnnotationRelaxed, isAnnotatedInHierarchy, removeAnnotation, removeAnnotationByClass, removeAnnotationInHierarchy, removeNonTopAnnotationInHierarchy, removePrimaryAnnotation, removePrimaryAnnotationByClass, removePrimaryAnnotationInHierarchy, removePrimaryAnnotations, replaceAnnotation, replaceAnnotations, toString, toString
-
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 typeList<T>
, whileList<Integer>
is a use of the type.- Overrides:
isDeclaration
in classAnnotatedTypeMirror
- Returns:
- true if this represents a declaration
-
addAnnotation
Description copied from class:AnnotatedTypeMirror
Adds the canonical version ofannotation
as a primary annotation of this type and, in the case ofAnnotatedTypeMirror.AnnotatedTypeVariable
s,AnnotatedTypeMirror.AnnotatedWildcardType
s, andAnnotatedTypeMirror.AnnotatedIntersectionType
s, adds it to all bounds. (The canonical version is found viaAnnotatedTypeFactory.canonicalAnnotation(javax.lang.model.element.AnnotationMirror)
.) If the canonical version ofannotation
is not a supported qualifier, then no annotation is added. If this type already has annotation in the same hierarchy asannotation
, the behavior of this method is undefined.- Overrides:
addAnnotation
in classAnnotatedTypeMirror
- Parameters:
annotation
- the annotation to add
-
setDeclaration
public void setDeclaration(boolean declaration) Change whether thisAnnotatedTypeVariable
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 classAnnotatedTypeMirror
-
accept
Description copied from class:AnnotatedTypeMirror
Applies a visitor to this type.- Specified by:
accept
in classAnnotatedTypeMirror
- Type Parameters:
R
- the return type of the visitor's methodsP
- the type of the additional parameter to the visitor's methods- Parameters:
v
- the visitor operating on this typep
- additional parameter to the visitor- Returns:
- a visitor-specified result
-
getUnderlyingType
Description copied from class:AnnotatedTypeMirror
Returns the underlying unannotated Java type, which this wraps.- Overrides:
getUnderlyingType
in classAnnotatedTypeMirror
- Returns:
- the underlying type
-
setLowerBound
Set the lower bound of this variable type.Returns the lower bound of this type variable. While a type parameter cannot include an explicit lower bound declaration, capture conversion can produce a type variable with a non-trivial lower bound. Type variables otherwise have a lower bound of NullType.
- Parameters:
type
- the lower bound type
-
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
Returns the lower bound type of this type variable.- Returns:
- the lower bound type of this type variable
-
setUpperBound
Set the upper bound of this variable type.- Parameters:
type
- the upper bound type
-
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
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
-
getBoundFields
-
deepCopy
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:
- Structure preservation -- The exact structure of the original AnnotatedTypeMirror is preserved in the copy including all component types.
- Annotation preservation -- All of the annotations from the original AnnotatedTypeMirror and its components have been copied to the new type.
- Specified by:
deepCopy
in classAnnotatedTypeMirror
- 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 interfaceorg.plumelib.util.DeepCopyable<AnnotatedTypeMirror>
- Specified by:
deepCopy
in classAnnotatedTypeMirror
- Returns:
- a deep copy of this type with annotations
- See Also:
-
shallowCopy
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 classAnnotatedTypeMirror
- Parameters:
copyAnnotations
- whether copy should have annotations, i.e. whether fieldannotations
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 classAnnotatedTypeMirror
- Returns:
- a shallow copy of this type with annotations
- See Also:
-
getErased
This method will traverse the upper bound of this type variable calling getErased until it finds the concrete upper bound. e.g.
A call to getErased will return the type List<E extends T>, T extends S, S extends List<String>>
- Overrides:
getErased
in classAnnotatedTypeMirror
- 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:
-