Interface ASTSwitchLike
-
- All Superinterfaces:
GenericNode<JavaNode>
,Iterable<ASTSwitchBranch>
,JavaNode
,JjtreeNode<JavaNode>
,Node
,Reportable
,TextAvailableNode
- All Known Implementing Classes:
ASTSwitchExpression
,ASTSwitchStatement
public interface ASTSwitchLike extends JavaNode, Iterable<ASTSwitchBranch>
Common supertype for switch statements and switch expressions. Their grammar is identical, and is described below. The difference is that switch expressions need to be exhaustive.SwitchLike ::=
SwitchExpression
|SwitchStatement
::= "switch" "("Expression
")" SwitchBlock SwitchBlock ::= SwitchArrowBlock | SwitchNormalBlock SwitchArrowBlock ::= "{"SwitchArrowBranch
* "}" SwitchNormalBlock ::= "{" SwitchFallthroughBranch* "}"
-
-
Field Summary
-
Fields inherited from interface net.sourceforge.pmd.lang.ast.Node
COORDS_COMPARATOR
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default NodeStream<ASTSwitchBranch>
getBranches()
Returns a stream of all branches of this switch.default ASTExpression
getTestedExpression()
Gets the expression tested by this switch.default boolean
hasDefaultCase()
Returns true if this switch has adefault
case.default boolean
isEnumSwitch()
Returns true if this switch statement tests an expression having an enum type.default boolean
isExhaustiveEnumSwitch()
Returns true if this switch statement tests an expression having an enum type and all the constants of this type are covered by a switch case.default boolean
isFallthroughSwitch()
Returns true if this a switch which uses fallthrough branches (old schoolcase label: break;
) and not arrow branches.default Iterator<ASTSwitchBranch>
iterator()
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.impl.GenericNode
ancestors, ancestorsOrSelf, asStream, children, descendants, descendantsOrSelf, getChild, getFirstChild, getLastChild, getNextSibling, getParent, getPreviousSibling
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface net.sourceforge.pmd.lang.java.ast.JavaNode
getEnclosingType, getRoot, getSymbolTable, getTypeSystem
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode
getFirstToken, getLastToken, tokens
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.Node
acceptVisitor, ancestors, children, compareLocation, descendants, firstChild, getAstInfo, getBeginColumn, getBeginLine, getEndColumn, getEndLine, getImage, getIndexInParent, getLanguageVersion, getNumChildren, getReportLocation, getTextDocument, getUserMap, getXPathAttributesIterator, getXPathNodeName, hasImageEqualTo, isFindBoundary
-
Methods inherited from interface net.sourceforge.pmd.lang.ast.TextAvailableNode
getOriginalText, getText, getTextRegion
-
-
-
-
Method Detail
-
hasDefaultCase
default boolean hasDefaultCase()
Returns true if this switch has adefault
case.
-
getBranches
default NodeStream<ASTSwitchBranch> getBranches()
Returns a stream of all branches of this switch.
-
getTestedExpression
default ASTExpression getTestedExpression()
Gets the expression tested by this switch. This is the expression between the parentheses.
-
isExhaustiveEnumSwitch
default boolean isExhaustiveEnumSwitch()
Returns true if this switch statement tests an expression having an enum type and all the constants of this type are covered by a switch case. Returns false if the type of the tested expression could not be resolved.
-
isEnumSwitch
default boolean isEnumSwitch()
Returns true if this switch statement tests an expression having an enum type.
-
iterator
default Iterator<ASTSwitchBranch> iterator()
- Specified by:
iterator
in interfaceIterable<ASTSwitchBranch>
-
isFallthroughSwitch
default boolean isFallthroughSwitch()
Returns true if this a switch which uses fallthrough branches (old schoolcase label: break;
) and not arrow branches. If the switch has no branches, returns false.
-
-