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

package lombok.ast;

public class ArrayDimension extends lombok.ast.AbstractNode {
	private lombok.ast.AbstractNode dimension = null;
	
	public ArrayCreation upToArrayCreation() {
		if (!(this.getParent() instanceof ArrayCreation)) return null;
		ArrayCreation out = (ArrayCreation)this.getParent();
		if (!out.rawDimensions().contains(this)) return null;
		return out;
	}
	
	
	public Expression astDimension() {
		if (!(this.dimension instanceof Expression)) return null;
		return (Expression) this.dimension;
	}
	
	public lombok.ast.ArrayDimension astDimension(Expression dimension) {
		return this.rawDimension(dimension);
	}
	
	public lombok.ast.Node rawDimension() {
		return this.dimension;
	}
	
	public lombok.ast.ArrayDimension rawDimension(lombok.ast.Node dimension) {
		if (dimension == this.dimension) return this;
		if (dimension != null) this.adopt((lombok.ast.AbstractNode)dimension);
		if (this.dimension != null) this.disown(this.dimension);
		this.dimension = (lombok.ast.AbstractNode)dimension;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.dimension != null) result.add(this.dimension);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.dimension == original) {
			this.rawDimension(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.dimension == child) {
			this.disown((AbstractNode) child);
			this.dimension = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitArrayDimension(this)) return;
		if (this.dimension != null) this.dimension.accept(visitor);
		visitor.afterVisitArrayDimension(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public ArrayDimension copy() {
		ArrayDimension result = new ArrayDimension();
		if (this.dimension != null) result.rawDimension(this.dimension.copy());
		return result;
	}
	
}
