Class AnnotatedTypeMirror.AnnotatedIntersectionType
- java.lang.Object
-
- org.checkerframework.framework.type.AnnotatedTypeMirror
-
- org.checkerframework.framework.type.AnnotatedTypeMirror.AnnotatedIntersectionType
-
- All Implemented Interfaces:
org.plumelib.util.DeepCopyable<AnnotatedTypeMirror>
- Enclosing class:
- AnnotatedTypeMirror
public static class AnnotatedTypeMirror.AnnotatedIntersectionType extends AnnotatedTypeMirror
Represents an intersection type.For example:
MyObject & Serializable & Comparable<MyObject>
-
-
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 Modifier and Type Field Description protected java.util.List<AnnotatedTypeMirror>
bounds
A list of the bounds of this which are also its direct super types.-
Fields inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
atypeFactory, EQUALITY_COMPARER, HASHCODE_VISITOR, primaryAnnotations, underlyingType
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R,P>
Raccept(AnnotatedTypeVisitor<R,P> v, P p)
Applies a visitor to this type.void
addAnnotation(javax.lang.model.element.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.void
copyIntersectionBoundAnnotations()
Copy the first annotation (in each hierarchy) on a bound to the primary annotation location of the intersection type.AnnotatedTypeMirror.AnnotatedIntersectionType
deepCopy()
Returns a deep copy of this type with annotations.AnnotatedTypeMirror.AnnotatedIntersectionType
deepCopy(boolean copyAnnotations)
Returns a deep copy of this type.java.util.List<? extends AnnotatedTypeMirror>
directSupertypes()
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.java.util.List<AnnotatedTypeMirror>
getBounds()
This returns the bounds of the intersection type.javax.lang.model.type.IntersectionType
getUnderlyingType()
Returns the underlying unannotated Java type, which this wraps.boolean
removeAnnotation(javax.lang.model.element.AnnotationMirror a)
Removes a primary annotation from the type.void
setBounds(java.util.List<AnnotatedTypeMirror> bounds)
Sets the bounds.AnnotatedTypeMirror.AnnotatedIntersectionType
shallowCopy()
Returns a shallow copy of this type with annotations.AnnotatedTypeMirror.AnnotatedIntersectionType
shallowCopy(boolean copyAnnotations)
Returns a shallow copy of this type.-
Methods inherited from class org.checkerframework.framework.type.AnnotatedTypeMirror
addAnnotation, addAnnotations, addMissingAnnotation, addMissingAnnotations, asUse, clearAnnotations, containsUninferredTypeArguments, createType, createTypeOfObject, createTypeOfRecord, equals, getAnnotation, getAnnotation, getAnnotationInHierarchy, getAnnotations, getAnnotationsField, getEffectiveAnnotation, getEffectiveAnnotationInHierarchy, getEffectiveAnnotations, getErased, getExplicitAnnotations, getKind, getPrimitiveKind, getUnderlyingTypeHashCode, hasAnnotation, hasAnnotation, hasAnnotationInHierarchy, hasAnnotationRelaxed, hasEffectiveAnnotation, hasEffectiveAnnotation, hasEffectiveAnnotationRelaxed, hasExplicitAnnotation, hasExplicitAnnotation, hasExplicitAnnotationRelaxed, hashCode, isAnnotatedInHierarchy, isDeclaration, removeAnnotationByClass, removeAnnotationInHierarchy, removeAnnotations, removeNonTopAnnotationInHierarchy, replaceAnnotation, replaceAnnotations, toString, toString
-
-
-
-
Field Detail
-
bounds
protected java.util.List<AnnotatedTypeMirror> bounds
A list of the bounds of this which are also its direct super types.Is set by
shallowCopy(boolean)
.
-
-
Method Detail
-
addAnnotation
public void addAnnotation(javax.lang.model.element.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. (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.Also, copies
a
to all the bounds.- Overrides:
addAnnotation
in classAnnotatedTypeMirror
- Parameters:
annotation
- the annotation to add
-
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 classAnnotatedTypeMirror
- Parameters:
a
- the annotation to remove- Returns:
- true if the annotation was removed, false if the type's annotations were unchanged
-
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 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
public javax.lang.model.type.IntersectionType getUnderlyingType()
Description copied from class:AnnotatedTypeMirror
Returns the underlying unannotated Java type, which this wraps.- Overrides:
getUnderlyingType
in classAnnotatedTypeMirror
- Returns:
- the underlying type
-
deepCopy
public AnnotatedTypeMirror.AnnotatedIntersectionType 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:
- 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
public AnnotatedTypeMirror.AnnotatedIntersectionType 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:
AnnotatedTypeMirror.deepCopy(boolean)
-
shallowCopy
public AnnotatedTypeMirror.AnnotatedIntersectionType 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 classAnnotatedTypeMirror
- Parameters:
copyAnnotations
- whether copy should have annotations, i.e. whether fieldannotations
should be copied.
-
shallowCopy
public AnnotatedTypeMirror.AnnotatedIntersectionType 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:
AnnotatedTypeMirror.shallowCopy(boolean)
-
directSupertypes
public java.util.List<? extends AnnotatedTypeMirror> directSupertypes()
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;
@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;
@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;
@Nullable A
are@Nullable B <@NonNull String>
and@Nullable List<@NonNull Integer>
.This returns the same types as
getBounds()
.- Overrides:
directSupertypes
in classAnnotatedTypeMirror
- Returns:
- the direct super types of this
- See Also:
Types.directSupertypes(TypeMirror)
-
getBounds
public java.util.List<AnnotatedTypeMirror> getBounds()
This returns the bounds of the intersection type. Although only declared types can appear in an explicitly written intersections, during capture conversion, intersections with other kinds of types are created.This returns the same types as
directSupertypes()
.- Returns:
- the bounds of this, which are also the direct super types of this
-
setBounds
public void setBounds(java.util.List<AnnotatedTypeMirror> bounds)
Sets the bounds.- Parameters:
bounds
- a list of bounds to be captured by this method
-
copyIntersectionBoundAnnotations
public void copyIntersectionBoundAnnotations()
Copy the first annotation (in each hierarchy) on a bound to the primary annotation location of the intersection type.For example, in the type
@NonNull Object & @Initialized @Nullable Serializable
,@Nullable
and@Initialized
are copied to the primary annotation location.
-
-