private static void set(final Object obj, Field field, final Object val) throws IllegalAccessException, InvocationTargetException { if (field.canAccess(obj)) field.set(obj, val); else { try { final Method setter = obj.getClass().getMethod("set" + StringUtils.capitalize(field.getName()), field.getType()); setter.invoke(obj, val); } catch (NoSuchMethodException e) { // No setter, field not public. ignore. } } }
private static Object retornarObjeto(Object objeto) { if (objeto == null) { return null; } for (int i = 0; i < objeto.getClass().getDeclaredFields().length; i++) { Field field = objeto.getClass().getDeclaredFields()[i]; if (field.getType().isAssignableFrom(List.class)) { try { Method metodo = metodoGet(objeto, field.getName()); Collection lista = (Collection) metodo.invoke(objeto); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { boolean campoAcessivel = true; if (!field.canAccess(objeto)) { field.setAccessible(true); campoAcessivel = false; } setValueField(objeto, field); if (!campoAcessivel) { field.setAccessible(false); } } } } return objeto; }
private static Object retornarObjeto(Object objeto) { if (objeto == null) { return null; } for (int i = 0; i < objeto.getClass().getDeclaredFields().length; i++) { Field field = objeto.getClass().getDeclaredFields()[i]; if (field.getType().isAssignableFrom(List.class)) { try { Method metodo = metodoGet(objeto, field.getName()); Collection lista = (Collection) metodo.invoke(objeto); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { boolean campoAcessivel = true; if (!field.canAccess(objeto)) { field.setAccessible(true); campoAcessivel = false; } setValueField(objeto, field); if (!campoAcessivel) { field.setAccessible(false); } } } } return objeto; }
for (Field field : fields) { Object value; boolean accessible = field.canAccess(object); try { try {
if (!field.canAccess(object))
if (!field.canAccess(fieldOwner))