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

package lombok.ast;

public class BinaryExpression extends lombok.ast.AbstractNode implements lombok.ast.Expression, lombok.ast.DescribedNode {
	private java.util.List<lombok.ast.Position> parensPositions = new java.util.ArrayList<lombok.ast.Position>();
	private lombok.ast.AbstractNode left = null;
	private BinaryOperator operator = null;
	private java.lang.String rawOperator;
	private java.lang.String errorReasonForOperator = "missing operator";
	private lombok.ast.AbstractNode right = null;
	
	public java.util.List<lombok.ast.Position> astParensPositions() {
		return this.parensPositions;
	}
	
	public Expression astLeft() {
		if (!(this.left instanceof Expression)) return null;
		return (Expression) this.left;
	}
	
	public lombok.ast.BinaryExpression astLeft(Expression left) {
		if (left == null) throw new java.lang.NullPointerException("left is mandatory");
		return this.rawLeft(left);
	}
	
	public lombok.ast.Node rawLeft() {
		return this.left;
	}
	
	public lombok.ast.BinaryExpression rawLeft(lombok.ast.Node left) {
		if (left == this.left) return this;
		if (left != null) this.adopt((lombok.ast.AbstractNode)left);
		if (this.left != null) this.disown(this.left);
		this.left = (lombok.ast.AbstractNode)left;
		return this;
	}
	
	public BinaryOperator astOperator() {
		if (this.errorReasonForOperator != null) return null;
		return this.operator;
	}
	
	public lombok.ast.BinaryExpression astOperator(BinaryOperator operator) {
		if (operator == null) throw new java.lang.NullPointerException("operator is mandatory");
		this.errorReasonForOperator = null;
		this.operator = operator;
		this.rawOperator = lombok.ast.BinaryExpressionTemplate.generateOperator(operator);
		return this;
	}
	
	public java.lang.String rawOperator() {
		return this.rawOperator;
	}
	
	public java.lang.String getErrorReasonForOperator() {
		return this.errorReasonForOperator;
	}
	
	public lombok.ast.BinaryExpression rawOperator(java.lang.String operator) {
		this.rawOperator = operator;
		this.operator = null;
		this.errorReasonForOperator = null;
		try {
			this.operator = lombok.ast.BinaryExpressionTemplate.parseOperator(operator);
		} catch (java.lang.IllegalArgumentException e) {
			this.errorReasonForOperator = e.getMessage() == null ? e.toString() : e.getMessage();
		} catch (Exception e) {
			this.errorReasonForOperator = e.toString();
		}
		return this;
	}
	public Expression astRight() {
		if (!(this.right instanceof Expression)) return null;
		return (Expression) this.right;
	}
	
	public lombok.ast.BinaryExpression astRight(Expression right) {
		if (right == null) throw new java.lang.NullPointerException("right is mandatory");
		return this.rawRight(right);
	}
	
	public lombok.ast.Node rawRight() {
		return this.right;
	}
	
	public lombok.ast.BinaryExpression rawRight(lombok.ast.Node right) {
		if (right == this.right) return this;
		if (right != null) this.adopt((lombok.ast.AbstractNode)right);
		if (this.right != null) this.disown(this.right);
		this.right = (lombok.ast.AbstractNode)right;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.left != null) result.add(this.left);
		if (this.right != null) result.add(this.right);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.left == original) {
			this.rawLeft(replacement);
			return true;
		}
		if (this.right == original) {
			this.rawRight(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.left == child) {
			this.disown((AbstractNode) child);
			this.left = null;
			return true;
		}
		if (this.right == child) {
			this.disown((AbstractNode) child);
			this.right = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitBinaryExpression(this)) return;
		if (this.left != null) this.left.accept(visitor);
		if (this.right != null) this.right.accept(visitor);
		visitor.afterVisitBinaryExpression(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public BinaryExpression copy() {
		BinaryExpression result = new BinaryExpression();
		result.parensPositions = new java.util.ArrayList<lombok.ast.Position>(this.parensPositions);
		if (this.left != null) result.rawLeft(this.left.copy());
		result.operator = this.operator;
		result.rawOperator = this.rawOperator;
		result.errorReasonForOperator = this.errorReasonForOperator;
		if (this.right != null) result.rawRight(this.right.copy());
		return result;
	}
	
	public java.lang.String getDescription() {
		return lombok.ast.BinaryExpressionTemplate.getDescription(this);
	}
	
	public boolean needsParentheses() {
		return lombok.ast.BinaryExpressionTemplate.needsParentheses(this);
	}
	
	public int getParens() {
		return lombok.ast.ExpressionMixin.getParens(this);
	}
	
	public int getIntendedParens() {
		return lombok.ast.ExpressionMixin.getIntendedParens(this);
	}
	
	public boolean isStatementExpression() {
		return lombok.ast.ExpressionMixin.isStatementExpression(this);
	}
	
}
