// Path: hydra-composer/src/main/java/com/flipkart/hydra/composer/Composer.java
// public interface Composer {
// 
//     public Object compose(Map<String, Object> values) throws ComposerEvaluationException;
// 
//     public List<String> getDependencies();
// }
// 
// Path: hydra-composer/src/main/java/com/flipkart/hydra/composer/exception/ComposerEvaluationException.java
// public class ComposerEvaluationException extends Exception {
// 
//     public ComposerEvaluationException() {
//         super();
//     }
// 
//     public ComposerEvaluationException(String message) {
//         super(message);
//     }
// 
//     public ComposerEvaluationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ComposerEvaluationException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: hydra-task/src/main/java/com/flipkart/hydra/task/exception/BadCallableException.java
// public class BadCallableException extends Exception {
// 
//     public BadCallableException() {
//         super();
//     }
// 
//     public BadCallableException(String message) {
//         super(message);
//     }
// 
//     public BadCallableException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public BadCallableException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: hydra-task/src/main/java/com/flipkart/hydra/task/helpers/ReflectionHelper.java
// public class ReflectionHelper {
// 
//     public static Constructor<? extends Callable> getFirstSingleArgConstructor(Class<? extends Callable> callableClass) throws NoSuchMethodException {
//         Constructor<?>[] declaredConstructors = callableClass.getDeclaredConstructors();
//         for (Constructor constructor : declaredConstructors) {
//             Class[] parameterTypes = constructor.getParameterTypes();
//             if (parameterTypes.length == 1) {
//                 return constructor;
//             }
//         }
// 
//         throw new NoSuchMethodException("Unable to find a single argument constructor.");
//     }
// }


import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import com.flipkart.hydra.composer.Composer;
import com.flipkart.hydra.composer.exception.ComposerEvaluationException;
import com.flipkart.hydra.task.exception.BadCallableException;
import com.flipkart.hydra.task.helpers.ReflectionHelper;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
    protected final Composer composer;
    protected final Map<String, Object> values;

    public WrapperCallable(ExecutorService executor, Class<? extends Callable> callableClass, Composer loopComposer, Composer composer, Map<String, Object> values) throws NoSuchMethodException, ComposerEvaluationException {
        this(MoreExecutors.listeningDecorator(executor),
                ReflectionHelper.getFirstSingleArgConstructor(callableClass),
                loopComposer.compose(values),
                composer,
                values);
    }

    public WrapperCallable(ListeningExecutorService executorService, Constructor<? extends Callable> constructor, Object loopVar, Composer composer, Map<String, Object> values) {
        this.executorService = executorService;
        this.constructor = constructor;
        this.loopVar = loopVar;
        this.composer = composer;
        this.values = values;
    }

    @Override
    public Object call() throws Exception {
        try {
            if (loopVar instanceof Map) {
                return getResponsesForMap();
            } else if (loopVar instanceof List) {
                return getResponsesForList();
            } else if (loopVar.getClass().isArray()) {
                return getResponsesForArray();
            }
        } catch (Throwable e) {
// Path: hydra-composer/src/main/java/com/flipkart/hydra/composer/Composer.java
// public interface Composer {
// 
//     public Object compose(Map<String, Object> values) throws ComposerEvaluationException;
// 
//     public List<String> getDependencies();
// }
// 
// Path: hydra-composer/src/main/java/com/flipkart/hydra/composer/exception/ComposerEvaluationException.java
// public class ComposerEvaluationException extends Exception {
// 
//     public ComposerEvaluationException() {
//         super();
//     }
// 
//     public ComposerEvaluationException(String message) {
//         super(message);
//     }
// 
//     public ComposerEvaluationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ComposerEvaluationException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: hydra-task/src/main/java/com/flipkart/hydra/task/exception/BadCallableException.java
// public class BadCallableException extends Exception {
// 
//     public BadCallableException() {
//         super();
//     }
// 
//     public BadCallableException(String message) {
//         super(message);
//     }
// 
//     public BadCallableException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public BadCallableException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: hydra-task/src/main/java/com/flipkart/hydra/task/helpers/ReflectionHelper.java
// public class ReflectionHelper {
// 
//     public static Constructor<? extends Callable> getFirstSingleArgConstructor(Class<? extends Callable> callableClass) throws NoSuchMethodException {
//         Constructor<?>[] declaredConstructors = callableClass.getDeclaredConstructors();
//         for (Constructor constructor : declaredConstructors) {
//             Class[] parameterTypes = constructor.getParameterTypes();
//             if (parameterTypes.length == 1) {
//                 return constructor;
//             }
//         }
// 
//         throw new NoSuchMethodException("Unable to find a single argument constructor.");
//     }
// }


// Path: hydra-task/src/main/java/com/flipkart/hydra/task/entities/WrapperCallable.java
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import com.flipkart.hydra.composer.Composer;
import com.flipkart.hydra.composer.exception.ComposerEvaluationException;
import com.flipkart.hydra.task.exception.BadCallableException;
import com.flipkart.hydra.task.helpers.ReflectionHelper;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

    protected final Composer composer;
    protected final Map<String, Object> values;

    public WrapperCallable(ExecutorService executor, Class<? extends Callable> callableClass, Composer loopComposer, Composer composer, Map<String, Object> values) throws NoSuchMethodException, ComposerEvaluationException {
        this(MoreExecutors.listeningDecorator(executor),
                ReflectionHelper.getFirstSingleArgConstructor(callableClass),
                loopComposer.compose(values),
                composer,
                values);
    }

    public WrapperCallable(ListeningExecutorService executorService, Constructor<? extends Callable> constructor, Object loopVar, Composer composer, Map<String, Object> values) {
        this.executorService = executorService;
        this.constructor = constructor;
        this.loopVar = loopVar;
        this.composer = composer;
        this.values = values;
    }

    @Override
    public Object call() throws Exception {
        try {
            if (loopVar instanceof Map) {
                return getResponsesForMap();
            } else if (loopVar instanceof List) {
                return getResponsesForList();
            } else if (loopVar.getClass().isArray()) {
                return getResponsesForArray();
            }
        } catch (Throwable e) {
            throw new BadCallableException("Unable to execute callable", e);