R
- the return type of this visitor's methods. Use Void for visitors that do not need to
return results.P
- the type of the additional parameter to this visitor's methods. Use Void for visitors
that do not need an additional parameter.public class AnnotatedTypeScanner<R,P> extends Object implements AnnotatedTypeVisitor<R,P>
The default implementation of the visitXYZ methods will determine a result as follows:
class CountTypeVariable extends TreeScanner {
@Override
public Integer visitTypeVariable(ATypeVariable node, Void p) {
return 1;
}
@Override
public Integer reduce(Integer r1, Integer r2) {
return (r1 == null ? 0 : r1) + (r2 == null ? 0 : r2);
}
}
Modifier and Type | Field and Description |
---|---|
protected Map<AnnotatedTypeMirror,R> |
visitedNodes |
Constructor and Description |
---|
AnnotatedTypeScanner() |
Modifier and Type | Method and Description |
---|---|
protected R |
reduce(R r1,
R r2)
Combines
r1 and r2 and returns the result. |
void |
reset()
Reset the scanner to allow reuse of the same instance.
|
protected R |
scan(AnnotatedTypeMirror type,
P p)
Scan
type by calling type.accept(this, p) ; this method may be overridden by
subclasses. |
protected R |
scan(Iterable<? extends AnnotatedTypeMirror> types,
P p)
Scan all the types and returns the reduced result.
|
protected R |
scanAndReduce(AnnotatedTypeMirror type,
P p,
R r)
Scans
type with the parameter p and reduces the result with r . |
protected R |
scanAndReduce(Iterable<? extends AnnotatedTypeMirror> types,
P p,
R r) |
R |
visit(AnnotatedTypeMirror type)
Calls
reset() and then scans type using null as the parameter. |
R |
visit(AnnotatedTypeMirror type,
P p)
|
R |
visitArray(AnnotatedTypeMirror.AnnotatedArrayType type,
P p)
Visits an array type.
|
R |
visitDeclared(AnnotatedTypeMirror.AnnotatedDeclaredType type,
P p)
Visits a declared type.
|
R |
visitExecutable(AnnotatedTypeMirror.AnnotatedExecutableType type,
P p)
Visits an executable type.
|
R |
visitIntersection(AnnotatedTypeMirror.AnnotatedIntersectionType type,
P p)
Visits an intersection type.
|
R |
visitNoType(AnnotatedTypeMirror.AnnotatedNoType type,
P p)
Visits NoType type.
|
R |
visitNull(AnnotatedTypeMirror.AnnotatedNullType type,
P p)
Visits a
null type. |
R |
visitPrimitive(AnnotatedTypeMirror.AnnotatedPrimitiveType type,
P p)
Visits a primitive type.
|
R |
visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable type,
P p)
Visits a type variable.
|
R |
visitUnion(AnnotatedTypeMirror.AnnotatedUnionType type,
P p)
Visits an union type.
|
R |
visitWildcard(AnnotatedTypeMirror.AnnotatedWildcardType type,
P p)
Visits a wildcard type.
|
protected final Map<AnnotatedTypeMirror,R> visitedNodes
public void reset()
public final R visit(AnnotatedTypeMirror type)
reset()
and then scans type
using null as the parameter.visit
in interface AnnotatedTypeVisitor<R,P>
type
- type to scantype
public final R visit(AnnotatedTypeMirror type, P p)
visit
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parametertype
protected R scan(AnnotatedTypeMirror type, P p)
type
by calling type.accept(this, p)
; this method may be overridden by
subclasses.type
- type to scanp
- the parameter to usetype
protected R scan(Iterable<? extends AnnotatedTypeMirror> types, P p)
types
- types to scanp
- the parameter to useprotected R scanAndReduce(Iterable<? extends AnnotatedTypeMirror> types, P p, R r)
protected R scanAndReduce(AnnotatedTypeMirror type, P p, R r)
type
with the parameter p
and reduces the result with r
.type
- type to scanp
- parameter to use for when scanning type
r
- result to combine with the result of scanning type
r
with the result of scanning type
protected R reduce(R r1, R r2)
r1
and r2
and returns the result. The default implementation returns
r1
if it is not null; otherwise, it returns r2
.r1
- a result of scanr2
- a result of scanr1
and r2
public R visitDeclared(AnnotatedTypeMirror.AnnotatedDeclaredType type, P p)
AnnotatedTypeVisitor
visitDeclared
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitIntersection(AnnotatedTypeMirror.AnnotatedIntersectionType type, P p)
AnnotatedTypeVisitor
visitIntersection
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitUnion(AnnotatedTypeMirror.AnnotatedUnionType type, P p)
AnnotatedTypeVisitor
visitUnion
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitArray(AnnotatedTypeMirror.AnnotatedArrayType type, P p)
AnnotatedTypeVisitor
visitArray
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitExecutable(AnnotatedTypeMirror.AnnotatedExecutableType type, P p)
AnnotatedTypeVisitor
visitExecutable
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable type, P p)
AnnotatedTypeVisitor
visitTypeVariable
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitNoType(AnnotatedTypeMirror.AnnotatedNoType type, P p)
AnnotatedTypeVisitor
visitNoType
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitNull(AnnotatedTypeMirror.AnnotatedNullType type, P p)
AnnotatedTypeVisitor
null
type.visitNull
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitPrimitive(AnnotatedTypeMirror.AnnotatedPrimitiveType type, P p)
AnnotatedTypeVisitor
visitPrimitive
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameterpublic R visitWildcard(AnnotatedTypeMirror.AnnotatedWildcardType type, P p)
AnnotatedTypeVisitor
visitWildcard
in interface AnnotatedTypeVisitor<R,P>
type
- the type to visitp
- a visitor-specified parameter