// Path: deferred/src/main/java/com/tuenti/deferred/LoggerProvider.java
// public static Logger getLogger() {
// 	return logger;
// }


import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import static com.tuenti.deferred.LoggerProvider.getLogger;

	@Override
	public Promise<D, F, P> fail(FailCallback<F> callback) {
		synchronized (this) {
			if (isRejected()) {
				triggerFail(callback, rejectResult);
			} else {
				failCallbacks.add(callback);
			}
		}
		return this;
	}

	@Override
	public Promise<D, F, P> always(AlwaysCallback<D, F> callback) {
		synchronized (this) {
			if (isPending()) {
				alwaysCallbacks.add(callback);
			} else {
				triggerAlways(callback, state, resolveResult, rejectResult);
			}
		}
		return this;
	}

	protected void triggerDone(D resolved) {
		for (DoneCallback<D> callback : doneCallbacks) {
			try {
				triggerDone(callback, resolved);
			} catch (Exception e) {
// Path: deferred/src/main/java/com/tuenti/deferred/LoggerProvider.java
// public static Logger getLogger() {
// 	return logger;
// }


// Path: deferred/src/main/java/com/tuenti/deferred/AbstractPromise.java
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Executor;
import static com.tuenti.deferred.LoggerProvider.getLogger;


	@Override
	public Promise<D, F, P> fail(FailCallback<F> callback) {
		synchronized (this) {
			if (isRejected()) {
				triggerFail(callback, rejectResult);
			} else {
				failCallbacks.add(callback);
			}
		}
		return this;
	}

	@Override
	public Promise<D, F, P> always(AlwaysCallback<D, F> callback) {
		synchronized (this) {
			if (isPending()) {
				alwaysCallbacks.add(callback);
			} else {
				triggerAlways(callback, state, resolveResult, rejectResult);
			}
		}
		return this;
	}

	protected void triggerDone(D resolved) {
		for (DoneCallback<D> callback : doneCallbacks) {
			try {
				triggerDone(callback, resolved);
			} catch (Exception e) {
				getLogger().error("an uncaught exception occured in a DoneCallback", e);