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:
com.sun.source.tree.TreeVisitor<R1,P1>
- Enclosing class:
- SwitchExpressionScanner<R,P>
public static class SwitchExpressionScanner.FunctionalSwitchExpressionScanner<R1,P1> extends SwitchExpressionScanner<R1,P1>
An implementation ofSwitchExpressionScanner
that uses functions passed to the constructor forvisitSwitchResultExpression(ExpressionTree, Object)
andcombineResults(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
Constructors Constructor Description FunctionalSwitchExpressionScanner(java.util.function.BiFunction<com.sun.source.tree.ExpressionTree,P1,R1> switchValueExpressionFunc, java.util.function.BiFunction<@Nullable R1,@Nullable R1,R1> combineResultFunc)
Creates aSwitchExpressionScanner.FunctionalSwitchExpressionScanner
that uses the given functions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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(com.sun.source.tree.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, visitBlock, visitBreak, visitCase, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitEnhancedForLoop, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitIdentifier, visitIf, visitImport, visitInstanceOf, visitIntersectionType, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitMethod, visitMethodInvocation, visitModifiers, visitModule, visitNewArray, visitNewClass, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitPrimitiveType, visitProvides, visitRequires, visitReturn, visitSwitch, visitSynchronized, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitUnionType, visitUses, visitVariable, visitWhileLoop, visitWildcard
-
-
-
-
Constructor Detail
-
FunctionalSwitchExpressionScanner
public FunctionalSwitchExpressionScanner(java.util.function.BiFunction<com.sun.source.tree.ExpressionTree,P1,R1> switchValueExpressionFunc, java.util.function.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 Detail
-
visitSwitchResultExpression
protected R1 visitSwitchResultExpression(com.sun.source.tree.ExpressionTree resultExpressionTree, P1 p1)
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
protected R1 combineResults(@Nullable R1 r1, @Nullable R1 r2)
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
-
-