List of utility methods to do Reflection Method Setter Invoke
void | invokeSetter(final Method setter, final Object target, Object value) Conveniance method used to invoke a JavaBeans-compatible setter method. if (value instanceof Number) value = convertNumber(setter.getParameterTypes()[0], (Number) value); setter.invoke(target, value); |
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 | invokeSetter(Object o, String name, Class value1clazz, Object value) invoke Setter final Method setter = getMethod(o, name, new Class[] { value1clazz }); invokeSetter(o, setter, value); |
void | invokeSetter(Object o, String name, Object value, Class clazz) invoke Setter Class argsTypes[] = { clazz }; Method setterMtd = o.getClass().getMethod(name, argsTypes); Object args[] = { value }; setterMtd.invoke(o, args); |
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 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) { ... |