The list of methods to do Reflection Method Setter Invoke are organized into topic(s).
void
invokeSetter(Method setter, Object obj, String fieldName, Object value) invoke Setter
try {
setter.invoke(obj, value);
} catch (IllegalAccessException | IllegalArgumentException
| InvocationTargetException ex) {
throw new IOException(
String.format("Unsupported operation with object of class %s for name \"%s\" - %s.",
obj.getClass().toString(), fieldName,
ex.getCause() == null ? ex.getLocalizedMessage() : ex.getCause().getLocalizedMessage()),
...
void
invokeSetter(Method setter, Object obj, String value) Invokes the setter method using reflection.
Class<?>[] types = setter.getParameterTypes();
if (types.length != 1) {
return;
Object valueObject = convertValue(types[0], value);
if (valueObject != null) {
setter.invoke(obj, new Object[] { valueObject });
void
invokeSetter(Method setter, Object object, Object propValue) invoke a setter method
if (setter == null) {
throw new IllegalArgumentException("The setter method cannot be null");
if (object == null) {
throw new IllegalArgumentException("The object cannot be null");
try {
setter.setAccessible(true);
...
void
invokeSetter(Object entity, String propertyName, Object propertyValue) Sets a property on an entity based on its name.
if (propertyName != null && entity != null) {
propertyName = propertyName.replaceAll("/", ".");
Object o = entity;
String pty = propertyName;
String[] strings = propertyName.split("\\.");
if (strings.length > 1) {
for (int i = 0; i < strings.length - 1; i++) {
String string = strings[i];
...
void
invokeSetterMethod(Method method, Object oBean, Object oValue) invoke Setter Method
Object[] args = new Object[1];
args[0] = oValue;
try {
method.invoke(oBean, args);
} catch (IllegalArgumentException e) {
throw new RuntimeException("invokeSetterMethod : IllegalArgumentException ", e);
} catch (IllegalAccessException e) {
throw new RuntimeException("invokeSetterMethod : IllegalAccessException ", e);
...
T
invokeSetters(final T instance, final Map vars) Invoke the setters for the given variables on the given instance.
if (instance != null && vars != null) {
final Class<?> clazz = instance.getClass();
final Method[] methods = clazz.getMethods();
for (final Entry<String, Object> entry : vars.entrySet()) {
final String methodName = "set" + entry.getKey().substring(0, 1).toUpperCase(Locale.US)
+ entry.getKey().substring(1);
boolean found = false;
for (final Method method : methods) {
...