// Path: src/main/java/com/github/vbauer/caesar/runner/impl/base/AbstractCallbackMethodRunner.java
// public abstract class AbstractCallbackMethodRunner extends AbstractAsyncMethodRunner {
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public <T> Callable<T> createCall(final Object origin, final Method syncMethod, final Object[] args) {
//         final Object asyncCallback = args[0];
//         final Object[] restArgs = Arrays.copyOfRange(args, 1, args.length);
// 
//         return createCall(origin, syncMethod, asyncCallback, restArgs);
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     protected Method findSyncMethod(
//         final Class<?> targetClass, final String methodName,
//         final Class<?> returnType, final Class<?>[] parameterTypes
//     ) {
//         if (void.class == returnType && parameterTypes != null && parameterTypes.length > 0) {
//             final Class<?> lastParam = parameterTypes[0];
//             final Class<?> callbackClass = getCallbackClass();
// 
//             if (callbackClass.isAssignableFrom(lastParam)) {
//                 final Class<?>[] restParamTypes =
//                     Arrays.copyOfRange(parameterTypes, 1, parameterTypes.length);
// 
//                 return ReflectionUtils.findDeclaredMethod(targetClass, methodName, restParamTypes);
//             }
// 
//         }
//         return null;
//     }
// 
// 
//     protected abstract <T> Callable<T> createCall(
//         Object origin, Method syncMethod, Object callback, Object[] args
//     );
// 
//     protected abstract Class<?> getCallbackClass();
// 
// }
// 
// Path: src/main/java/com/github/vbauer/caesar/runner/task/FutureCallbackTask.java
// public class FutureCallbackTask<T> implements Callable<T> {
// 
//     private final Object origin;
//     private final Object[] args;
//     private final Method syncMethod;
//     private final FutureCallback futureCallback;
// 
// 
//     public FutureCallbackTask(
//         final Object origin, final Method syncMethod, final Object[] args,
//         final FutureCallback futureCallback
//     ) {
//         this.origin = origin;
//         this.args = args;
//         this.syncMethod = syncMethod;
//         this.futureCallback = futureCallback;
//     }
// 
// 
//     @SuppressWarnings("unchecked")
//     public T call() {
//         final Object result;
// 
//         try {
//             result = syncMethod.invoke(origin, args);
//         } catch (final Throwable ex) {
//             futureCallback.onFailure(ex.getCause());
//             return null;
//         }
// 
//         futureCallback.onSuccess(result);
// 
//         return (T) result;
//     }
// 
// }


import com.github.vbauer.caesar.runner.impl.base.AbstractCallbackMethodRunner;
import com.github.vbauer.caesar.runner.task.FutureCallbackTask;
import com.google.common.util.concurrent.FutureCallback;
import java.lang.reflect.Method;
import java.util.concurrent.Callable;
package com.github.vbauer.caesar.runner.impl;



/**
 * @author Vladislav Bauer
 */

@SuppressWarnings("all")
public class FutureCallbackMethodRunner extends AbstractCallbackMethodRunner {

    /**
     * {@inheritDoc}
     */
    @Override
    protected  <T> Callable<T> createCall(
        final Object origin, final Method syncMethod, final Object callback, final Object[] args
    ) {
// Path: src/main/java/com/github/vbauer/caesar/runner/impl/base/AbstractCallbackMethodRunner.java
// public abstract class AbstractCallbackMethodRunner extends AbstractAsyncMethodRunner {
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     public <T> Callable<T> createCall(final Object origin, final Method syncMethod, final Object[] args) {
//         final Object asyncCallback = args[0];
//         final Object[] restArgs = Arrays.copyOfRange(args, 1, args.length);
// 
//         return createCall(origin, syncMethod, asyncCallback, restArgs);
//     }
// 
//     /**
//      * {@inheritDoc}
//      */
//     @Override
//     protected Method findSyncMethod(
//         final Class<?> targetClass, final String methodName,
//         final Class<?> returnType, final Class<?>[] parameterTypes
//     ) {
//         if (void.class == returnType && parameterTypes != null && parameterTypes.length > 0) {
//             final Class<?> lastParam = parameterTypes[0];
//             final Class<?> callbackClass = getCallbackClass();
// 
//             if (callbackClass.isAssignableFrom(lastParam)) {
//                 final Class<?>[] restParamTypes =
//                     Arrays.copyOfRange(parameterTypes, 1, parameterTypes.length);
// 
//                 return ReflectionUtils.findDeclaredMethod(targetClass, methodName, restParamTypes);
//             }
// 
//         }
//         return null;
//     }
// 
// 
//     protected abstract <T> Callable<T> createCall(
//         Object origin, Method syncMethod, Object callback, Object[] args
//     );
// 
//     protected abstract Class<?> getCallbackClass();
// 
// }
// 
// Path: src/main/java/com/github/vbauer/caesar/runner/task/FutureCallbackTask.java
// public class FutureCallbackTask<T> implements Callable<T> {
// 
//     private final Object origin;
//     private final Object[] args;
//     private final Method syncMethod;
//     private final FutureCallback futureCallback;
// 
// 
//     public FutureCallbackTask(
//         final Object origin, final Method syncMethod, final Object[] args,
//         final FutureCallback futureCallback
//     ) {
//         this.origin = origin;
//         this.args = args;
//         this.syncMethod = syncMethod;
//         this.futureCallback = futureCallback;
//     }
// 
// 
//     @SuppressWarnings("unchecked")
//     public T call() {
//         final Object result;
// 
//         try {
//             result = syncMethod.invoke(origin, args);
//         } catch (final Throwable ex) {
//             futureCallback.onFailure(ex.getCause());
//             return null;
//         }
// 
//         futureCallback.onSuccess(result);
// 
//         return (T) result;
//     }
// 
// }


// Path: src/main/java/com/github/vbauer/caesar/runner/impl/FutureCallbackMethodRunner.java
import com.github.vbauer.caesar.runner.impl.base.AbstractCallbackMethodRunner;
import com.github.vbauer.caesar.runner.task.FutureCallbackTask;
import com.google.common.util.concurrent.FutureCallback;
import java.lang.reflect.Method;
import java.util.concurrent.Callable;

package com.github.vbauer.caesar.runner.impl;



/**
 * @author Vladislav Bauer
 */

@SuppressWarnings("all")
public class FutureCallbackMethodRunner extends AbstractCallbackMethodRunner {

    /**
     * {@inheritDoc}
     */
    @Override
    protected  <T> Callable<T> createCall(
        final Object origin, final Method syncMethod, final Object callback, final Object[] args
    ) {
        return new FutureCallbackTask<T>(origin, syncMethod, args, (FutureCallback) callback);