Class DoubleAnnotatedTypeScanner<R>
- java.lang.Object
-
- org.checkerframework.framework.type.visitor.AnnotatedTypeScanner<R,AnnotatedTypeMirror>
-
- org.checkerframework.framework.type.visitor.DoubleAnnotatedTypeScanner<R>
-
- Type Parameters:
R
- the result of scanning the twoAnnotatedTypeMirror
s
- All Implemented Interfaces:
AnnotatedTypeVisitor<R,AnnotatedTypeMirror>
- Direct Known Subclasses:
AnnotatedTypeCombiner
,AnnotatedTypeReplacer
public abstract class DoubleAnnotatedTypeScanner<R> extends AnnotatedTypeScanner<R,AnnotatedTypeMirror>
AnAnnotatedTypeScanner
that scans twoAnnotatedTypeMirror
s simultaneously and performsdefaultAction(AnnotatedTypeMirror, AnnotatedTypeMirror)
on the pair. Both AnnotatedTypeMirrors must have the same structure, or a subclass must arrange not to continue recursing past the point at which their structure diverges.If the default action does not return a result, then
R
should beVoid
andDoubleAnnotatedTypeScanner()
should be used to construct the scanner. If the default action returns a result, then specify aAnnotatedTypeScanner.reduce(R, R)
function and useDoubleAnnotatedTypeScanner(Reduce, Object)
.- See Also:
AnnotatedTypeScanner
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
AnnotatedTypeScanner.Reduce<R>
-
-
Field Summary
-
Fields inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
defaultResult, reduceFunction, visitedNodes
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DoubleAnnotatedTypeScanner()
Constructs an AnnotatedTypeScanner where the reduce function returns the first result if it is nonnull; otherwise the second result is returned.protected
DoubleAnnotatedTypeScanner(AnnotatedTypeScanner.Reduce<R> reduce, R defaultResult)
Creates a scanner with the givenreduce
function anddefaultResult
.
-
Method Summary
-
Methods inherited from class org.checkerframework.framework.type.visitor.AnnotatedTypeScanner
reduce, reset, scan, scanAndReduce, visit, visit, visitNoType, visitNull, visitPrimitive
-
-
-
-
Constructor Detail
-
DoubleAnnotatedTypeScanner
protected DoubleAnnotatedTypeScanner()
Constructs an AnnotatedTypeScanner where the reduce function returns the first result if it is nonnull; otherwise the second result is returned. The default result isnull
.
-
DoubleAnnotatedTypeScanner
protected DoubleAnnotatedTypeScanner(AnnotatedTypeScanner.Reduce<R> reduce, R defaultResult)
Creates a scanner with the givenreduce
function anddefaultResult
.- Parameters:
reduce
- function used to combine the results of scandefaultResult
- result to use by default
-
-
Method Detail
-
defaultAction
protected abstract R defaultAction(AnnotatedTypeMirror type, AnnotatedTypeMirror p)
Called by default for any visit method that is not overridden.- Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
scan
protected R scan(java.lang.Iterable<? extends AnnotatedTypeMirror> types1, java.lang.Iterable<? extends AnnotatedTypeMirror> types2)
- Parameters:
types1
- typestypes2
- types- Returns:
- the result of scanning and reducing all the types in
types1
andtypes2
orAnnotatedTypeScanner.defaultResult
if they are empty
-
scanAndReduce
protected R scanAndReduce(java.lang.Iterable<? extends AnnotatedTypeMirror> types, java.lang.Iterable<? extends AnnotatedTypeMirror> p, R r)
Runscan(java.lang.Iterable<? extends org.checkerframework.framework.type.AnnotatedTypeMirror>, java.lang.Iterable<? extends org.checkerframework.framework.type.AnnotatedTypeMirror>)
on types and p, then runAnnotatedTypeScanner.reduce(R, R)
on the result (plus r) to return a single element.
-
scanAndReduce
protected final R scanAndReduce(java.lang.Iterable<? extends AnnotatedTypeMirror> types, AnnotatedTypeMirror p, R r)
- Overrides:
scanAndReduce
in classAnnotatedTypeScanner<R,AnnotatedTypeMirror>
-
scan
protected R scan(AnnotatedTypeMirror type, AnnotatedTypeMirror p)
Description copied from class:AnnotatedTypeScanner
Scantype
by callingtype.accept(this, p)
; this method may be overridden by subclasses.- Overrides:
scan
in classAnnotatedTypeScanner<R,AnnotatedTypeMirror>
- Parameters:
type
- type to scanp
- the parameter to use- Returns:
- the result of visiting
type
-
visitDeclared
public final R visitDeclared(AnnotatedTypeMirror.AnnotatedDeclaredType type, AnnotatedTypeMirror p)
Description copied from interface:AnnotatedTypeVisitor
Visits a declared type.- Specified by:
visitDeclared
in interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror>
- Overrides:
visitDeclared
in classAnnotatedTypeScanner<R,AnnotatedTypeMirror>
- Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitArray
public final R visitArray(AnnotatedTypeMirror.AnnotatedArrayType type, AnnotatedTypeMirror p)
Description copied from interface:AnnotatedTypeVisitor
Visits an array type.- Specified by:
visitArray
in interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror>
- Overrides:
visitArray
in classAnnotatedTypeScanner<R,AnnotatedTypeMirror>
- Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitExecutable
public final R visitExecutable(AnnotatedTypeMirror.AnnotatedExecutableType type, AnnotatedTypeMirror p)
Description copied from interface:AnnotatedTypeVisitor
Visits an executable type.- Specified by:
visitExecutable
in interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror>
- Overrides:
visitExecutable
in classAnnotatedTypeScanner<R,AnnotatedTypeMirror>
- Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitTypeVariable
public R visitTypeVariable(AnnotatedTypeMirror.AnnotatedTypeVariable type, AnnotatedTypeMirror p)
Description copied from interface:AnnotatedTypeVisitor
Visits a type variable.- Specified by:
visitTypeVariable
in interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror>
- Overrides:
visitTypeVariable
in classAnnotatedTypeScanner<R,AnnotatedTypeMirror>
- Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitWildcard
public R visitWildcard(AnnotatedTypeMirror.AnnotatedWildcardType type, AnnotatedTypeMirror p)
Description copied from interface:AnnotatedTypeVisitor
Visits a wildcard type.- Specified by:
visitWildcard
in interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror>
- Overrides:
visitWildcard
in classAnnotatedTypeScanner<R,AnnotatedTypeMirror>
- Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitIntersection
public R visitIntersection(AnnotatedTypeMirror.AnnotatedIntersectionType type, AnnotatedTypeMirror p)
Description copied from interface:AnnotatedTypeVisitor
Visits an intersection type.- Specified by:
visitIntersection
in interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror>
- Overrides:
visitIntersection
in classAnnotatedTypeScanner<R,AnnotatedTypeMirror>
- Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
visitUnion
public R visitUnion(AnnotatedTypeMirror.AnnotatedUnionType type, AnnotatedTypeMirror p)
Description copied from interface:AnnotatedTypeVisitor
Visits an union type.- Specified by:
visitUnion
in interfaceAnnotatedTypeVisitor<R,AnnotatedTypeMirror>
- Overrides:
visitUnion
in classAnnotatedTypeScanner<R,AnnotatedTypeMirror>
- Parameters:
type
- the type to visitp
- a visitor-specified parameter- Returns:
- a visitor-specified result
-
-