List of utility methods to do Reflection Method Getter Invoke
Object | invokeGetMethod(Object obj, String getterName) invoke Get Method return obj.getClass().getDeclaredMethod(getterName).invoke(obj);
|
Object | invokeGetter(Method getter, Object object) invoke Getter try { getter.setAccessible(true); return getter.invoke(object, new Object[0]); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } catch (InvocationTargetException e) { throw new IllegalStateException(e); |
T | invokeGetter(Object bean, Method getter) Invokes a getter method on a given bean boolean accessible = getter.isAccessible(); getter.setAccessible(true); T result = null; try { result = (T) getter.invoke(bean); } finally { getter.setAccessible(accessible); return result; |
Object | invokeGetter(Object entity, String propertyName) Returns the value of a property on an entity based on its name. Object result = null; if (propertyName != null && entity != null) { propertyName = propertyName.replaceAll("/", "."); Object o = entity; String pty = propertyName; int index = propertyName.indexOf("."); if (index != -1) { o = invokeGetter(entity, propertyName.substring(0, index)); ... |
Object | invokeGetter(Object getterOwner, Method method) invoke Getter try { return method.invoke(getterOwner); } catch (Exception e) { return null; |
Object | invokeGetter(Object o, String name, boolean forceAccess) invoke Getter Method getterMtd = o.getClass().getMethod(name, null); if (forceAccess) { getterMtd.setAccessible(true); return getterMtd.invoke(o, null); |
Object | invokeGetter(Object obj, String methodName) invoke Getter Method m = obj.getClass().getMethod(methodName, (Class[]) null); if (m != null) { if (m.getExceptionTypes().length != 0) { return null; } else { return m.invoke(obj, (Object[]) null); return null; |
int | invokeGetter(Object obj, String methodName, int defaultValue) Invokes the specified getter method if it exists. try { Method method = obj.getClass().getMethod(methodName, new Class[0]); Object result = method.invoke(obj, new Object[0]); return ((Integer) result).intValue(); } catch (NoSuchMethodException e) { return defaultValue; } catch (IllegalAccessException e) { return defaultValue; ... |
Object | invokeGetter(Object object, String field) invoke Getter Method method = getGetterMethod(object.getClass(), field);
return method.invoke(object);
|
Object | invokeGetter(Object target, Method getter) call getter and return object. RuntimeException re = new RuntimeException("Error trying to get value: " + getter.toString()); Object result = null; try { result = getter.invoke(target, new Object[] {}); } catch (IllegalArgumentException e) { re.initCause(e); throw re; } catch (IllegalAccessException e) { ... |