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.TreeTraversal
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration, 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, toYieldStmt
addOrphanComment, containsData, customInitialization, equals, findAll, findAll, findCompilationUnit, findFirst, findFirst, findFirst, findRootNode, getAllContainedComments, getChildNodes, getChildNodesByType, getComment, getData, getDataKeys, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getParsed, getRange, getSymbolResolver, getTokenRange, getToStringPrettyPrinterConfiguration, hashCode, isAncestorOf, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, removeComment, removeData, removeForced, removeOrphanComment, replace, setAsParentNodeOf, setAsParentNodeOf, setBlockComment, setComment, setData, setLineComment, setParentNode, setParsed, setRange, setTokenRange, setToStringPrettyPrinterConfiguration, stream, stream, toString, toString, tryAddImportToParentCompilationUnit, unregister, walk, walk, walk
finalize, getClass, notify, notifyAll, wait, wait, wait
createBlockStatementAsBody, hasEmptyBody
findAncestor, findAncestor, isDescendantOf
containsWithin, containsWithinRange, getBegin, getEnd
public 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)
Visitable
accept
in interface Visitable
R
- 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)
Visitable
public 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 Statement
public ForEachStmt asForEachStmt()
asForEachStmt
in class Statement
public Optional<ForEachStmt> toForEachStmt()
toForEachStmt
in class Statement
public void ifForEachStmt(Consumer<ForEachStmt> action)
ifForEachStmt
in class Statement
public ForEachStmtMetaModel getMetaModel()
getMetaModel
in class Statement
Copyright © 2007–2019. All rights reserved.