public static < T > T getMethod ( Object object , String name , Object ... params ) { Check . notNull ( object ) ; Check . notNull ( name ) ; Check . notNull ( params ) ; try { final Class < ? > clazz = getClass ( object ) ; final Method method = clazz . getDeclaredMethod ( name , getParamTypes ( params ) ) ; setAccessible ( method , true ) ; @ SuppressWarnings ( "unchecked" ) final T value = ( T ) method . invoke ( object , params ) ; return value ; } catch ( final NoSuchMethodException | InvocationTargetException | IllegalAccessException exception ) { if ( exception . getCause ( ) instanceof LionEngineException ) { throw ( LionEngineException ) exception . getCause ( ) ; } throw new LionEngineException ( exception , ERROR_METHOD + name ) ; } }
Get method and call its return value with parameters .