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

package lombok.ast;

public class Continue extends lombok.ast.AbstractNode implements lombok.ast.Statement {
	private lombok.ast.AbstractNode label = 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 Identifier astLabel() {
		if (!(this.label instanceof Identifier)) return null;
		return (Identifier) this.label;
	}
	
	public lombok.ast.Continue astLabel(Identifier label) {
		return this.rawLabel(label);
	}
	
	private lombok.ast.Continue rawLabel(lombok.ast.Node label) {
		if (label == this.label) return this;
		if (label != null) this.adopt((lombok.ast.AbstractNode)label);
		if (this.label != null) this.disown(this.label);
		this.label = (lombok.ast.AbstractNode)label;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.label != null) result.add(this.label);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.label == original) {
			if (replacement instanceof Identifier) {
				this.astLabel((Identifier) replacement);
				return true;
			} else throw new lombok.ast.AstException(this, String.format(
					"Cannot replace node: replacement must be of type %s but is of type %s",
					"Identifier", replacement == null ? "null" : replacement.getClass().getName()));
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.label == child) {
			this.disown((AbstractNode) child);
			this.label = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitContinue(this)) return;
		if (this.label != null) this.label.accept(visitor);
		visitor.afterVisitContinue(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public Continue copy() {
		Continue result = new Continue();
		if (this.label != null) result.rawLabel(this.label.copy());
		return result;
	}
	
	public boolean hasLabel() {
		return lombok.ast.ContinueTemplate.hasLabel(this);
	}
	
}
