log.error("invalid method: " + method);
return null;
}
//get on with the real business
XMethod setterMethod = null;
if (log.isInfoEnabled()) {
log.info("===find setter method===");
log.info("method name: " + method.getName());
log.info("property name: " + propertyName);
log.info("property type: " + propertyType);
}
//attempt to find an explicitly named setter method
final String explicitMethodName = method.getDoc().getTag("javabean.property").getAttributeValue("setter");
if (isExplicitlyReadOnlyProperty(method)) {
log.info("explicit read only");
}
else if ((explicitMethodName != null) && (explicitMethodName.length() > 0)) {
//the method has an explicit attribute
//there must be a bean property method with the given name
java.util.List methodList = getCurrentClass().getMethods(
new Predicate()
{
public boolean evaluate(Object obj)
{
XMethod method = (XMethod) obj;
return isPossiblePropertyMutator(method, propertyType) &&
method.getName().equals(explicitMethodName);
}
}, false);
if (methodList.size() == 1) {
setterMethod = (XMethod) methodList.get(0);
if (log.isInfoEnabled()) {
log.info("found explicit setter " + setterMethod.getName());
}
if (isPossiblePropertyMutator(method, propertyType)
&& (setterMethod != method)) {
log.warn("explicit setter " + setterMethod.getName() + " (should be passed method)");
}
}
else {
//they gave an explicit method name but it could not be found
log.warn("no explicit setter " + explicitMethodName);
}
}
else if (isPossiblePropertyMutator(method, propertyType)) {
//this was put on a mutator assume it was what they wanted?
setterMethod = method;
log.info("using the passed method");
}
else {
//attempt to find the standard bean method (Simple property JavaBeans API specification 8.3.1)
//takes one param
java.util.List methodList = getCurrentClass().getMethods(
new Predicate()
{
public boolean evaluate(Object obj)
{
XMethod method = (XMethod) obj;
return isPossiblePropertyMutator(method, propertyType) &&
propertyName.equals(method.getPropertyName());
}
}, false);
if (methodList.size() == 1) {
setterMethod = (XMethod) methodList.get(0);