Package org.checkerframework.javacutil
Class SwitchExpressionScanner.FunctionalSwitchExpressionScanner<R1,P1>
java.lang.Object
com.sun.source.util.TreeScanner<R,P>
org.checkerframework.javacutil.SwitchExpressionScanner<R1,P1>
org.checkerframework.javacutil.SwitchExpressionScanner.FunctionalSwitchExpressionScanner<R1,P1>
- Type Parameters:
R1
- the type result ofvisitSwitchResultExpression(ExpressionTree, Object)
P1
- the type of the parameter to pass tovisitSwitchResultExpression(ExpressionTree, Object)
- All Implemented Interfaces:
TreeVisitor<R1,
P1>
- Enclosing class:
- SwitchExpressionScanner<R,
P>
public static class SwitchExpressionScanner.FunctionalSwitchExpressionScanner<R1,P1>
extends SwitchExpressionScanner<R1,P1>
An implementation of
SwitchExpressionScanner
that uses functions passed to the
constructor for visitSwitchResultExpression(ExpressionTree, Object)
and combineResults(Object, Object)
.-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.javacutil.SwitchExpressionScanner
SwitchExpressionScanner.FunctionalSwitchExpressionScanner<R1,
P1>, SwitchExpressionScanner.YieldVisitor -
Field Summary
Fields inherited from class org.checkerframework.javacutil.SwitchExpressionScanner
yieldVisitor
-
Constructor Summary
ConstructorDescriptionFunctionalSwitchExpressionScanner
(BiFunction<ExpressionTree, P1, R1> switchValueExpressionFunc, BiFunction<@Nullable R1, @Nullable R1, R1> combineResultFunc) Creates aSwitchExpressionScanner.FunctionalSwitchExpressionScanner
that uses the given functions. -
Method Summary
Modifier and TypeMethodDescriptionprotected R1
combineResults
(@Nullable R1 r1, @Nullable R1 r2) This method combines the result of two calls toSwitchExpressionScanner.visitSwitchResultExpression(ExpressionTree, Object)
ornull
and the result of one call toSwitchExpressionScanner.visitSwitchResultExpression(ExpressionTree, Object)
.protected R1
visitSwitchResultExpression
(ExpressionTree resultExpressionTree, P1 p1) This method is called for each result expression of the switch expression passed inSwitchExpressionScanner.scanSwitchExpression(Tree, Object)
.Methods inherited from class org.checkerframework.javacutil.SwitchExpressionScanner
scanSwitchExpression
Methods inherited from class com.sun.source.util.TreeScanner
reduce, scan, scan, visitAnnotatedType, visitAnnotation, visitArrayAccess, visitArrayType, visitAssert, visitAssignment, visitBinary, visitBindingPattern, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitGuardedPattern, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitModule, visitNewArray, visitNewClass, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitParenthesizedPattern, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitSwitch, visitSwitchExpression, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard, visitYield
-
Constructor Details
-
FunctionalSwitchExpressionScanner
public FunctionalSwitchExpressionScanner(BiFunction<ExpressionTree, P1, R1> switchValueExpressionFunc, BiFunction<@Nullable R1, @Nullable R1, R1> combineResultFunc) Creates aSwitchExpressionScanner.FunctionalSwitchExpressionScanner
that uses the given functions.- Parameters:
switchValueExpressionFunc
- the function called on each switch result expressioncombineResultFunc
- the function used to combine the result of multiple calls toswitchValueExpressionFunc
-
-
Method Details
-
visitSwitchResultExpression
Description copied from class:SwitchExpressionScanner
This method is called for each result expression of the switch expression passed inSwitchExpressionScanner.scanSwitchExpression(Tree, Object)
.- Specified by:
visitSwitchResultExpression
in classSwitchExpressionScanner<R1,
P1> - Parameters:
resultExpressionTree
- a result expression of the switch expression currently being scannedp1
- a parameter- Returns:
- the result of visiting the result expression
-
combineResults
Description copied from class:SwitchExpressionScanner
This method combines the result of two calls toSwitchExpressionScanner.visitSwitchResultExpression(ExpressionTree, Object)
ornull
and the result of one call toSwitchExpressionScanner.visitSwitchResultExpression(ExpressionTree, Object)
.- Specified by:
combineResults
in classSwitchExpressionScanner<R1,
P1> - Parameters:
r1
- a possibly null result returned bySwitchExpressionScanner.visitSwitchResultExpression(ExpressionTree, Object)
r2
- a possibly null result returned bySwitchExpressionScanner.visitSwitchResultExpression(ExpressionTree, Object)
- Returns:
- the combination of
r1
andr2
-