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

package lombok.ast;

public class DoWhile extends lombok.ast.AbstractNode implements lombok.ast.Statement {
	private lombok.ast.AbstractNode statement = null;
	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 Statement astStatement() {
		if (!(this.statement instanceof Statement)) return null;
		return (Statement) this.statement;
	}
	
	public lombok.ast.DoWhile astStatement(Statement statement) {
		if (statement == null) throw new java.lang.NullPointerException("statement is mandatory");
		return this.rawStatement(statement);
	}
	
	public lombok.ast.Node rawStatement() {
		return this.statement;
	}
	
	public lombok.ast.DoWhile rawStatement(lombok.ast.Node statement) {
		if (statement == this.statement) return this;
		if (statement != null) this.adopt((lombok.ast.AbstractNode)statement);
		if (this.statement != null) this.disown(this.statement);
		this.statement = (lombok.ast.AbstractNode)statement;
		return this;
	}
	
	public Expression astCondition() {
		if (!(this.condition instanceof Expression)) return null;
		return (Expression) this.condition;
	}
	
	public lombok.ast.DoWhile 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.DoWhile 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.statement != null) result.add(this.statement);
		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.statement == original) {
			this.rawStatement(replacement);
			return true;
		}
		if (this.condition == original) {
			this.rawCondition(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.statement == child) {
			this.disown((AbstractNode) child);
			this.statement = null;
			return true;
		}
		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.visitDoWhile(this)) return;
		if (this.statement != null) this.statement.accept(visitor);
		if (this.condition != null) this.condition.accept(visitor);
		visitor.afterVisitDoWhile(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public DoWhile copy() {
		DoWhile result = new DoWhile();
		if (this.statement != null) result.rawStatement(this.statement.copy());
		if (this.condition != null) result.rawCondition(this.condition.copy());
		return result;
	}
	
}
