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

package lombok.ast;

public class VariableDefinitionEntry extends lombok.ast.AbstractNode {
	private lombok.ast.AbstractNode name = adopt(new lombok.ast.Identifier());
	private int arrayDimensions = 0;
	private lombok.ast.AbstractNode initializer = null;
	
	public VariableDefinition upToVariableDefinition() {
		if (!(this.getParent() instanceof VariableDefinition)) return null;
		VariableDefinition out = (VariableDefinition)this.getParent();
		if (!out.rawVariables().contains(this)) return null;
		return out;
	}
	
	
	public Identifier astName() {
		if (!(this.name instanceof Identifier)) return null;
		return (Identifier) this.name;
	}
	
	public lombok.ast.VariableDefinitionEntry astName(Identifier name) {
		return this.rawName(name);
	}
	
	private lombok.ast.VariableDefinitionEntry rawName(lombok.ast.Node name) {
		if (name == this.name) return this;
		if (name != null) this.adopt((lombok.ast.AbstractNode)name);
		if (this.name != null) this.disown(this.name);
		this.name = (lombok.ast.AbstractNode)name;
		return this;
	}
	
	public int astArrayDimensions() {
		return this.arrayDimensions;
	}
	
	public lombok.ast.VariableDefinitionEntry astArrayDimensions(int arrayDimensions) {
		this.arrayDimensions = arrayDimensions;
		return this;
	}
	
	public Expression astInitializer() {
		if (!(this.initializer instanceof Expression)) return null;
		return (Expression) this.initializer;
	}
	
	public lombok.ast.VariableDefinitionEntry astInitializer(Expression initializer) {
		return this.rawInitializer(initializer);
	}
	
	public lombok.ast.Node rawInitializer() {
		return this.initializer;
	}
	
	public lombok.ast.VariableDefinitionEntry rawInitializer(lombok.ast.Node initializer) {
		if (initializer == this.initializer) return this;
		if (initializer != null) this.adopt((lombok.ast.AbstractNode)initializer);
		if (this.initializer != null) this.disown(this.initializer);
		this.initializer = (lombok.ast.AbstractNode)initializer;
		return this;
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.name != null) result.add(this.name);
		if (this.initializer != null) result.add(this.initializer);
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.name == original) {
			if (replacement instanceof Identifier) {
				this.astName((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()));
		}
		if (this.initializer == original) {
			this.rawInitializer(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.name == child) {
			this.disown((AbstractNode) child);
			this.name = null;
			return true;
		}
		if (this.initializer == child) {
			this.disown((AbstractNode) child);
			this.initializer = null;
			return true;
		}
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitVariableDefinitionEntry(this)) return;
		if (this.name != null) this.name.accept(visitor);
		if (this.initializer != null) this.initializer.accept(visitor);
		visitor.afterVisitVariableDefinitionEntry(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public VariableDefinitionEntry copy() {
		VariableDefinitionEntry result = new VariableDefinitionEntry();
		if (this.name != null) result.rawName(this.name.copy());
		result.arrayDimensions = this.arrayDimensions;
		if (this.initializer != null) result.rawInitializer(this.initializer.copy());
		return result;
	}
	
	public TypeReference getEffectiveTypeReference() {
		return lombok.ast.VariableDefinitionEntryTemplate.getEffectiveTypeReference(this);
	}
	
	public Modifiers getModifiersOfParent() {
		return lombok.ast.VariableDefinitionEntryTemplate.getModifiersOfParent(this);
	}
	
	public lombok.ast.TypeDeclaration upUpIfFieldToTypeDeclaration() {
		return lombok.ast.VariableDefinitionEntryTemplate.upUpIfFieldToTypeDeclaration(this);
	}
	
	public Block upUpIfLocalVariableToBlock() {
		return lombok.ast.VariableDefinitionEntryTemplate.upUpIfLocalVariableToBlock(this);
	}
	
}
