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

package lombok.ast;

public class ArrayCreation extends lombok.ast.AbstractNode implements lombok.ast.Expression {
	private java.util.List<lombok.ast.Position> parensPositions = new java.util.ArrayList<lombok.ast.Position>();
	private lombok.ast.AbstractNode componentTypeReference = null;
	lombok.ast.ListAccessor<ArrayDimension, lombok.ast.ArrayCreation> dimensions = ListAccessor.of(this, ArrayDimension.class, "ArrayCreation.dimensions");
	private lombok.ast.AbstractNode initializer = null;
	
	public java.util.List<lombok.ast.Position> astParensPositions() {
		return this.parensPositions;
	}
	
	public TypeReference astComponentTypeReference() {
		if (!(this.componentTypeReference instanceof TypeReference)) return null;
		return (TypeReference) this.componentTypeReference;
	}
	
	public lombok.ast.ArrayCreation astComponentTypeReference(TypeReference componentTypeReference) {
		if (componentTypeReference == null) throw new java.lang.NullPointerException("componentTypeReference is mandatory");
		return this.rawComponentTypeReference(componentTypeReference);
	}
	
	public lombok.ast.Node rawComponentTypeReference() {
		return this.componentTypeReference;
	}
	
	public lombok.ast.ArrayCreation rawComponentTypeReference(lombok.ast.Node componentTypeReference) {
		if (componentTypeReference == this.componentTypeReference) return this;
		if (componentTypeReference != null) this.adopt((lombok.ast.AbstractNode)componentTypeReference);
		if (this.componentTypeReference != null) this.disown(this.componentTypeReference);
		this.componentTypeReference = (lombok.ast.AbstractNode)componentTypeReference;
		return this;
	}
	
	public lombok.ast.RawListAccessor<ArrayDimension, lombok.ast.ArrayCreation> rawDimensions() {
		return this.dimensions.asRaw();
	}
	
	public lombok.ast.StrictListAccessor<ArrayDimension, lombok.ast.ArrayCreation> astDimensions() {
		return this.dimensions.asStrict();
	}
	
	public ArrayInitializer astInitializer() {
		if (!(this.initializer instanceof ArrayInitializer)) return null;
		return (ArrayInitializer) this.initializer;
	}
	
	public lombok.ast.ArrayCreation astInitializer(ArrayInitializer initializer) {
		return this.rawInitializer(initializer);
	}
	
	public lombok.ast.Node rawInitializer() {
		return this.initializer;
	}
	
	public lombok.ast.ArrayCreation 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.componentTypeReference != null) result.add(this.componentTypeReference);
		result.addAll(this.dimensions.backingList());
		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.componentTypeReference == original) {
			this.rawComponentTypeReference(replacement);
			return true;
		}
		if (this.rawDimensions().replace(original, replacement)) return true;
		if (this.initializer == original) {
			this.rawInitializer(replacement);
			return true;
		}
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.componentTypeReference == child) {
			this.disown((AbstractNode) child);
			this.componentTypeReference = null;
			return true;
		}
		if (this.rawDimensions().remove(child)) 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.visitArrayCreation(this)) return;
		if (this.componentTypeReference != null) this.componentTypeReference.accept(visitor);
		for (lombok.ast.Node child : this.dimensions.asIterable()) {
			child.accept(visitor);
		}
		if (this.initializer != null) this.initializer.accept(visitor);
		visitor.afterVisitArrayCreation(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public ArrayCreation copy() {
		ArrayCreation result = new ArrayCreation();
		result.parensPositions = new java.util.ArrayList<lombok.ast.Position>(this.parensPositions);
		if (this.componentTypeReference != null) result.rawComponentTypeReference(this.componentTypeReference.copy());
		for (Node n : this.dimensions.backingList()) {
			result.rawDimensions().addToEnd(n == null ? null : n.copy());
		}
		if (this.initializer != null) result.rawInitializer(this.initializer.copy());
		return result;
	}
	
	public int getParens() {
		return lombok.ast.ExpressionMixin.getParens(this);
	}
	
	public int getIntendedParens() {
		return lombok.ast.ExpressionMixin.getIntendedParens(this);
	}
	
	public boolean needsParentheses() {
		return lombok.ast.ExpressionMixin.needsParentheses(this);
	}
	
	public boolean isStatementExpression() {
		return lombok.ast.ExpressionMixin.isStatementExpression(this);
	}
	
}
