Class EnumDecl
- java.lang.Object
-
- com.tonic.analysis.source.ast.decl.EnumDecl
-
-
Constructor Summary
Constructors Constructor Description EnumDecl(String name)Creates an empty enum declaration at an unknown location.EnumDecl(String name, SourceLocation location)Creates an empty enum declaration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.EnumDecladdAnnotation(AnnotationExpr annotation)Adds an annotation.EnumDecladdConstant(EnumConstantDecl constant)Adds an enum constant.EnumDecladdConstructor(ConstructorDecl constructor)Adds a constructor.EnumDecladdField(FieldDecl field)Adds a field member.EnumDecladdInnerType(TypeDecl innerType)Adds a nested type.EnumDecladdInterface(SourceType iface)Adds an implemented interface.EnumDecladdMethod(MethodDecl method)Adds a method member.EnumDecladdModifier(Modifier modifier)Adds a modifier.NodeList<AnnotationExpr>getAnnotations()List<ASTNode>getChildren()Lists the direct children a node holds, in source order.EnumConstantDeclgetConstant(String name)Finds an enum constant by name.NodeList<EnumConstantDecl>getConstants()NodeList<ConstructorDecl>getConstructors()NodeList<FieldDecl>getFields()NodeList<TypeDecl>getInnerTypes()NodeList<SourceType>getInterfaces()SourceLocationgetLocation()Gets the source location of this node.NodeList<MethodDecl>getMethods()Set<Modifier>getModifiers()StringgetName()ASTNodegetParent()Gets the parent node in the AST tree.voidsetName(String name)Sets the enum name.voidsetParent(ASTNode parent)Sets the parent node.StringtoString()EnumDeclwithModifiers(Set<Modifier> modifiers)Replaces all modifiers with the given set.EnumDeclwithName(String name)Sets the enum 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
-
Methods inherited from interface com.tonic.analysis.source.ast.decl.TypeDecl
getField, getInnerType, getMethod, isAbstract, isFinal, isPrivate, isProtected, isPublic, isStatic
-
-
-
-
Constructor Detail
-
EnumDecl
public EnumDecl(String name, SourceLocation location)
Creates an empty enum declaration.- Parameters:
name- the simple enum namelocation- the source location, or null for unknown
-
EnumDecl
public EnumDecl(String name)
Creates an empty enum declaration at an unknown location.- Parameters:
name- the simple enum name
-
-
Method Detail
-
setName
public void setName(String name)
Sets the enum name.- Parameters:
name- the simple enum name
-
getModifiers
public Set<Modifier> getModifiers()
- Specified by:
getModifiersin interfaceTypeDecl- Returns:
- the modifiers
-
getAnnotations
public NodeList<AnnotationExpr> getAnnotations()
- Specified by:
getAnnotationsin interfaceTypeDecl- Returns:
- the annotations
-
getInterfaces
public NodeList<SourceType> getInterfaces()
- Returns:
- the interfaces
-
getConstants
public NodeList<EnumConstantDecl> getConstants()
- Returns:
- the constants
-
getMethods
public NodeList<MethodDecl> getMethods()
- Specified by:
getMethodsin interfaceTypeDecl- Returns:
- the methods
-
getConstructors
public NodeList<ConstructorDecl> getConstructors()
- Returns:
- the constructors
-
getInnerTypes
public NodeList<TypeDecl> getInnerTypes()
- Specified by:
getInnerTypesin interfaceTypeDecl- Returns:
- the inner types
-
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 EnumDecl withName(String name)
Sets the enum name.- Parameters:
name- the simple enum name- Returns:
- this declaration
-
withModifiers
public EnumDecl withModifiers(Set<Modifier> modifiers)
Replaces all modifiers with the given set.- Parameters:
modifiers- the modifiers to apply- Returns:
- this declaration
-
addModifier
public EnumDecl addModifier(Modifier modifier)
Adds a modifier.- Parameters:
modifier- the modifier to add- Returns:
- this declaration
-
addAnnotation
public EnumDecl addAnnotation(AnnotationExpr annotation)
Adds an annotation.- Parameters:
annotation- the annotation to add- Returns:
- this declaration
-
addInterface
public EnumDecl addInterface(SourceType iface)
Adds an implemented interface.- Parameters:
iface- the interface type- Returns:
- this declaration
-
addConstant
public EnumDecl addConstant(EnumConstantDecl constant)
Adds an enum constant.- Parameters:
constant- the constant declaration- Returns:
- this declaration
-
addField
public EnumDecl addField(FieldDecl field)
Adds a field member.- Parameters:
field- the field declaration- Returns:
- this declaration
-
addMethod
public EnumDecl addMethod(MethodDecl method)
Adds a method member.- Parameters:
method- the method declaration- Returns:
- this declaration
-
addConstructor
public EnumDecl addConstructor(ConstructorDecl constructor)
Adds a constructor.- Parameters:
constructor- the constructor declaration- Returns:
- this declaration
-
addInnerType
public EnumDecl addInnerType(TypeDecl innerType)
Adds a nested type.- Parameters:
innerType- the nested type declaration- Returns:
- this declaration
-
getConstant
public EnumConstantDecl getConstant(String name)
Finds an enum constant by name.- Parameters:
name- the constant name- Returns:
- the matching constant, or null if none
-
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.
-
-