List of utility methods to do Reflection Field Set
void | setField(Field field, Object obj, String value) Set field value using reflection. Class<?> type = field.getType();
Object valueObject = convertValue(type, value);
if (valueObject != null) {
field.set(obj, valueObject);
|
void | setField(Field field, Object objToSet, Object value) set Field field.setAccessible(true); try { field.set(objToSet, value); } catch (IllegalArgumentException | IllegalAccessException e) { throw new RuntimeException(e); |
void | setField(Field field, Object target, Object value) set Field try { makeAccessible(field); field.set(target, value); } catch (IllegalAccessException var4) { throw new IllegalStateException( "Unexpected reflection exception - " + var4.getClass().getName() + ": " + var4.getMessage()); |
Object | setField(Field field, Object target, Object value) Set a field if (field == null) throw new IllegalArgumentException("Null field"); try { field.set(target, value); return null; } catch (Throwable t) { throw handleErrors("set", field, target, value, t); |
void | setField(Field field, Object target, Object value) set Field if (!Modifier.isPublic(field.getModifiers())) { field.setAccessible(true); try { field.set(target, value); } catch (IllegalAccessException iae) { throw new IllegalArgumentException("Could not set field " + field, iae); |
void | setField(Field field, Object target, Object value) Set the field represented by the supplied Field field object on the specified Object target object to the specified value .
try { field.set(target, value); } catch (IllegalAccessException ex) { handleReflectionException(ex); throw new IllegalStateException( "Unexpected reflection exception - " + ex.getClass().getName() + ": " + ex.getMessage()); |
void | setField(Field field, Object target, Object value) set Field try { field.set(target, value); } catch (IllegalAccessException ex) { throw new IllegalStateException( "Unexpected reflection exception - " + ex.getClass().getName() + ": " + ex.getMessage()); |
void | setField(Field field, Object target, Object value) Set the field represented by the supplied Field field object on the specified Object target object to the specified value . try { boolean accessibled = makeAccessible(field); field.set(target, value); if (accessibled) field.setAccessible(false); } catch (IllegalAccessException e) { throw new IllegalStateException("Could not access field: " + e.getMessage()); |
void | setField(Field field, Object target, Object value) set Field try { field.set(target, value); } catch (IllegalAccessException ex) { handleReflectionException(ex); throw new IllegalStateException( "Unexpected reflection exception - " + ex.getClass().getName() + ": " + ex.getMessage()); |
Object | setField(Field field, T newValue, Object instance) set Field Object old = null; final boolean accessible = field.isAccessible(); if (!accessible) { field.setAccessible(!accessible); old = retrieveField(field, instance); field.set(instance, newValue); field.setAccessible(accessible); ... |