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

package lombok.ast;

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