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

package lombok.ast;

public class Return extends lombok.ast.AbstractNode implements lombok.ast.Statement {
	private lombok.ast.AbstractNode value = 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 astValue() {
		if (!(this.value instanceof Expression)) return null;
		return (Expression) this.value;
	}
	
	public lombok.ast.Return astValue(Expression value) {
		return this.rawValue(value);
	}
	
	public lombok.ast.Node rawValue() {
		return this.value;
	}
	
	public lombok.ast.Return rawValue(lombok.ast.Node value) {
		if (value == this.value) return this;
		if (value != null) this.adopt((lombok.ast.AbstractNode)value);
		if (this.value != null) this.disown(this.value);
		this.value = (lombok.ast.AbstractNode)value;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.value != null) result.add(this.value);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.value == original) {
			this.rawValue(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.value == child) {
			this.disown((AbstractNode) child);
			this.value = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitReturn(this)) return;
		if (this.value != null) this.value.accept(visitor);
		visitor.afterVisitReturn(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public Return copy() {
		Return result = new Return();
		if (this.value != null) result.rawValue(this.value.copy());
		return result;
	}
	
}
