public final class VariableDeclarator extends Node implements NodeWithType<VariableDeclarator,Type<?>>
Node.ObserverRegistrationMode
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration
Constructor and Description |
---|
VariableDeclarator() |
VariableDeclarator(Range range,
VariableDeclaratorId id,
Expression init) |
VariableDeclarator(String variableName) |
VariableDeclarator(String variableName,
Expression init) |
VariableDeclarator(VariableDeclaratorId id) |
VariableDeclarator(VariableDeclaratorId id,
Expression init)
Defines the declaration of a variable.
|
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.
|
VariableDeclaratorId |
getId() |
Optional<Expression> |
getInit() |
Type |
getType()
Gets the type
|
VariableDeclarator |
setId(VariableDeclaratorId id) |
VariableDeclarator |
setInit(Expression init)
Sets the init expression
|
VariableDeclarator |
setInit(String init)
Will create a
NameExpr with the init param |
VariableDeclarator |
setType(Type<?> type)
Sets the type
|
addOrphanComment, clone, containsWithin, equals, getAllContainedComments, getBegin, getChildNodes, getComment, getData, getEnd, getNodeLists, getNodesByType, getOrphanComments, getParentNode, getParentNodeForChildren, getRange, hasComment, hashCode, isPositionedAfter, isPositionedBefore, isRegistered, notifyPropertyChange, register, register, registerForSubtree, remove, setAsParentNodeOf, setBegin, setBlockComment, setComment, setData, setEnd, setLineComment, setParentNode, setRange, toString, toString, tryAddImportToParentCompilationUnit, unregister
finalize, getClass, notify, notifyAll, wait, wait, wait
setType, setType
getAncestorOfType, setAsParentNodeOf, setAsParentNodeOf
public VariableDeclarator()
public VariableDeclarator(VariableDeclaratorId id)
public VariableDeclarator(String variableName)
public VariableDeclarator(VariableDeclaratorId id, Expression init)
id
- The identifier for this variable. IE. The variables name.init
- What this variable should be initialized to.
An AssignExpr
is unnecessary as the =
operator is
already added.public VariableDeclarator(String variableName, Expression init)
public VariableDeclarator(Range range, VariableDeclaratorId id, Expression init)
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 VariableDeclaratorId getId()
public Optional<Expression> getInit()
public VariableDeclarator setId(VariableDeclaratorId id)
public VariableDeclarator setInit(Expression init)
init
- the init expression, can be nullpublic VariableDeclarator setInit(String init)
NameExpr
with the init paraminit
- the init expression, can be nullpublic Type getType()
NodeWithType
getType
in interface NodeWithType<VariableDeclarator,Type<?>>
public VariableDeclarator setType(Type<?> type)
NodeWithType
setType
in interface NodeWithType<VariableDeclarator,Type<?>>
type
- the typeCopyright © 2007–2016. All rights reserved.