public final class VariableDeclarator extends Node implements NodeWithType<VariableDeclarator,Type>, NodeWithSimpleName<VariableDeclarator>
int x = 14;
Node.ObserverRegistrationMode
ABSOLUTE_BEGIN_LINE, ABSOLUTE_END_LINE, NODE_BY_BEGIN_POSITION, prettyPrinterNoCommentsConfiguration
Constructor and Description |
---|
VariableDeclarator() |
VariableDeclarator(Range range,
Type type,
SimpleName name,
Expression initializer) |
VariableDeclarator(Type type,
SimpleName name) |
VariableDeclarator(Type type,
SimpleName name,
Expression initializer)
Defines the declaration of a variable.
|
VariableDeclarator(Type type,
String variableName) |
VariableDeclarator(Type type,
String variableName,
Expression initializer) |
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.
|
Optional<Expression> |
getInitializer() |
SimpleName |
getName() |
Type |
getType()
Gets the type
|
VariableDeclarator |
setInitializer(Expression initializer)
Sets the initializer expression
|
VariableDeclarator |
setInitializer(String init)
Will create a
NameExpr with the initializer param |
VariableDeclarator |
setName(SimpleName name) |
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
getNameAsString, setName
getAncestorOfType, setAsParentNodeOf, setAsParentNodeOf
public VariableDeclarator()
public VariableDeclarator(Type type, SimpleName name)
public VariableDeclarator(Type type, SimpleName name, Expression initializer)
name
- 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(Type type, String variableName, Expression initializer)
public VariableDeclarator(Range range, Type type, SimpleName name, 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 Optional<Expression> getInitializer()
public SimpleName getName()
getName
in interface NodeWithSimpleName<VariableDeclarator>
public VariableDeclarator setName(SimpleName name)
setName
in interface NodeWithSimpleName<VariableDeclarator>
public VariableDeclarator setInitializer(Expression initializer)
initializer
- the initializer expression, can be nullpublic VariableDeclarator setInitializer(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.