public abstract class AbstractQualifierPolymorphism extends Object implements QualifierPolymorphism
DefaultQualifierPolymorphism
implements the abstract methods in this class. Subclasses
can alter the way instantiations of polymorphic qualifiers are combined
.
An "instantiation" is a mapping from declaration type to use-site type — that is, a
mapping from @Poly*
to concrete qualifiers.
The implementation performs these steps:
@Poly*
by the concrete qualifier it maps to in the instantiation
@Poly*
by the top
qualifier
Modifier and Type | Field and Description |
---|---|
protected AnnotatedTypeFactory |
atypeFactory
Annotated type factory.
|
protected AnnotationMirrorMap<AnnotationMirror> |
polyInstantiationForQualifierParameter
Mapping from poly qualifier to its instantiation for types with a qualifier parameter.
|
protected AnnotationMirrorMap<AnnotationMirror> |
polyQuals
The polymorphic qualifiers: mapping from a polymorphic qualifier of
qualHierarchy to
the top qualifier of that hierarchy. |
protected QualifierHierarchy |
qualHierarchy
The qualifier hierarchy to use.
|
protected AnnotationMirrorSet |
topQuals
The qualifiers at the top of
qualHierarchy . |
Modifier | Constructor and Description |
---|---|
protected |
AbstractQualifierPolymorphism(ProcessingEnvironment env,
AnnotatedTypeFactory factory)
Creates an
AbstractQualifierPolymorphism instance that uses the given checker for
querying type qualifiers and the given factory for getting annotated types. |
Modifier and Type | Method and Description |
---|---|
protected abstract AnnotationMirror |
combine(AnnotationMirror polyQual,
AnnotationMirror a1,
AnnotationMirror a2)
Returns annotation that is the combination of the two annotations.
|
protected abstract void |
replace(AnnotatedTypeMirror type,
AnnotationMirrorMap<AnnotationMirror> replacements)
Replaces the top-level polymorphic annotations in
type with the instantiations in
replacements . |
protected void |
reset()
Reset to allow reuse of the same instance.
|
void |
resolve(AnnotatedTypeMirror.AnnotatedExecutableType functionalInterface,
AnnotatedTypeMirror.AnnotatedExecutableType memberReference)
Resolves polymorphism annotations for the given type.
|
void |
resolve(MethodInvocationTree tree,
AnnotatedTypeMirror.AnnotatedExecutableType type)
Resolves polymorphism annotations for the given type.
|
void |
resolve(NewClassTree tree,
AnnotatedTypeMirror.AnnotatedExecutableType type)
Resolves polymorphism annotations for the given type.
|
void |
resolve(VariableElement field,
AnnotatedTypeMirror owner,
AnnotatedTypeMirror type)
Resolves polymorphism annotations for the given field type.
|
protected final AnnotatedTypeFactory atypeFactory
protected final QualifierHierarchy qualHierarchy
protected final AnnotationMirrorMap<AnnotationMirror> polyQuals
qualHierarchy
to
the top qualifier of that hierarchy.protected final AnnotationMirrorSet topQuals
qualHierarchy
. These are the values in polyQuals
.protected final AnnotationMirrorMap<AnnotationMirror> polyInstantiationForQualifierParameter
protected AbstractQualifierPolymorphism(ProcessingEnvironment env, AnnotatedTypeFactory factory)
AbstractQualifierPolymorphism
instance that uses the given checker for
querying type qualifiers and the given factory for getting annotated types. Subclasses need
to add polymorphic qualifiers to this.polyQuals
.env
- the processing environmentfactory
- the factory for the current checkerprotected void reset()
public void resolve(MethodInvocationTree tree, AnnotatedTypeMirror.AnnotatedExecutableType type)
resolve
in interface QualifierPolymorphism
tree
- the tree associated with the typetype
- the type to annotatepublic void resolve(NewClassTree tree, AnnotatedTypeMirror.AnnotatedExecutableType type)
QualifierPolymorphism
resolve
in interface QualifierPolymorphism
tree
- the tree associated with the typetype
- the type to annotate; is side-effected by this methodpublic void resolve(VariableElement field, AnnotatedTypeMirror owner, AnnotatedTypeMirror type)
QualifierPolymorphism
resolve
in interface QualifierPolymorphism
field
- field element to whose poly annotation must be resolvedowner
- the type of the object whose field is being typedtype
- type of the field which still has poly annotationspublic void resolve(AnnotatedTypeMirror.AnnotatedExecutableType functionalInterface, AnnotatedTypeMirror.AnnotatedExecutableType memberReference)
QualifierPolymorphism
resolve
in interface QualifierPolymorphism
functionalInterface
- the function type of memberReference
memberReference
- the type of a member reference; is side-effected by this methodprotected abstract AnnotationMirror combine(AnnotationMirror polyQual, AnnotationMirror a1, AnnotationMirror a2)
polyQual
.
The combination is typically their least upper bound. (It could be the GLB in the case that all arguments to a polymorphic method must have the same annotation.)
polyQual
- polymorphic qualifier for which a1
and a2
are instantiationsa1
- an annotation that is an instantiation of polyQual
a2
- an annotation that is an instantiation of polyQual
protected abstract void replace(AnnotatedTypeMirror type, AnnotationMirrorMap<AnnotationMirror> replacements)
type
with the instantiations in
replacements
.
This method is called on all parts of a type.
type
- AnnotatedTypeMirror whose poly annotations are replaced; it is side-effected by
this methodreplacements
- mapping from polymorphic annotation to instantiation