class RepeatContextSupport extends SynchronizedAttributeAccessor implements RepeatContext {

	private final RepeatContext parent;

	private int count;

	private volatile boolean completeOnly;

	private volatile boolean terminateOnly;

	private final Map<String, Set<Runnable>> callbacks = new HashMap<>();

	/**
	 * Constructor for {@link RepeatContextSupport}. The parent can be null, but should be
	 * set to the enclosing repeat context if there is one, e.g. if this context is an
	 * inner loop.
	 * @param parent {@link RepeatContext} to be used as the parent context.
	 */
	public RepeatContextSupport(RepeatContext parent) {
		super();
		this.parent = parent;
	}

	@Override
	public boolean isCompleteOnly() {
		return completeOnly;
	}

	@Override
	public void setCompleteOnly() {
		completeOnly = true;
	}

	@Override
	public boolean isTerminateOnly() {
		return terminateOnly;
	}

	@Override
	public void setTerminateOnly() {
		terminateOnly = true;
		setCompleteOnly();
	}

	@Override
	public RepeatContext getParent() {
		return parent;
	}

	/**
	 * Used by clients to increment the started count.
	 */
	public synchronized void increment() {
		count++;
	}

	@Override
	public synchronized int getStartedCount() {
		return count;
	}

	@Override
	public void registerDestructionCallback(String name, Runnable callback) {
		synchronized (callbacks) {
			Set<Runnable> set = callbacks.computeIfAbsent(name, k -> new HashSet<>());
			set.add(callback);
		}
	}

	@Override
	public void close() {<FILL_FUNCTION_BODY>}

}


		List<RuntimeException> errors = new ArrayList<>();

		Set<Map.Entry<String, Set<Runnable>>> copy;

		synchronized (callbacks) {
			copy = new HashSet<>(callbacks.entrySet());
		}

		for (Map.Entry<String, Set<Runnable>> entry : copy) {

			for (Runnable callback : entry.getValue()) {
				/*
				 * Potentially we could check here if there is an attribute with the given
				 * name - if it has been removed, maybe the callback is invalid. On the
				 * other hand it is less surprising for the callback register if it is
				 * always executed.
				 */
				if (callback != null) {
					/*
					 * The documentation of the interface says that these callbacks must
					 * not throw exceptions, but we don't trust them necessarily...
					 */
					try {
						callback.run();
					}
					catch (RuntimeException t) {
						errors.add(t);
					}
				}
			}
		}

		if (errors.isEmpty()) {
			return;
		}

		throw errors.get(0);
	
<methods>public non-sealed void <init>() ,public java.lang.String[] attributeNames() ,public boolean equals(java.lang.Object) ,public java.lang.Object getAttribute(java.lang.String) ,public boolean hasAttribute(java.lang.String) ,public int hashCode() ,public java.lang.Object removeAttribute(java.lang.String) ,public void setAttribute(java.lang.String, java.lang.Object) ,public java.lang.Object setAttributeIfAbsent(java.lang.String, java.lang.Object) ,public java.lang.String toString() <variables>org.springframework.core.AttributeAccessorSupport support