Class EnumConstantDecl
- java.lang.Object
-
- com.tonic.analysis.source.ast.decl.EnumConstantDecl
-
-
Constructor Summary
Constructors Constructor Description EnumConstantDecl(String name)Creates an enum constant at an unknown location.EnumConstantDecl(String name, SourceLocation location)Creates an enum constant with no arguments or body.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.EnumConstantDecladdAnnotation(AnnotationExpr annotation)Adds an annotation.EnumConstantDecladdArgument(Expression argument)Adds a constructor argument.EnumConstantDecladdField(FieldDecl field)Adds a field to the constant's class body.EnumConstantDecladdMethod(MethodDecl method)Adds a method to the constant's class body.NodeList<AnnotationExpr>getAnnotations()NodeList<Expression>getArguments()List<ASTNode>getChildren()Lists the direct children a node holds, in source order.NodeList<FieldDecl>getFields()SourceLocationgetLocation()Gets the source location of this node.NodeList<MethodDecl>getMethods()StringgetName()ASTNodegetParent()Gets the parent node in the AST tree.booleanhasArguments()booleanhasBody()voidsetName(String name)Sets the constant name.voidsetParent(ASTNode parent)Sets the parent node.StringtoString()EnumConstantDeclwithName(String name)Sets the constant name.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.tonic.analysis.source.ast.ASTNode
deepClone, findAll, findAll, findAncestor, findFirst, findFirst, getRoot, isDescendantOf, remove, replaceWith, stream, stream, walk
-
-
-
-
Constructor Detail
-
EnumConstantDecl
public EnumConstantDecl(String name, SourceLocation location)
Creates an enum constant with no arguments or body.- Parameters:
name- the constant namelocation- the source location, or null for unknown
-
EnumConstantDecl
public EnumConstantDecl(String name)
Creates an enum constant at an unknown location.- Parameters:
name- the constant name
-
-
Method Detail
-
getName
public String getName()
- Returns:
- the name
-
setName
public void setName(String name)
Sets the constant name.- Parameters:
name- the constant name
-
getAnnotations
public NodeList<AnnotationExpr> getAnnotations()
- Returns:
- the annotations
-
getArguments
public NodeList<Expression> getArguments()
- Returns:
- the arguments
-
getMethods
public NodeList<MethodDecl> getMethods()
- Returns:
- the methods
-
getLocation
public SourceLocation getLocation()
Description copied from interface:ASTNodeGets the source location of this node.- Specified by:
getLocationin interfaceASTNode- Returns:
- the location
-
getParent
public ASTNode getParent()
Description copied from interface:ASTNodeGets the parent node in the AST tree.
-
setParent
public void setParent(ASTNode parent)
Sets the parent node.
-
withName
public EnumConstantDecl withName(String name)
Sets the constant name.- Parameters:
name- the constant name- Returns:
- this declaration
-
addAnnotation
public EnumConstantDecl addAnnotation(AnnotationExpr annotation)
Adds an annotation.- Parameters:
annotation- the annotation to add- Returns:
- this declaration
-
addArgument
public EnumConstantDecl addArgument(Expression argument)
Adds a constructor argument.- Parameters:
argument- the argument expression- Returns:
- this declaration
-
addMethod
public EnumConstantDecl addMethod(MethodDecl method)
Adds a method to the constant's class body.- Parameters:
method- the method declaration- Returns:
- this declaration
-
addField
public EnumConstantDecl addField(FieldDecl field)
Adds a field to the constant's class body.- Parameters:
field- the field declaration- Returns:
- this declaration
-
hasArguments
public boolean hasArguments()
- Returns:
- true if the constant passes constructor arguments
-
hasBody
public boolean hasBody()
- Returns:
- true if the constant declares a class body
-
getChildren
public List<ASTNode> getChildren()
Description copied from interface:ASTNodeLists the direct children a node holds, in source order.- Specified by:
getChildrenin interfaceASTNode- Returns:
- the direct children, empty for a leaf
-
accept
public <T> T accept(SourceVisitor<T> visitor)
Description copied from interface:ASTNodeAccepts a visitor for this node.
-
-