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

package lombok.ast;

public class For extends lombok.ast.AbstractNode implements lombok.ast.Statement {
	lombok.ast.ListAccessor<Expression, lombok.ast.For> expressionInits = ListAccessor.of(this, Expression.class, "For.expressionInits");
	private lombok.ast.AbstractNode variableDeclaration = null;
	private lombok.ast.AbstractNode condition = null;
	lombok.ast.ListAccessor<Expression, lombok.ast.For> updates = ListAccessor.of(this, Expression.class, "For.updates");
	private lombok.ast.AbstractNode statement = 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 lombok.ast.RawListAccessor<Expression, lombok.ast.For> rawExpressionInits() {
		return this.expressionInits.asRaw();
	}
	
	public lombok.ast.StrictListAccessor<Expression, lombok.ast.For> astExpressionInits() {
		return this.expressionInits.asStrict();
	}
	
	public VariableDefinition astVariableDeclaration() {
		if (!(this.variableDeclaration instanceof VariableDefinition)) return null;
		return (VariableDefinition) this.variableDeclaration;
	}
	
	public lombok.ast.For astVariableDeclaration(VariableDefinition variableDeclaration) {
		return this.rawVariableDeclaration(variableDeclaration);
	}
	
	public lombok.ast.Node rawVariableDeclaration() {
		return this.variableDeclaration;
	}
	
	public lombok.ast.For rawVariableDeclaration(lombok.ast.Node variableDeclaration) {
		if (variableDeclaration == this.variableDeclaration) return this;
		if (variableDeclaration != null) this.adopt((lombok.ast.AbstractNode)variableDeclaration);
		if (this.variableDeclaration != null) this.disown(this.variableDeclaration);
		this.variableDeclaration = (lombok.ast.AbstractNode)variableDeclaration;
		return this;
	}
	
	public Expression astCondition() {
		if (!(this.condition instanceof Expression)) return null;
		return (Expression) this.condition;
	}
	
	public lombok.ast.For astCondition(Expression condition) {
		return this.rawCondition(condition);
	}
	
	public lombok.ast.Node rawCondition() {
		return this.condition;
	}
	
	public lombok.ast.For rawCondition(lombok.ast.Node condition) {
		if (condition == this.condition) return this;
		if (condition != null) this.adopt((lombok.ast.AbstractNode)condition);
		if (this.condition != null) this.disown(this.condition);
		this.condition = (lombok.ast.AbstractNode)condition;
		return this;
	}
	
	public lombok.ast.RawListAccessor<Expression, lombok.ast.For> rawUpdates() {
		return this.updates.asRaw();
	}
	
	public lombok.ast.StrictListAccessor<Expression, lombok.ast.For> astUpdates() {
		return this.updates.asStrict();
	}
	
	public Statement astStatement() {
		if (!(this.statement instanceof Statement)) return null;
		return (Statement) this.statement;
	}
	
	public lombok.ast.For astStatement(Statement statement) {
		if (statement == null) throw new java.lang.NullPointerException("statement is mandatory");
		return this.rawStatement(statement);
	}
	
	public lombok.ast.Node rawStatement() {
		return this.statement;
	}
	
	public lombok.ast.For rawStatement(lombok.ast.Node statement) {
		if (statement == this.statement) return this;
		if (statement != null) this.adopt((lombok.ast.AbstractNode)statement);
		if (this.statement != null) this.disown(this.statement);
		this.statement = (lombok.ast.AbstractNode)statement;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		result.addAll(this.expressionInits.backingList());
		if (this.variableDeclaration != null) result.add(this.variableDeclaration);
		if (this.condition != null) result.add(this.condition);
		result.addAll(this.updates.backingList());
		if (this.statement != null) result.add(this.statement);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.rawExpressionInits().replace(original, replacement)) return true;
		if (this.variableDeclaration == original) {
			this.rawVariableDeclaration(replacement);
			return true;
		}
		if (this.condition == original) {
			this.rawCondition(replacement);
			return true;
		}
		if (this.rawUpdates().replace(original, replacement)) return true;
		if (this.statement == original) {
			this.rawStatement(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.rawExpressionInits().remove(child)) return true;
		if (this.variableDeclaration == child) {
			this.disown((AbstractNode) child);
			this.variableDeclaration = null;
			return true;
		}
		if (this.condition == child) {
			this.disown((AbstractNode) child);
			this.condition = null;
			return true;
		}
		if (this.rawUpdates().remove(child)) return true;
		if (this.statement == child) {
			this.disown((AbstractNode) child);
			this.statement = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitFor(this)) return;
		for (lombok.ast.Node child : this.expressionInits.asIterable()) {
			child.accept(visitor);
		}
		if (this.variableDeclaration != null) this.variableDeclaration.accept(visitor);
		if (this.condition != null) this.condition.accept(visitor);
		for (lombok.ast.Node child : this.updates.asIterable()) {
			child.accept(visitor);
		}
		if (this.statement != null) this.statement.accept(visitor);
		visitor.afterVisitFor(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public For copy() {
		For result = new For();
		for (Node n : this.expressionInits.backingList()) {
			result.rawExpressionInits().addToEnd(n == null ? null : n.copy());
		}
		if (this.variableDeclaration != null) result.rawVariableDeclaration(this.variableDeclaration.copy());
		if (this.condition != null) result.rawCondition(this.condition.copy());
		for (Node n : this.updates.backingList()) {
			result.rawUpdates().addToEnd(n == null ? null : n.copy());
		}
		if (this.statement != null) result.rawStatement(this.statement.copy());
		return result;
	}
	
	public boolean isVariableDeclarationBased() {
		return lombok.ast.ForTemplate.isVariableDeclarationBased(this);
	}
	
	public boolean isStatementExpressionsBased() {
		return lombok.ast.ForTemplate.isStatementExpressionsBased(this);
	}
	
}
