public class ForEachStmt extends Statement implements NodeWithBody<ForEachStmt>
for(Object o: objects) { ... }
It was introduced in Java 5.Node.BreadthFirstIterator, Node.DirectChildrenIterator, Node.ObserverRegistrationMode, Node.ParentsVisitor, Node.Parsedness, Node.PostOrderIterator, Node.PreOrderIterator, Node.TreeTraversalABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, LINE_SEPARATOR_KEY, NODE_BY_BEGIN_POSITION, PHANTOM_KEY, prettyPrinterNoCommentsConfiguration, PRINTER_KEY, SYMBOL_RESOLVER_KEY| Constructor and Description |
|---|
ForEachStmt() |
ForEachStmt(TokenRange tokenRange,
VariableDeclarationExpr variable,
Expression iterable,
Statement body)
This constructor is used by the parser and is considered private.
|
ForEachStmt(VariableDeclarationExpr variable,
Expression iterable,
Statement body) |
ForEachStmt(VariableDeclarationExpr variable,
String iterable,
BlockStmt body) |
| Modifier and Type | Method and Description |
|---|---|
<R,A> R |
accept(GenericVisitor<R,A> v,
A arg)
Accept method for visitor support.
|
<A> void |
accept(VoidVisitor<A> v,
A arg)
Accept method for visitor support.
|
ForEachStmt |
asForEachStmt() |
ForEachStmt |
clone() |
Statement |
getBody() |
Expression |
getIterable() |
ForEachStmtMetaModel |
getMetaModel() |
VariableDeclarationExpr |
getVariable() |
VariableDeclarator |
getVariableDeclarator()
Convenience method that directly returns this foreach statement's single variable declarator.
|
boolean |
hasFinalVariable()
Convenience method that decides whether this foreach statement's variable is
final. |
void |
ifForEachStmt(Consumer<ForEachStmt> action) |
boolean |
isForEachStmt() |
boolean |
remove(Node node) |
boolean |
replace(Node node,
Node replacementNode) |
ForEachStmt |
setBody(Statement body) |
ForEachStmt |
setIterable(Expression iterable) |
ForEachStmt |
setVariable(VariableDeclarationExpr variable) |
Optional<ForEachStmt> |
toForEachStmt() |
asAssertStmt, asBlockStmt, asBreakStmt, asContinueStmt, asDoStmt, asEmptyStmt, asExplicitConstructorInvocationStmt, asExpressionStmt, asForStmt, asIfStmt, asLabeledStmt, asLocalClassDeclarationStmt, asReturnStmt, asSwitchStmt, asSynchronizedStmt, asThrowStmt, asTryStmt, asUnparsableStmt, asWhileStmt, asYieldStmt, ifAssertStmt, ifBlockStmt, ifBreakStmt, ifContinueStmt, ifDoStmt, ifEmptyStmt, ifExplicitConstructorInvocationStmt, ifExpressionStmt, ifForStmt, ifIfStmt, ifLabeledStmt, ifLocalClassDeclarationStmt, ifReturnStmt, ifSwitchStmt, ifSynchronizedStmt, ifThrowStmt, ifTryStmt, ifUnparsableStmt, ifWhileStmt, ifYieldStmt, isAssertStmt, isBlockStmt, isBreakStmt, isContinueStmt, isDoStmt, isEmptyStmt, isExplicitConstructorInvocationStmt, isExpressionStmt, isForStmt, isIfStmt, isLabeledStmt, isLocalClassDeclarationStmt, isReturnStmt, isSwitchStmt, isSynchronizedStmt, isThrowStmt, isTryStmt, isUnparsableStmt, isWhileStmt, isYieldStmt, toAssertStmt, toBlockStmt, toBreakStmt, toContinueStmt, toDoStmt, toEmptyStmt, toExplicitConstructorInvocationStmt, toExpressionStmt, toForStmt, toIfStmt, toLabeledStmt, toLocalClassDeclarationStmt, toReturnStmt, toSwitchStmt, toSynchronizedStmt, toThrowStmt, toTryStmt, toUnparsableStmt, toWhileStmt, toYieldStmtaddOrphanComment, containsData, createDefaultPrinter, createDefaultPrinter, customInitialization, equals, findAll, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getDataKeys, getDefaultPrinterConfiguration, getLineEndingStyle, getLineEndingStyleOrDefault, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getPrinter, getPrinter, getRange, getSymbolResolver, getTokenRange, hashCode, hasScope, isAncestorOf, isPhantom, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeData, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walkfinalize, getClass, notify, notifyAll, wait, wait, waitcreateBlockStatementAsBody, hasEmptyBodyfindAncestor, findAncestor, hasParentNode, isDescendantOfcontainsWithin, containsWithinRange, getBegin, getEnd, hasRangepublic ForEachStmt()
public ForEachStmt(VariableDeclarationExpr variable, Expression iterable, Statement body)
public ForEachStmt(TokenRange tokenRange, VariableDeclarationExpr variable, Expression iterable, Statement body)
public ForEachStmt(VariableDeclarationExpr variable, String iterable, BlockStmt body)
public <R,A> R accept(GenericVisitor<R,A> v, A arg)
Visitableaccept in interface VisitableR - the type of the return value of the visitorA - the type the user argument passed to the visitorv - the visitor implementationarg - the argument passed to the visitor (of type A)public <A> void accept(VoidVisitor<A> v, A arg)
Visitablepublic Statement getBody()
getBody in interface NodeWithBody<ForEachStmt>public Expression getIterable()
public VariableDeclarationExpr getVariable()
public ForEachStmt setBody(Statement body)
setBody in interface NodeWithBody<ForEachStmt>public ForEachStmt setIterable(Expression iterable)
public ForEachStmt setVariable(VariableDeclarationExpr variable)
public VariableDeclarator getVariableDeclarator()
getVariable()) always
has exactly one variable declarator.
Calling this method on a foreach statement forEachStmt is equivalent to calling
forEachStmt.getVariable().getVariable(0).
public boolean hasFinalVariable()
final.
Note that any foreach statement's variable declaration expression (as returned by getVariable()) always
has either no modifiers, or a single final modifier.
Calling this method on a foreach statement forEachStmt is equivalent to calling
forEachStmt.getVariable().getModifiers().isNonEmpty() &&
forEachStmt.getVariable().getModifiers().get(0).getKeyword() == Modifier.Keyword.FINAL.
true if this foreach statement's variable is final, and false otherwise.public ForEachStmt clone()
public boolean isForEachStmt()
isForEachStmt in class Statementpublic ForEachStmt asForEachStmt()
asForEachStmt in class Statementpublic Optional<ForEachStmt> toForEachStmt()
toForEachStmt in class Statementpublic void ifForEachStmt(Consumer<ForEachStmt> action)
ifForEachStmt in class Statementpublic ForEachStmtMetaModel getMetaModel()
getMetaModel in class StatementCopyright © 2007–2021. All rights reserved.