List of utility methods to do Method Call
void | invokePrimivite(Object entity, Method writeMethod, Class propertyType, String propertyValue) invoke Primivite if (isByte(propertyType)) { writeMethod.invoke(entity, Byte.parseByte(propertyValue)); } else if (isShort(propertyType)) { writeMethod.invoke(entity, Short.parseShort(propertyValue)); } else if (isInt(propertyType)) { writeMethod.invoke(entity, Integer.parseInt(propertyValue)); } else if (isLong(propertyType)) { writeMethod.invoke(entity, Long.parseLong(propertyValue)); ... |
Object | invokePrivate(Class> clazz, Object instance, String methodName, Class>[] argTypes, Object[] args) invoke Private try { Method method = clazz.getDeclaredMethod(methodName, argTypes); method.setAccessible(true); return method.invoke(instance, args); } catch (Exception e) { throw new RuntimeException(e); |
Object | invokePrivate(String name, final Object obj, Object[] objects) invoke Private Method method = null; Class<?> objClass = obj instanceof Class ? (Class<?>) obj : obj.getClass(); while (objClass != null && method == null) { for (Method m : objClass.getDeclaredMethods()) { if (name.equals(m.getName()) && (objects == null && m.getParameterTypes().length == 0) || (objects != null && objects.length == m.getParameterTypes().length)) { method = m; break; ... |
Object | invokePrivateMethod(Method method, Object object, Object... args) invoke Private Method try { method.setAccessible(true); return method.invoke(object, args); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { return null; } finally { method.setAccessible(false); |
T | invokePrivateMethod(Object instance, String name, Object... args) invoke Private Method Class<?>[] clazArray = new Class<?>[args.length]; for (int i = 0; i < args.length; i++) { clazArray[i] = args[i].getClass(); try { Method method = instance.getClass().getDeclaredMethod(name, clazArray); method.setAccessible(true); T result = (T) method.invoke(instance, args); ... |
Object | invokePrivateMethod(Object obj, String methodName, Class>[] parameterTypes, Object[] args) Invoke a private Java method by reflection Method m = obj.getClass().getDeclaredMethod(methodName, parameterTypes);
m.setAccessible(true);
return m.invoke(obj, args);
|
void | invokePrivateMethod(String methodName, Class> clazz, Object object) invoke Private Method try { final Method method = clazz.getDeclaredMethod(methodName); method.setAccessible(true); method.invoke(object); } catch (Exception e) { e.printStackTrace(); return; |
Object | invokeProperty(Object obj, String property) Invoke the method/field getter on the Object. if ((property == null) || (property.length() == 0)) { return null; Class cls = obj.getClass(); Object[] oParams = {}; Class[] cParams = {}; try { Method method = cls.getMethod(createMethodName(GET, property), cParams); ... |
Object | invokeProtectedMethod(Class c, String method, Object... args) invoke Protected Method return invokeProtectedMethod(c, null, method, args);
|
T | invokeProtectedMethod(Object o, Object[] args, String methodName, Class>[] types) Invokes a protected method on the specified object. try { Method m = getDeclaredMethod(o.getClass(), methodName, types); m.setAccessible(true); return (T) m.invoke(o, args); } catch (SecurityException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); ... |