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

package lombok.ast;

public class Annotation extends lombok.ast.AbstractNode implements lombok.ast.DescribedNode, lombok.ast.AnnotationValue {
	private lombok.ast.AbstractNode annotationTypeReference = null;
	lombok.ast.ListAccessor<AnnotationElement, lombok.ast.Annotation> elements = ListAccessor.of(this, AnnotationElement.class, "Annotation.elements");
	
	public Modifiers upToModifiers() {
		if (!(this.getParent() instanceof Modifiers)) return null;
		Modifiers out = (Modifiers)this.getParent();
		if (!out.rawAnnotations().contains(this)) return null;
		return out;
	}
	
	
	public TypeReference astAnnotationTypeReference() {
		if (!(this.annotationTypeReference instanceof TypeReference)) return null;
		return (TypeReference) this.annotationTypeReference;
	}
	
	public lombok.ast.Annotation astAnnotationTypeReference(TypeReference annotationTypeReference) {
		if (annotationTypeReference == null) throw new java.lang.NullPointerException("annotationTypeReference is mandatory");
		return this.rawAnnotationTypeReference(annotationTypeReference);
	}
	
	public lombok.ast.Node rawAnnotationTypeReference() {
		return this.annotationTypeReference;
	}
	
	public lombok.ast.Annotation rawAnnotationTypeReference(lombok.ast.Node annotationTypeReference) {
		if (annotationTypeReference == this.annotationTypeReference) return this;
		if (annotationTypeReference != null) this.adopt((lombok.ast.AbstractNode)annotationTypeReference);
		if (this.annotationTypeReference != null) this.disown(this.annotationTypeReference);
		this.annotationTypeReference = (lombok.ast.AbstractNode)annotationTypeReference;
		return this;
	}
	
	public lombok.ast.RawListAccessor<AnnotationElement, lombok.ast.Annotation> rawElements() {
		return this.elements.asRaw();
	}
	
	public lombok.ast.StrictListAccessor<AnnotationElement, lombok.ast.Annotation> astElements() {
		return this.elements.asStrict();
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.annotationTypeReference != null) result.add(this.annotationTypeReference);
		result.addAll(this.elements.backingList());
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.annotationTypeReference == original) {
			this.rawAnnotationTypeReference(replacement);
			return true;
		}
		if (this.rawElements().replace(original, replacement)) return true;
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.annotationTypeReference == child) {
			this.disown((AbstractNode) child);
			this.annotationTypeReference = null;
			return true;
		}
		if (this.rawElements().remove(child)) return true;
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitAnnotation(this)) return;
		if (this.annotationTypeReference != null) this.annotationTypeReference.accept(visitor);
		for (lombok.ast.Node child : this.elements.asIterable()) {
			child.accept(visitor);
		}
		visitor.afterVisitAnnotation(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public Annotation copy() {
		Annotation result = new Annotation();
		if (this.annotationTypeReference != null) result.rawAnnotationTypeReference(this.annotationTypeReference.copy());
		for (Node n : this.elements.backingList()) {
			result.rawElements().addToEnd(n == null ? null : n.copy());
		}
		return result;
	}
	
	public java.lang.String getDescription() {
		return lombok.ast.AnnotationTemplate.getDescription(this);
	}
	
	public java.util.List<lombok.ast.Node> getValueValues() {
		return lombok.ast.AnnotationTemplate.getValueValues(this);
	}
	
	public java.util.List<lombok.ast.Node> getValues(java.lang.String key) {
		return lombok.ast.AnnotationTemplate.getValues(this, key);
	}
	
}
