Example #1
0
 /**
  * This is a shortcut for {@link #invokeSpecificMethod(Object, Class, String, Class...)}.{@link
  * InvocationTarget#withArguments(Object...)}. That is, it uses the types of the given arguments
  * to look up the method. This will only work if the types are exact matches for the parameter
  * types.
  *
  * @param <T>
  * @param instance
  * @param methodOwner
  * @param methodName
  * @param args
  * @return
  */
 public static <T> T invokeMethod(
     Object instance, Class<?> methodOwner, String methodName, Object... args) {
   Class<?>[] types = new Class<?>[args.length];
   for (int i = 0; i < args.length; i++) {
     types[i] = args[i].getClass();
   }
   return Reflections.<T>invokeSpecificMethod(instance, methodOwner, methodName, types)
       .withArguments(args);
 }
Example #2
0
 public static <T> T invokeNoArgMethod(Object instance, Class<?> methodOwner, String methodName) {
   return Reflections.<T>invokeSpecificMethod(instance, methodOwner, methodName).withArguments();
 }