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

package lombok.ast;

public class VariableReference 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 identifier = adopt(new lombok.ast.Identifier());
	
	public java.util.List<lombok.ast.Position> astParensPositions() {
		return this.parensPositions;
	}
	
	public Identifier astIdentifier() {
		if (!(this.identifier instanceof Identifier)) return null;
		return (Identifier) this.identifier;
	}
	
	public lombok.ast.VariableReference astIdentifier(Identifier identifier) {
		return this.rawIdentifier(identifier);
	}
	
	private lombok.ast.VariableReference rawIdentifier(lombok.ast.Node identifier) {
		if (identifier == this.identifier) return this;
		if (identifier != null) this.adopt((lombok.ast.AbstractNode)identifier);
		if (this.identifier != null) this.disown(this.identifier);
		this.identifier = (lombok.ast.AbstractNode)identifier;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.identifier != null) result.add(this.identifier);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.identifier == original) {
			if (replacement instanceof Identifier) {
				this.astIdentifier((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()));
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.identifier == child) {
			this.disown((AbstractNode) child);
			this.identifier = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitVariableReference(this)) return;
		if (this.identifier != null) this.identifier.accept(visitor);
		visitor.afterVisitVariableReference(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public VariableReference copy() {
		VariableReference result = new VariableReference();
		result.parensPositions = new java.util.ArrayList<lombok.ast.Position>(this.parensPositions);
		if (this.identifier != null) result.rawIdentifier(this.identifier.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);
	}
	
}
