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

package lombok.ast;

public class ArrayAccess extends lombok.ast.AbstractNode implements lombok.ast.Expression {
	private java.util.List<lombok.ast.Position> parensPositions = new java.util.ArrayList<lombok.ast.Position>();
	private lombok.ast.AbstractNode operand = null;
	private lombok.ast.AbstractNode indexExpression = null;
	
	public java.util.List<lombok.ast.Position> astParensPositions() {
		return this.parensPositions;
	}
	
	public Expression astOperand() {
		if (!(this.operand instanceof Expression)) return null;
		return (Expression) this.operand;
	}
	
	public lombok.ast.ArrayAccess astOperand(Expression operand) {
		if (operand == null) throw new java.lang.NullPointerException("operand is mandatory");
		return this.rawOperand(operand);
	}
	
	public lombok.ast.Node rawOperand() {
		return this.operand;
	}
	
	public lombok.ast.ArrayAccess rawOperand(lombok.ast.Node operand) {
		if (operand == this.operand) return this;
		if (operand != null) this.adopt((lombok.ast.AbstractNode)operand);
		if (this.operand != null) this.disown(this.operand);
		this.operand = (lombok.ast.AbstractNode)operand;
		return this;
	}
	
	public Expression astIndexExpression() {
		if (!(this.indexExpression instanceof Expression)) return null;
		return (Expression) this.indexExpression;
	}
	
	public lombok.ast.ArrayAccess astIndexExpression(Expression indexExpression) {
		if (indexExpression == null) throw new java.lang.NullPointerException("indexExpression is mandatory");
		return this.rawIndexExpression(indexExpression);
	}
	
	public lombok.ast.Node rawIndexExpression() {
		return this.indexExpression;
	}
	
	public lombok.ast.ArrayAccess rawIndexExpression(lombok.ast.Node indexExpression) {
		if (indexExpression == this.indexExpression) return this;
		if (indexExpression != null) this.adopt((lombok.ast.AbstractNode)indexExpression);
		if (this.indexExpression != null) this.disown(this.indexExpression);
		this.indexExpression = (lombok.ast.AbstractNode)indexExpression;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.operand != null) result.add(this.operand);
		if (this.indexExpression != null) result.add(this.indexExpression);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.operand == original) {
			this.rawOperand(replacement);
			return true;
		}
		if (this.indexExpression == original) {
			this.rawIndexExpression(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.operand == child) {
			this.disown((AbstractNode) child);
			this.operand = null;
			return true;
		}
		if (this.indexExpression == child) {
			this.disown((AbstractNode) child);
			this.indexExpression = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitArrayAccess(this)) return;
		if (this.operand != null) this.operand.accept(visitor);
		if (this.indexExpression != null) this.indexExpression.accept(visitor);
		visitor.afterVisitArrayAccess(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public ArrayAccess copy() {
		ArrayAccess result = new ArrayAccess();
		result.parensPositions = new java.util.ArrayList<lombok.ast.Position>(this.parensPositions);
		if (this.operand != null) result.rawOperand(this.operand.copy());
		if (this.indexExpression != null) result.rawIndexExpression(this.indexExpression.copy());
		return result;
	}
	
	public int getParens() {
		return lombok.ast.ExpressionMixin.getParens(this);
	}
	
	public int getIntendedParens() {
		return lombok.ast.ExpressionMixin.getIntendedParens(this);
	}
	
	public boolean needsParentheses() {
		return lombok.ast.ExpressionMixin.needsParentheses(this);
	}
	
	public boolean isStatementExpression() {
		return lombok.ast.ExpressionMixin.isStatementExpression(this);
	}
	
}
