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 code replaces everything; but the
instantiation only contains @Poly*
as keys.)
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 a qualifier hierarchy to
the top qualifier of that hierarchy.
|
protected QualifierHierarchy |
qualHierarchy
The qualifier hierarchy to use.
|
protected AnnotationMirrorSet |
topQuals
The qualifiers at the top of the qualifier hierarchy.
|
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 |
---|---|
void |
annotate(AnnotatedTypeMirror.AnnotatedExecutableType functionalInterface,
AnnotatedTypeMirror.AnnotatedExecutableType memberReference)
Resolves polymorphism annotations for the given type.
|
void |
annotate(MethodInvocationTree tree,
AnnotatedTypeMirror.AnnotatedExecutableType type)
Resolves polymorphism annotations for the given type.
|
void |
annotate(NewClassTree tree,
AnnotatedTypeMirror.AnnotatedExecutableType type)
Resolves polymorphism annotations for the given type.
|
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
matches . |
protected void |
reset()
Reset to allow reuse of the same instance.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPolymorphicQualifier, getPolymorphicQualifierTop, isPolyAll, isPolymorphicQualified
protected final AnnotatedTypeFactory atypeFactory
protected final AnnotationMirrorMap<AnnotationMirror> polyQuals
protected final AnnotationMirrorSet topQuals
protected final QualifierHierarchy qualHierarchy
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 polyQuals
.env
- the processing environmentfactory
- the factory for the current checkerprotected void reset()
public void annotate(MethodInvocationTree tree, AnnotatedTypeMirror.AnnotatedExecutableType type)
annotate
in interface QualifierPolymorphism
tree
- the tree associated with the typetype
- the type to annotatepublic void annotate(NewClassTree tree, AnnotatedTypeMirror.AnnotatedExecutableType type)
QualifierPolymorphism
annotate
in interface QualifierPolymorphism
tree
- the tree associated with the typetype
- the type to annotate; is side-effected by this methodpublic void annotate(AnnotatedTypeMirror.AnnotatedExecutableType functionalInterface, AnnotatedTypeMirror.AnnotatedExecutableType memberReference)
QualifierPolymorphism
annotate
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
.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
matches
.
This method is called on all parts of a type.
type
- AnnotationTypeMirror whose poly annotations are replacedreplacements
- mapping from polymorphic annotation to instantiation