// Path: src/main/java/com/rc/gds/interfaces/GDSCallback.java
// public interface GDSCallback<T> {
// 	public void onSuccess(T t, Throwable err);
// }
// 
// Path: src/main/java/com/rc/gds/interfaces/GDSMultiResult.java
// public interface GDSMultiResult<T> {
// 	
// 	public void later(GDSResultReceiver<T> resultReceiver);
// 	
// 	public void laterAsList(GDSResultListReceiver<T> resultListReceiver);
// 	
// 	public List<T> asList();
// 	
// }
// 
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
// 	
// 	public void later(GDSCallback<T> inCallback);
// 	
// 	public T now();
// 	
// }
// 
// Path: src/main/java/com/rc/gds/interfaces/GDSResultListReceiver.java
// public interface GDSResultListReceiver<T> {
// 	
// 	public void success(List<T> list, Throwable err);
// 
// }


import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.rc.gds.interfaces.GDSCallback;
import com.rc.gds.interfaces.GDSMultiResult;
import com.rc.gds.interfaces.GDSResult;
import com.rc.gds.interfaces.GDSResultListReceiver;

		
		final GDSCallback singleCallback = new GDSCallback() {
			
			@Override
			public void onSuccess(Object t, Throwable err) {
				handleSuccess(current, total, asyncResult, err);
			}
		};
		final GDSResultListReceiver multiCallback = new GDSResultListReceiver() {
			
			@Override
			public void success(List list, Throwable err) {
				handleSuccess(current, total, asyncResult, err);
			}
		};

		if (singleResults != null) {
			total.addAndGet(singleResults.length);
			for (GDSResult<?> result : singleResults)
				result.later(singleCallback);
		}
		if (multiResults != null) {
			total.addAndGet(multiResults.length);
			for (GDSMultiResult<?> result : multiResults)
				result.laterAsList(multiCallback);
		}
		
		return asyncResult;
	}


// Path: src/main/java/com/rc/gds/interfaces/GDSCallback.java
// public interface GDSCallback<T> {
// 	public void onSuccess(T t, Throwable err);
// }
// 
// Path: src/main/java/com/rc/gds/interfaces/GDSMultiResult.java
// public interface GDSMultiResult<T> {
// 	
// 	public void later(GDSResultReceiver<T> resultReceiver);
// 	
// 	public void laterAsList(GDSResultListReceiver<T> resultListReceiver);
// 	
// 	public List<T> asList();
// 	
// }
// 
// Path: src/main/java/com/rc/gds/interfaces/GDSResult.java
// public interface GDSResult<T> {
// 	
// 	public void later(GDSCallback<T> inCallback);
// 	
// 	public T now();
// 	
// }
// 
// Path: src/main/java/com/rc/gds/interfaces/GDSResultListReceiver.java
// public interface GDSResultListReceiver<T> {
// 	
// 	public void success(List<T> list, Throwable err);
// 
// }


// Path: src/main/java/com/rc/gds/GDSBatcher.java
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.rc.gds.interfaces.GDSCallback;
import com.rc.gds.interfaces.GDSMultiResult;
import com.rc.gds.interfaces.GDSResult;
import com.rc.gds.interfaces.GDSResultListReceiver;

		
		final GDSCallback singleCallback = new GDSCallback() {
			
			@Override
			public void onSuccess(Object t, Throwable err) {
				handleSuccess(current, total, asyncResult, err);
			}
		};
		final GDSResultListReceiver multiCallback = new GDSResultListReceiver() {
			
			@Override
			public void success(List list, Throwable err) {
				handleSuccess(current, total, asyncResult, err);
			}
		};

		if (singleResults != null) {
			total.addAndGet(singleResults.length);
			for (GDSResult<?> result : singleResults)
				result.later(singleCallback);
		}
		if (multiResults != null) {
			total.addAndGet(multiResults.length);
			for (GDSMultiResult<?> result : multiResults)
				result.laterAsList(multiCallback);
		}
		
		return asyncResult;
	}


	protected void handleSuccess(AtomicInteger current, AtomicInteger total, GDSAsyncImpl<Boolean> result, Throwable err) {
