package org.hive2hive.processframework;

import java.util.List;

import org.hive2hive.processframework.interfaces.IProcessComponent;
import org.hive2hive.processframework.interfaces.IProcessComponentListener;

/**
 * Abstract base class for all decorators that decorate {@link IProcessComponent}s.
 * These decorators provide additional behavior or state to existing implementations of
 * {@link IProcessComponent}s.
 * This abstract base class just delegates all calls to the wrapped/decorated {@link IProcessComponent}
 * implementation.
 * 
 * @author Christian Lthold
 *
 * @param <T> The type of the result computed by the wrapped/decorated {@code IProcessComponent}.
 */
public abstract class ProcessDecorator<T> extends ProcessComponent<T> {

	protected final IProcessComponent<T> decoratedComponent;

	/**
	 * Creates a {@code ProcessDecorator} that wraps/decorates the provided {@link IProcessComponent}
	 * implementation.
	 * 
	 * @param decoratedComponent The {@link IProcessComponent} implementation to be wrapped/decorated by this
	 *            {@code ProcessDecorator}.
	 */
	public ProcessDecorator(IProcessComponent<T> decoratedComponent) {
		this.decoratedComponent = decoratedComponent;
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public void await() throws InterruptedException {
		decoratedComponent.await();
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public void await(long timeout) throws InterruptedException {
		decoratedComponent.await(timeout);
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public Process<?> getParent() {
		return decoratedComponent.getParent();
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public void setName(String name) {
		decoratedComponent.setName(name);
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public String getName() {
		return decoratedComponent.getName();
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public String getID() {
		return decoratedComponent.getID();
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public double getProgress() {
		return decoratedComponent.getProgress();
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public ProcessState getState() {
		return decoratedComponent.getState();
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public synchronized void attachListener(IProcessComponentListener listener) {
		decoratedComponent.attachListener(listener);
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public synchronized void detachListener(IProcessComponentListener listener) {
		decoratedComponent.detachListener(listener);
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public List<IProcessComponentListener> getListeners() {
		return decoratedComponent.getListeners();
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public String toString() {
		return decoratedComponent.toString();
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public boolean equals(Object obj) {
		return decoratedComponent.equals(obj);
	}

	/**
	 * Default decorator implementation:
	 * Just delegates the call to the wrapped/decorated {@link IProcessComponent} implementation.
	 */
	@Override
	public int hashCode() {
		return decoratedComponent.hashCode();
	}

}
@@ -580,16 +580,31 @@
 Lthold%0D%0A
+ * @param %3CT%3E%0D%0A
  *%0D%0A * @
@@ -805,33 +805,33 @@
 rocessComponent%3C
-T
+?
 %3E decoratedCompo
@@ -1171,17 +1171,17 @@
 mponent%3C
-T
+?
 %3E decora

make decorators more generic, because they only wrap