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

package lombok.ast;

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