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 AnnotationMirror |
POLYALL
PolyAll annotation mirror. |
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 . |
Constructor and Description |
---|
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 AnnotationMirrorSet |
combine(AnnotationMirror polyQual,
AnnotationMirrorSet a1Annos,
AnnotationMirrorSet a2Annos)
Returns an annotation set that is the merge of the two sets of annotations.
|
protected abstract void |
replace(AnnotatedTypeMirror type,
AnnotationMirrorMap<AnnotationMirrorSet> 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPolymorphicQualifier, getPolymorphicQualifierElement, getPolymorphicQualifierTop, hasPolymorphicQualifier, isPolyAll, isPolymorphicQualified
protected final AnnotatedTypeFactory atypeFactory
protected final QualifierHierarchy qualHierarchy
protected final AnnotationMirrorMap<AnnotationMirror> polyQuals
qualHierarchy
to
the top qualifier of that hierarchy. The field is always non-null, but it might be an empty
mapping. If a value is null, the polymorphic qualifier, such as PolyAll
, applies to
all hierarchies.protected final AnnotationMirrorSet topQuals
qualHierarchy
. These are the values in polyQuals
.protected final AnnotationMirror POLYALL
PolyAll
annotation mirror.public 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(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 AnnotationMirrorSet combine(AnnotationMirror polyQual, AnnotationMirrorSet a1Annos, AnnotationMirrorSet a2Annos)
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 a1Annos
and a2Annos
are
instantiationsa1Annos
- a set that is an instantiation of polyQual
a2Annos
- a set that is an instantiation of polyQual
protected abstract void replace(AnnotatedTypeMirror type, AnnotationMirrorMap<AnnotationMirrorSet> 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