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

package lombok.ast;

public class Assert extends lombok.ast.AbstractNode implements lombok.ast.Statement {
	private lombok.ast.AbstractNode assertion = null;
	private lombok.ast.AbstractNode message = 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 astAssertion() {
		if (!(this.assertion instanceof Expression)) return null;
		return (Expression) this.assertion;
	}
	
	public lombok.ast.Assert astAssertion(Expression assertion) {
		if (assertion == null) throw new java.lang.NullPointerException("assertion is mandatory");
		return this.rawAssertion(assertion);
	}
	
	public lombok.ast.Node rawAssertion() {
		return this.assertion;
	}
	
	public lombok.ast.Assert rawAssertion(lombok.ast.Node assertion) {
		if (assertion == this.assertion) return this;
		if (assertion != null) this.adopt((lombok.ast.AbstractNode)assertion);
		if (this.assertion != null) this.disown(this.assertion);
		this.assertion = (lombok.ast.AbstractNode)assertion;
		return this;
	}
	
	public Expression astMessage() {
		if (!(this.message instanceof Expression)) return null;
		return (Expression) this.message;
	}
	
	public lombok.ast.Assert astMessage(Expression message) {
		return this.rawMessage(message);
	}
	
	public lombok.ast.Node rawMessage() {
		return this.message;
	}
	
	public lombok.ast.Assert rawMessage(lombok.ast.Node message) {
		if (message == this.message) return this;
		if (message != null) this.adopt((lombok.ast.AbstractNode)message);
		if (this.message != null) this.disown(this.message);
		this.message = (lombok.ast.AbstractNode)message;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.assertion != null) result.add(this.assertion);
		if (this.message != null) result.add(this.message);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.assertion == original) {
			this.rawAssertion(replacement);
			return true;
		}
		if (this.message == original) {
			this.rawMessage(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.assertion == child) {
			this.disown((AbstractNode) child);
			this.assertion = null;
			return true;
		}
		if (this.message == child) {
			this.disown((AbstractNode) child);
			this.message = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitAssert(this)) return;
		if (this.assertion != null) this.assertion.accept(visitor);
		if (this.message != null) this.message.accept(visitor);
		visitor.afterVisitAssert(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public Assert copy() {
		Assert result = new Assert();
		if (this.assertion != null) result.rawAssertion(this.assertion.copy());
		if (this.message != null) result.rawMessage(this.message.copy());
		return result;
	}
	
}
