com.github.restup.service.VarArgsMethodCommand Maven / Gradle / Ivy
package com.github.restup.service;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.restup.errors.RequestErrorException;
import com.github.restup.util.Assert;
/**
* Simple Method Executor which uses reflection to invoke a {@link Method} from a variable list of
* arguments which are mapped to the {@link Method} arguments by type.
*
* For example, given the class Foo
*
*
*
* public class Foo {
* public void bar(String message) {
* System.out.println(message);
* }
* }
*
*
* The following will print "Hello World"
*
*
*
* VarArgsMethodExecutor executor = new VarArgsMethodExecutor(new Foo(), Foo.class.getMethod("bar", String.class));
* executor.execute(new Date(), 10, "Hello World");
*
*
* @author andy.buttaro
*/
public class VarArgsMethodCommand implements MethodCommand