List of utility methods to do Reflection Field Value Set
void | setFieldValue(Object host, Field f, Object value) set Field Value f.setAccessible(true); unsafeSetFieldValue(host, f, value); |
Object | setFieldValue(Object input, Object value, String fieldName) set Field Value Class searchClass = input.getClass(); while (searchClass != null) { Field[] fields = searchClass.getDeclaredFields(); for (Field field : fields) { if (field.getName().equals(fieldName)) { field.setAccessible(true); if (field.getType().getName().equals("java.lang.Long")) { if (value instanceof String) { ... |
void | setFieldValue(Object instance, Field field, Object value) Sets a field value via reflection. try { field.set(instance, value); } catch (IllegalAccessException e) { throw new IllegalStateException(e); |
void | setFieldValue(Object instanceContainingField, String fieldName, Object fieldValue) Sets a value to a field using reflection even if the field is private. Class<?> targetClass = instanceContainingField.getClass(); while (targetClass != null) { for (Field field : targetClass.getDeclaredFields()) { if (field.getName().equalsIgnoreCase(fieldName)) { try { boolean isAccessible = field.isAccessible(); try { field.setAccessible(true); ... |
void | setFieldValue(Object o, Class> baseClass, Class set Field Value if (o == null) { throw new NullPointerException(); if (!baseClass.isAssignableFrom(o.getClass())) { throw new IllegalArgumentException( "Got a " + o.getClass().getName() + " but expected a " + baseClass.getName()); for (Field f : baseClass.getDeclaredFields()) { ... |
void | SetFieldValue(Object o, String field, Object object) Set Field Value Field _field = o.getClass().getDeclaredField(field); _field.setAccessible(true); _field.set(o, object); |
void | setFieldValue(Object obj, Field f, Object value) set Field Value try { boolean accessible = f.isAccessible(); try { f.setAccessible(true); f.set(obj, value); } finally { f.setAccessible(accessible); } catch (IllegalArgumentException e) { throw e; } catch (IllegalAccessException e) { assert false; |
void | setFieldValue(Object obj, Field field, Object value) set Field Value field.setAccessible(true); field.set(obj, value); |
void | setFieldValue(Object obj, Field field, Object value) set Field Value field.setAccessible(true); try { field.set(obj, value); } catch (IllegalArgumentException e) { throw new RuntimeException("IllegalArgumentException", e); } catch (IllegalAccessException e) { throw new RuntimeException("IllegalAccessExceptione", e); |
void | setFieldValue(Object obj, String field, Object value) set Field Value setFieldValue(obj, getField(obj.getClass(), field), value); |