Method setter(String propertyName, Class type) { Method s = null; try { s = proxyObject.getClass().getMethod("set" + propertyName, type); } catch (NoSuchMethodException e) { s = cp().setter(propertyName, type); } return s; }
/** * Returns a setter method for a property of java bean. * * <p>The <tt>type</tt> parameter may be <code>null</code> to indicate the the setter for the * property should be returned regardless of the type. If not null it will be used to filter the * returned method. * * @param clazz The type of the bean. * @param property The property name. * @param type The type of the property, may be <code>null</code>. * @return The setter method, or <code>null</code> if not found. */ public static Method setter(Class clazz, String property, Class type) { return classProperties(clazz).setter(property, type); }
/** * Looks up a setter method by property name. * * <p>setter("foo",Integer) --> void setFoo(Integer); * * @param property The property. * @param type The type of the property. * @return The setter for the property, or null if it does not exist. */ public Method setter(String property, Class type) { Collection<Method> methods = setters.get(property); for (Method setter : methods) { if (type == null) { return setter; } else { Class target = setter.getParameterTypes()[0]; if (target.isAssignableFrom(type) || (target.isPrimitive() && type == wrapper(target)) || (type.isPrimitive() && target == wrapper(type))) { return setter; } } } // could not be found, try again with a more lax match String lax = lax(property); if (!lax.equals(property)) { return setter(lax, type); } return null; }
Method s = properties.setter(property, null); if (s == null) { continue;
Method setter = properties.setter(p, type);