// Path: awex-core/src/main/java/com/raycoarana/awex/callbacks/CancelCallback.java
// public interface CancelCallback {
// 
//     void onCancel();
// 
// }
// 
// Path: awex-core/src/main/java/com/raycoarana/awex/callbacks/DoneCallback.java
// public interface DoneCallback<T> {
// 
//     void onDone(T result);
// 
// }
// 
// Path: awex-core/src/main/java/com/raycoarana/awex/callbacks/FailCallback.java
// public interface FailCallback {
// 
//     void onFail(Exception exception);
// 
// }
// 
// Path: awex-core/src/main/java/com/raycoarana/awex/exceptions/AllFailException.java
// public class AllFailException extends Exception {
// 
//     private final Exception[] mExceptions;
// 
//     public AllFailException(Exception... exceptions) {
//         mExceptions = exceptions;
//     }
// 
//     public Exception getException(int index) {
//         return mExceptions[index];
//     }
// 
//     public int getCount() {
//         return mExceptions.length;
//     }
// 
// }


import com.raycoarana.awex.callbacks.CancelCallback;
import com.raycoarana.awex.callbacks.DoneCallback;
import com.raycoarana.awex.callbacks.FailCallback;
import com.raycoarana.awex.exceptions.AllFailException;
import java.util.Collection;
                    synchronized (AnyOfPromise.this) {
                        if (getState() == STATE_PENDING) {
                            mExceptions[promiseIndex] = ex;
                            mFailedPromises++;
                            if (mFailedPromises == mPromises.size()) {
                                reject(new AllFailException(mExceptions));
                            }
                        }
                    }
                }
            }).cancel(mCancelCallback);

            i++;
        }
    }

    private DoneCallback<Result> buildDoneCallback() {
        return new DoneCallback<Result>() {
            @Override
            public void onDone(Result result) {
                synchronized (AnyOfPromise.this) {
                    if (getState() == STATE_PENDING) {
                        resolve(result);
                    }
                }
            }
        };
    }

    private CancelCallback buildCancelCallback() {
// Path: awex-core/src/main/java/com/raycoarana/awex/callbacks/CancelCallback.java
// public interface CancelCallback {
// 
//     void onCancel();
// 
// }
// 
// Path: awex-core/src/main/java/com/raycoarana/awex/callbacks/DoneCallback.java
// public interface DoneCallback<T> {
// 
//     void onDone(T result);
// 
// }
// 
// Path: awex-core/src/main/java/com/raycoarana/awex/callbacks/FailCallback.java
// public interface FailCallback {
// 
//     void onFail(Exception exception);
// 
// }
// 
// Path: awex-core/src/main/java/com/raycoarana/awex/exceptions/AllFailException.java
// public class AllFailException extends Exception {
// 
//     private final Exception[] mExceptions;
// 
//     public AllFailException(Exception... exceptions) {
//         mExceptions = exceptions;
//     }
// 
//     public Exception getException(int index) {
//         return mExceptions[index];
//     }
// 
//     public int getCount() {
//         return mExceptions.length;
//     }
// 
// }


// Path: awex-core/src/main/java/com/raycoarana/awex/AnyOfPromise.java
import com.raycoarana.awex.callbacks.CancelCallback;
import com.raycoarana.awex.callbacks.DoneCallback;
import com.raycoarana.awex.callbacks.FailCallback;
import com.raycoarana.awex.exceptions.AllFailException;
import java.util.Collection;

                    synchronized (AnyOfPromise.this) {
                        if (getState() == STATE_PENDING) {
                            mExceptions[promiseIndex] = ex;
                            mFailedPromises++;
                            if (mFailedPromises == mPromises.size()) {
                                reject(new AllFailException(mExceptions));
                            }
                        }
                    }
                }
            }).cancel(mCancelCallback);

            i++;
        }
    }

    private DoneCallback<Result> buildDoneCallback() {
        return new DoneCallback<Result>() {
            @Override
            public void onDone(Result result) {
                synchronized (AnyOfPromise.this) {
                    if (getState() == STATE_PENDING) {
                        resolve(result);
                    }
                }
            }
        };
    }

    private CancelCallback buildCancelCallback() {
        return new CancelCallback() {