//Generated by lombok.ast.template.TemplateProcessor. DO NOT EDIT, DO NOT CHECK IN!

package lombok.ast;

public class EnumConstant extends lombok.ast.AbstractNode implements lombok.ast.TypeMember, lombok.ast.DescribedNode, lombok.ast.JavadocContainer {
	private lombok.ast.AbstractNode javadoc = null;
	lombok.ast.ListAccessor<Annotation, lombok.ast.EnumConstant> annotations = ListAccessor.of(this, Annotation.class, "EnumConstant.annotations");
	private lombok.ast.AbstractNode name = adopt(new lombok.ast.Identifier());
	lombok.ast.ListAccessor<Expression, lombok.ast.EnumConstant> arguments = ListAccessor.of(this, Expression.class, "EnumConstant.arguments");
	private lombok.ast.AbstractNode body = null;
	
	public EnumTypeBody upToEnumTypeBody() {
		if (!(this.getParent() instanceof EnumTypeBody)) return null;
		EnumTypeBody out = (EnumTypeBody)this.getParent();
		if (!out.rawConstants().contains(this)) return null;
		return out;
	}
	
	public TypeBody upToTypeBody() {
		if (!(this.getParent() instanceof TypeBody)) return null;
		TypeBody out = (TypeBody)this.getParent();
		if (!out.rawMembers().contains(this)) return null;
		return out;
	}
	
	
	public Comment astJavadoc() {
		if (!(this.javadoc instanceof Comment)) return null;
		return (Comment) this.javadoc;
	}
	
	public lombok.ast.EnumConstant astJavadoc(Comment javadoc) {
		return this.rawJavadoc(javadoc);
	}
	
	public lombok.ast.Node rawJavadoc() {
		return this.javadoc;
	}
	
	public lombok.ast.EnumConstant rawJavadoc(lombok.ast.Node javadoc) {
		if (javadoc == this.javadoc) return this;
		if (javadoc != null) this.adopt((lombok.ast.AbstractNode)javadoc);
		if (this.javadoc != null) this.disown(this.javadoc);
		this.javadoc = (lombok.ast.AbstractNode)javadoc;
		return this;
	}
	
	public lombok.ast.RawListAccessor<Annotation, lombok.ast.EnumConstant> rawAnnotations() {
		return this.annotations.asRaw();
	}
	
	public lombok.ast.StrictListAccessor<Annotation, lombok.ast.EnumConstant> astAnnotations() {
		return this.annotations.asStrict();
	}
	
	public Identifier astName() {
		if (!(this.name instanceof Identifier)) return null;
		return (Identifier) this.name;
	}
	
	public lombok.ast.EnumConstant astName(Identifier name) {
		return this.rawName(name);
	}
	
	private lombok.ast.EnumConstant rawName(lombok.ast.Node name) {
		if (name == this.name) return this;
		if (name != null) this.adopt((lombok.ast.AbstractNode)name);
		if (this.name != null) this.disown(this.name);
		this.name = (lombok.ast.AbstractNode)name;
		return this;
	}
	
	public lombok.ast.RawListAccessor<Expression, lombok.ast.EnumConstant> rawArguments() {
		return this.arguments.asRaw();
	}
	
	public lombok.ast.StrictListAccessor<Expression, lombok.ast.EnumConstant> astArguments() {
		return this.arguments.asStrict();
	}
	
	public NormalTypeBody astBody() {
		if (!(this.body instanceof NormalTypeBody)) return null;
		return (NormalTypeBody) this.body;
	}
	
	public lombok.ast.EnumConstant astBody(NormalTypeBody body) {
		return this.rawBody(body);
	}
	
	public lombok.ast.Node rawBody() {
		return this.body;
	}
	
	public lombok.ast.EnumConstant rawBody(lombok.ast.Node body) {
		if (body == this.body) return this;
		if (body != null) this.adopt((lombok.ast.AbstractNode)body);
		if (this.body != null) this.disown(this.body);
		this.body = (lombok.ast.AbstractNode)body;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.javadoc != null) result.add(this.javadoc);
		result.addAll(this.annotations.backingList());
		if (this.name != null) result.add(this.name);
		result.addAll(this.arguments.backingList());
		if (this.body != null) result.add(this.body);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.javadoc == original) {
			this.rawJavadoc(replacement);
			return true;
		}
		if (this.rawAnnotations().replace(original, replacement)) return true;
		if (this.name == original) {
			if (replacement instanceof Identifier) {
				this.astName((Identifier) replacement);
				return true;
			} else throw new lombok.ast.AstException(this, String.format(
					"Cannot replace node: replacement must be of type %s but is of type %s",
					"Identifier", replacement == null ? "null" : replacement.getClass().getName()));
		}
		if (this.rawArguments().replace(original, replacement)) return true;
		if (this.body == original) {
			this.rawBody(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.javadoc == child) {
			this.disown((AbstractNode) child);
			this.javadoc = null;
			return true;
		}
		if (this.rawAnnotations().remove(child)) return true;
		if (this.name == child) {
			this.disown((AbstractNode) child);
			this.name = null;
			return true;
		}
		if (this.rawArguments().remove(child)) return true;
		if (this.body == child) {
			this.disown((AbstractNode) child);
			this.body = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitEnumConstant(this)) return;
		if (this.javadoc != null) this.javadoc.accept(visitor);
		for (lombok.ast.Node child : this.annotations.asIterable()) {
			child.accept(visitor);
		}
		if (this.name != null) this.name.accept(visitor);
		for (lombok.ast.Node child : this.arguments.asIterable()) {
			child.accept(visitor);
		}
		if (this.body != null) this.body.accept(visitor);
		visitor.afterVisitEnumConstant(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public EnumConstant copy() {
		EnumConstant result = new EnumConstant();
		if (this.javadoc != null) result.rawJavadoc(this.javadoc.copy());
		for (Node n : this.annotations.backingList()) {
			result.rawAnnotations().addToEnd(n == null ? null : n.copy());
		}
		if (this.name != null) result.rawName(this.name.copy());
		for (Node n : this.arguments.backingList()) {
			result.rawArguments().addToEnd(n == null ? null : n.copy());
		}
		if (this.body != null) result.rawBody(this.body.copy());
		return result;
	}
	
	public java.lang.String getDescription() {
		return lombok.ast.EnumConstantTemplate.getDescription(this);
	}
	
	public lombok.ast.TypeDeclaration upUpToTypeDeclaration() {
		return lombok.ast.TypeMemberMixin.upUpToTypeDeclaration(this);
	}
	
}
