public final class VariableDeclarator extends Node implements NodeWithType<VariableDeclarator,Type<?>>, NodeWithVariableDeclaratorId<VariableDeclarator>
Node.ObserverRegistrationMode
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration
Constructor and Description |
---|
VariableDeclarator() |
VariableDeclarator(Range range,
VariableDeclaratorId identifier,
Expression initializer) |
VariableDeclarator(String variableName) |
VariableDeclarator(String variableName,
Expression initializer) |
VariableDeclarator(VariableDeclaratorId identifier) |
VariableDeclarator(VariableDeclaratorId identifier,
Expression initializer)
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 |
getIdentifier() |
Optional<Expression> |
getInitializer() |
Type |
getType()
Gets the type
|
VariableDeclarator |
setIdentifier(VariableDeclaratorId identifier) |
VariableDeclarator |
setInit(String init)
Will create a
NameExpr with the initializer param |
VariableDeclarator |
setInitializer(Expression initializer)
Sets the initializer expression
|
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, setBlockComment, setComment, setData, setLineComment, setParentNode, setRange, toString, toString, tryAddImportToParentCompilationUnit, unregister
finalize, getClass, notify, notifyAll, wait, wait, wait
setType, setType
getIdentifierAsString, setIdentifier
getAncestorOfType, setAsParentNodeOf, setAsParentNodeOf
public VariableDeclarator()
public VariableDeclarator(VariableDeclaratorId identifier)
public VariableDeclarator(String variableName)
public VariableDeclarator(VariableDeclaratorId identifier, Expression initializer)
identifier
- The identifier for this variable. IE. The variables name.initializer
- What this variable should be initialized to. An AssignExpr
is
unnecessary as the =
operator is already added.public VariableDeclarator(String variableName, Expression initializer)
public VariableDeclarator(Range range, VariableDeclaratorId identifier, Expression initializer)
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 getIdentifier()
getIdentifier
in interface NodeWithVariableDeclaratorId<VariableDeclarator>
public Optional<Expression> getInitializer()
public VariableDeclarator setIdentifier(VariableDeclaratorId identifier)
setIdentifier
in interface NodeWithVariableDeclaratorId<VariableDeclarator>
public VariableDeclarator setInitializer(Expression initializer)
initializer
- the initializer expression, can be nullpublic VariableDeclarator setInit(String init)
NameExpr
with the initializer paraminit
- the initializer 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.