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

package lombok.ast;

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