public class AnnotatedTypeReplacer extends DoubleAnnotatedTypeScanner<Void>
Example use:
AnnotatedTypeMirror visitType = ...;
AnnotatedTypeMirror parameter = ...;
visitType.accept(new AnnotatedTypeReplacer(), parameter);
AnnotatedTypeScanner.Reduce<R>
defaultResult, reduceFunction, visitedNodes
Constructor and Description |
---|
AnnotatedTypeReplacer()
Construct an AnnotatedTypeReplacer that will replace all annotations.
|
AnnotatedTypeReplacer(AnnotationMirror top)
Construct an AnnotatedTypeReplacer that will only replace annotations in
top 's
hierarchy. |
Modifier and Type | Method and Description |
---|---|
protected Void |
defaultAction(AnnotatedTypeMirror from,
AnnotatedTypeMirror to)
Called by default for any visit method that is not overridden.
|
static void |
replace(AnnotatedTypeMirror from,
AnnotatedTypeMirror to)
Deprecated.
|
static void |
replace(AnnotatedTypeMirror from,
AnnotatedTypeMirror to,
AnnotationMirror top)
Deprecated.
|
protected void |
replaceAnnotations(AnnotatedTypeMirror from,
AnnotatedTypeMirror to)
Replace the annotations in to with the annotations in from, wherever from has an annotation.
|
void |
resolvePrimaries(AnnotatedTypeMirror from,
AnnotatedTypeMirror to)
For type variables and wildcards, the absence of a primary annotations has an implied meaning
on substitution.
|
void |
setTop(@Nullable AnnotationMirror top)
If
top != null , then only annotations in the hierarchy of top are affected;
otherwise, all annotations are replaced. |
Void |
visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable from,
AnnotatedTypeMirror to)
Visits a type variable.
|
Void |
visitWildcard(AnnotatedTypeMirror.AnnotatedWildcardType from,
AnnotatedTypeMirror to)
Visits a wildcard type.
|
scan, scan, scanAndReduce, scanAndReduce, visitArray, visitDeclared, visitExecutable, visitIntersection, visitUnion
reduce, reset, scan, scanAndReduce, visit, visit, visitNoType, visitNull, visitPrimitive
public AnnotatedTypeReplacer()
public AnnotatedTypeReplacer(AnnotationMirror top)
top
's
hierarchy.top
- if top != null, then only annotation in the hierarchy of top are affected@Deprecated public static void replace(AnnotatedTypeMirror from, AnnotatedTypeMirror to)
AnnotatedTypeFactory.replaceAnnotations(AnnotatedTypeMirror,
AnnotatedTypeMirror)
instead.from
to to
. Annotations from from
will be used everywhere they exist, but annotations in to
will be kept anywhere that
from
is unannotated.from
- the annotated type mirror from which to take new annotationsto
- the annotated type mirror to which the annotations will be added@Deprecated public static void replace(AnnotatedTypeMirror from, AnnotatedTypeMirror to, AnnotationMirror top)
AnnotatedTypeFactory.replaceAnnotations(AnnotatedTypeMirror,
AnnotatedTypeMirror, AnnotationMirror)
instead.top
's hierarchy from from
to to
.
Annotations from from
will be used everywhere they exist, but annotations in to
will be kept anywhere that from
is unannotated.from
- the annotated type mirror from which to take new annotationsto
- the annotated type mirror to which the annotations will be addedtop
- the top type of the hierarchy whose annotations will be addedpublic void setTop(@Nullable AnnotationMirror top)
top != null
, then only annotations in the hierarchy of top
are affected;
otherwise, all annotations are replaced.top
- if top != null, then only annotations in the hierarchy of top are replaced;
otherwise, all annotations are replaced.protected Void defaultAction(AnnotatedTypeMirror from, AnnotatedTypeMirror to)
DoubleAnnotatedTypeScanner
defaultAction
in class DoubleAnnotatedTypeScanner<Void>
from
- the type to visitto
- a visitor-specified parameterprotected void replaceAnnotations(AnnotatedTypeMirror from, AnnotatedTypeMirror to)
from
- the source of the annotationsto
- the destination of the annotations, modified by this methodpublic Void visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable from, AnnotatedTypeMirror to)
AnnotatedTypeVisitor
visitTypeVariable
in interface AnnotatedTypeVisitor<Void,AnnotatedTypeMirror>
visitTypeVariable
in class DoubleAnnotatedTypeScanner<Void>
from
- the type to visitto
- a visitor-specified parameterpublic Void visitWildcard(AnnotatedTypeMirror.AnnotatedWildcardType from, AnnotatedTypeMirror to)
AnnotatedTypeVisitor
visitWildcard
in interface AnnotatedTypeVisitor<Void,AnnotatedTypeMirror>
visitWildcard
in class DoubleAnnotatedTypeScanner<Void>
from
- the type to visitto
- a visitor-specified parameterpublic void resolvePrimaries(AnnotatedTypeMirror from, AnnotatedTypeMirror to)
from
- a type variable or wildcardto
- the destination annotated type mirror