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

package lombok.ast;

public class TypeVariable extends lombok.ast.AbstractNode implements lombok.ast.DescribedNode {
	private lombok.ast.AbstractNode name = adopt(new lombok.ast.Identifier());
	lombok.ast.ListAccessor<TypeReference, lombok.ast.TypeVariable> extending = ListAccessor.of(this, TypeReference.class, "TypeVariable.extending");
	
	public Identifier astName() {
		if (!(this.name instanceof Identifier)) return null;
		return (Identifier) this.name;
	}
	
	public lombok.ast.TypeVariable astName(Identifier name) {
		return this.rawName(name);
	}
	
	private lombok.ast.TypeVariable 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 lombok.ast.RawListAccessor<TypeReference, lombok.ast.TypeVariable> rawExtending() {
		return this.extending.asRaw();
	}
	
	public lombok.ast.StrictListAccessor<TypeReference, lombok.ast.TypeVariable> astExtending() {
		return this.extending.asStrict();
	}
	
	@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);
		result.addAll(this.extending.backingList());
		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.rawExtending().replace(original, 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.rawExtending().remove(child)) return true;
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitTypeVariable(this)) return;
		if (this.name != null) this.name.accept(visitor);
		for (lombok.ast.Node child : this.extending.asIterable()) {
			child.accept(visitor);
		}
		visitor.afterVisitTypeVariable(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public TypeVariable copy() {
		TypeVariable result = new TypeVariable();
		if (this.name != null) result.rawName(this.name.copy());
		for (Node n : this.extending.backingList()) {
			result.rawExtending().addToEnd(n == null ? null : n.copy());
		}
		return result;
	}
	
	public java.lang.String getDescription() {
		return lombok.ast.TypeVariableTemplate.getDescription(this);
	}
	
}
