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

package lombok.ast;

public class Case extends lombok.ast.AbstractNode implements lombok.ast.Statement {
	private lombok.ast.AbstractNode condition = 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.Case 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.Case 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;
	}
	
	@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);
		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;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.condition == child) {
			this.disown((AbstractNode) child);
			this.condition = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitCase(this)) return;
		if (this.condition != null) this.condition.accept(visitor);
		visitor.afterVisitCase(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public Case copy() {
		Case result = new Case();
		if (this.condition != null) result.rawCondition(this.condition.copy());
		return result;
	}
	
}
