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

package lombok.ast;

public class Select 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 identifier = adopt(new lombok.ast.Identifier());
	
	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.Select 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.Select 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 Identifier astIdentifier() {
		if (!(this.identifier instanceof Identifier)) return null;
		return (Identifier) this.identifier;
	}
	
	public lombok.ast.Select astIdentifier(Identifier identifier) {
		return this.rawIdentifier(identifier);
	}
	
	private lombok.ast.Select 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.operand != null) result.add(this.operand);
		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.operand == original) {
			this.rawOperand(replacement);
			return true;
		}
		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.operand == child) {
			this.disown((AbstractNode) child);
			this.operand = null;
			return true;
		}
		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.visitSelect(this)) return;
		if (this.operand != null) this.operand.accept(visitor);
		if (this.identifier != null) this.identifier.accept(visitor);
		visitor.afterVisitSelect(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public Select copy() {
		Select result = new Select();
		result.parensPositions = new java.util.ArrayList<lombok.ast.Position>(this.parensPositions);
		if (this.operand != null) result.rawOperand(this.operand.copy());
		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);
	}
	
}
