Java Method Call invokeAndCastCollection(T returnType, Method m, Object obj, Object... args)

Here you can find the source of invokeAndCastCollection(T returnType, Method m, Object obj, Object... args)

Description

Same as ReflectionHelper#invokeAndCast(Object,Method,Object,Object) but with a cast to Collection

License

Apache License

Declaration

@SuppressWarnings({ "unchecked" })
public static <T> Collection<T> invokeAndCastCollection(T returnType, Method m, Object obj, Object... args) 

Method Source Code


//package com.java2s;
// SMSLib is distributed under the terms of the Apache License version 2.0

import java.lang.reflect.Method;
import java.util.Collection;

public class Main {
    /**//from  w  w  w  . ja va2 s.  com
     * Same as
     * {@link ReflectionHelper#invokeAndCast(Object, Method, Object, Object...) but with a cast to Collection<T> }
     * 
     * @see ReflectionHelper#invokeAndCast(Object, Method, Object, Object...)
     */
    @SuppressWarnings({ "unchecked" })
    public static <T> Collection<T> invokeAndCastCollection(T returnType, Method m, Object obj, Object... args) {
        try {
            return (Collection<T>) m.invoke(obj, args);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. invoke(String methodName, Object object, Class[] argTypes, Object[] args)
  2. invoke(String methodName, Object target, Class targetClass, Object[] args)
  3. invoke(String name, Object object, Object... args)
  4. invoke_ex(Object obj, String method, Class[] params, Object[] args)
  5. invokeAccessableMethodWithArguments(Object instance, String method, Object... arguments)
  6. invokeAnnotatedDeclaredMethod(Object obj, Class annotationType)
  7. invokeAnUnwrapException(final Method method, final Object[] args, final Object target)
  8. invokeCallback(String callbackName, String callbackParam)
  9. invokeCmd(String className, String[] args)