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

package lombok.ast;

public class Switch extends lombok.ast.AbstractNode implements lombok.ast.Statement {
	private lombok.ast.AbstractNode condition = null;
	private lombok.ast.AbstractNode body = null;
	
	public Block upToBlock() {
		if (!(this.getParent() instanceof Block)) return null;
		Block out = (Block)this.getParent();
		if (!out.rawContents().contains(this)) return null;
		return out;
	}
	
	
	public Expression astCondition() {
		if (!(this.condition instanceof Expression)) return null;
		return (Expression) this.condition;
	}
	
	public lombok.ast.Switch astCondition(Expression condition) {
		if (condition == null) throw new java.lang.NullPointerException("condition is mandatory");
		return this.rawCondition(condition);
	}
	
	public lombok.ast.Node rawCondition() {
		return this.condition;
	}
	
	public lombok.ast.Switch rawCondition(lombok.ast.Node condition) {
		if (condition == this.condition) return this;
		if (condition != null) this.adopt((lombok.ast.AbstractNode)condition);
		if (this.condition != null) this.disown(this.condition);
		this.condition = (lombok.ast.AbstractNode)condition;
		return this;
	}
	
	public Block astBody() {
		if (!(this.body instanceof Block)) return null;
		return (Block) this.body;
	}
	
	public lombok.ast.Switch astBody(Block body) {
		if (body == null) throw new java.lang.NullPointerException("body is mandatory");
		return this.rawBody(body);
	}
	
	public lombok.ast.Node rawBody() {
		return this.body;
	}
	
	public lombok.ast.Switch rawBody(lombok.ast.Node body) {
		if (body == this.body) return this;
		if (body != null) this.adopt((lombok.ast.AbstractNode)body);
		if (this.body != null) this.disown(this.body);
		this.body = (lombok.ast.AbstractNode)body;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.condition != null) result.add(this.condition);
		if (this.body != null) result.add(this.body);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.condition == original) {
			this.rawCondition(replacement);
			return true;
		}
		if (this.body == original) {
			this.rawBody(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.condition == child) {
			this.disown((AbstractNode) child);
			this.condition = null;
			return true;
		}
		if (this.body == child) {
			this.disown((AbstractNode) child);
			this.body = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitSwitch(this)) return;
		if (this.condition != null) this.condition.accept(visitor);
		if (this.body != null) this.body.accept(visitor);
		visitor.afterVisitSwitch(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public Switch copy() {
		Switch result = new Switch();
		if (this.condition != null) result.rawCondition(this.condition.copy());
		if (this.body != null) result.rawBody(this.body.copy());
		return result;
	}
	
}
