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

package lombok.ast;

public class Cast 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 typeReference = null;
	private lombok.ast.AbstractNode operand = null;
	
	public java.util.List<lombok.ast.Position> astParensPositions() {
		return this.parensPositions;
	}
	
	public TypeReference astTypeReference() {
		if (!(this.typeReference instanceof TypeReference)) return null;
		return (TypeReference) this.typeReference;
	}
	
	public lombok.ast.Cast astTypeReference(TypeReference typeReference) {
		if (typeReference == null) throw new java.lang.NullPointerException("typeReference is mandatory");
		return this.rawTypeReference(typeReference);
	}
	
	public lombok.ast.Node rawTypeReference() {
		return this.typeReference;
	}
	
	public lombok.ast.Cast rawTypeReference(lombok.ast.Node typeReference) {
		if (typeReference == this.typeReference) return this;
		if (typeReference != null) this.adopt((lombok.ast.AbstractNode)typeReference);
		if (this.typeReference != null) this.disown(this.typeReference);
		this.typeReference = (lombok.ast.AbstractNode)typeReference;
		return this;
	}
	
	public Expression astOperand() {
		if (!(this.operand instanceof Expression)) return null;
		return (Expression) this.operand;
	}
	
	public lombok.ast.Cast 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.Cast 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;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.typeReference != null) result.add(this.typeReference);
		if (this.operand != null) result.add(this.operand);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.typeReference == original) {
			this.rawTypeReference(replacement);
			return true;
		}
		if (this.operand == original) {
			this.rawOperand(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.typeReference == child) {
			this.disown((AbstractNode) child);
			this.typeReference = null;
			return true;
		}
		if (this.operand == child) {
			this.disown((AbstractNode) child);
			this.operand = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitCast(this)) return;
		if (this.typeReference != null) this.typeReference.accept(visitor);
		if (this.operand != null) this.operand.accept(visitor);
		visitor.afterVisitCast(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public Cast copy() {
		Cast result = new Cast();
		result.parensPositions = new java.util.ArrayList<lombok.ast.Position>(this.parensPositions);
		if (this.typeReference != null) result.rawTypeReference(this.typeReference.copy());
		if (this.operand != null) result.rawOperand(this.operand.copy());
		return result;
	}
	
	public boolean needsParentheses() {
		return lombok.ast.CastTemplate.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);
	}
	
}
