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

package lombok.ast;

public class PackageDeclaration extends lombok.ast.AbstractNode implements lombok.ast.JavadocContainer {
	private lombok.ast.AbstractNode javadoc = null;
	lombok.ast.ListAccessor<Annotation, lombok.ast.PackageDeclaration> annotations = ListAccessor.of(this, Annotation.class, "PackageDeclaration.annotations");
	lombok.ast.ListAccessor<Identifier, lombok.ast.PackageDeclaration> parts = ListAccessor.of(this, Identifier.class, "PackageDeclaration.parts");
	
	public CompilationUnit upToCompilationUnit() {
		if (!(this.getParent() instanceof CompilationUnit)) return null;
		CompilationUnit out = (CompilationUnit)this.getParent();
		if (out.rawPackageDeclaration() != this) return null;
		return out;
	}
	
	
	public Comment astJavadoc() {
		if (!(this.javadoc instanceof Comment)) return null;
		return (Comment) this.javadoc;
	}
	
	public lombok.ast.PackageDeclaration astJavadoc(Comment javadoc) {
		return this.rawJavadoc(javadoc);
	}
	
	public lombok.ast.Node rawJavadoc() {
		return this.javadoc;
	}
	
	public lombok.ast.PackageDeclaration rawJavadoc(lombok.ast.Node javadoc) {
		if (javadoc == this.javadoc) return this;
		if (javadoc != null) this.adopt((lombok.ast.AbstractNode)javadoc);
		if (this.javadoc != null) this.disown(this.javadoc);
		this.javadoc = (lombok.ast.AbstractNode)javadoc;
		return this;
	}
	
	public lombok.ast.RawListAccessor<Annotation, lombok.ast.PackageDeclaration> rawAnnotations() {
		return this.annotations.asRaw();
	}
	
	public lombok.ast.StrictListAccessor<Annotation, lombok.ast.PackageDeclaration> astAnnotations() {
		return this.annotations.asStrict();
	}
	
	public lombok.ast.RawListAccessor<Identifier, lombok.ast.PackageDeclaration> rawParts() {
		return this.parts.asRaw();
	}
	
	public lombok.ast.StrictListAccessor<Identifier, lombok.ast.PackageDeclaration> astParts() {
		return this.parts.asStrict();
	}
	
	@java.lang.Override public java.util.List<Node> getChildren() {
		java.util.List<Node> result = new java.util.ArrayList<Node>();
		if (this.javadoc != null) result.add(this.javadoc);
		result.addAll(this.annotations.backingList());
		result.addAll(this.parts.backingList());
		return result;
	}
	
	@java.lang.Override public boolean replaceChild(Node original, Node replacement) throws lombok.ast.AstException {
		if (this.javadoc == original) {
			this.rawJavadoc(replacement);
			return true;
		}
		if (this.rawAnnotations().replace(original, replacement)) return true;
		if (this.rawParts().replace(original, replacement)) return true;
		return false;
	}
	
	@java.lang.Override public boolean detach(Node child) {
		if (this.javadoc == child) {
			this.disown((AbstractNode) child);
			this.javadoc = null;
			return true;
		}
		if (this.rawAnnotations().remove(child)) return true;
		if (this.rawParts().remove(child)) return true;
		return false;
	}
	
	@java.lang.Override public void accept(lombok.ast.AstVisitor visitor) {
		if (visitor.visitPackageDeclaration(this)) return;
		if (this.javadoc != null) this.javadoc.accept(visitor);
		for (lombok.ast.Node child : this.annotations.asIterable()) {
			child.accept(visitor);
		}
		for (lombok.ast.Node child : this.parts.asIterable()) {
			child.accept(visitor);
		}
		visitor.afterVisitPackageDeclaration(this);
		visitor.endVisit(this);
	}
	
	@java.lang.Override public PackageDeclaration copy() {
		PackageDeclaration result = new PackageDeclaration();
		if (this.javadoc != null) result.rawJavadoc(this.javadoc.copy());
		for (Node n : this.annotations.backingList()) {
			result.rawAnnotations().addToEnd(n == null ? null : n.copy());
		}
		for (Node n : this.parts.backingList()) {
			result.rawParts().addToEnd(n == null ? null : n.copy());
		}
		return result;
	}
	
	public java.lang.String getPackageName() {
		return lombok.ast.PackageDeclarationTemplate.getPackageName(this);
	}
	
}
