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

package lombok.ast;

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