class NaryTreeNode extends AbstractTreeNode<D, N> {

	@Override
	@SuppressWarnings("checkstyle:npathcomplexity")
	public boolean setChildAt(int index, N newChild) throws IndexOutOfBoundsException {
		final int count = (this.children == null) ? 0 : this.children.size();

		if (index < 0 || index >= count) {
			throw new IndexOutOfBoundsException();
		}

		final N oldChild = this.children.get(index);
		if (oldChild == newChild) {
			return false;
		}

		if (oldChild != null) {
			oldChild.setParentNodeReference(null, true);
			--this.notNullChildCount;
			firePropertyChildRemoved(index, oldChild);
		}

		if (newChild != null) {
			final N oldParent = newChild.getParentNode();
			if (oldParent != this) {
				newChild.removeFromParent();
			}
		}

		// set the element
		if (newChild != null) {
			this.children.set(index, newChild);
		} else {
			this.children.remove(index);
		}

		if (newChild != null) {
			newChild.setParentNodeReference(toN(), true);
			++this.notNullChildCount;
			firePropertyChildAdded(index, newChild);
		}

		return true;
	}

	public  NaryTreeNode();
	public  NaryTreeNode(Collection<D> data);
	public  NaryTreeNode(D data);
	public  NaryTreeNode(boolean useLinkedList);
	public  NaryTreeNode(boolean useLinkedList, boolean copyDataCollection, List<D> data);
	public  NaryTreeNode(boolean useLinkedList, D data);

}