class RepeatSynchronizationManager {

	private static final ThreadLocal<RepeatContext> contextHolder = new ThreadLocal<>();

	private RepeatSynchronizationManager() {
	}

	/**
	 * Getter for the current context. A context is shared by all items in the batch, so
	 * this method is intended to return the same context object independent of whether
	 * the callback is running synchronously or asynchronously with the surrounding
	 * {@link RepeatOperations}.
	 * @return the current {@link RepeatContext} or null if there is none (if we are not
	 * in a batch).
	 */
	public static RepeatContext getContext() {
		return contextHolder.get();
	}

	/**
	 * Convenience method to set the current repeat operation to complete if it exists.
	 */
	public static void setCompleteOnly() {
		RepeatContext context = getContext();
		if (context != null) {
			context.setCompleteOnly();
		}
	}

	/**
	 * Method for registering a context - should only be used by {@link RepeatOperations}
	 * implementations to ensure that {@link #getContext()} always returns the correct
	 * value.
	 * @param context a new context at the start of a batch.
	 * @return the old value if there was one.
	 */
	public static RepeatContext register(RepeatContext context) {
		RepeatContext oldSession = getContext();
		RepeatSynchronizationManager.contextHolder.set(context);
		return oldSession;
	}

	/**
	 * Clear the current context at the end of a batch - should only be used by
	 * {@link RepeatOperations} implementations.
	 * @return the old value if there was one.
	 */
	public static RepeatContext clear() {
		RepeatContext context = getContext();
		RepeatSynchronizationManager.contextHolder.set(null);
		return context;
	}

	/**
	 * Set current session and all ancestors (via parent) to complete.,
	 */
	public static void setAncestorsCompleteOnly() {<FILL_FUNCTION_BODY>}

}

		RepeatContext context = getContext();
		while (context != null) {
			context.setCompleteOnly();
			context = context.getParent();
		}
	
<no_super_class>