in src/main/java/org/apache/commons/dbutils/BeanProcessor.java [121:150]
private void callSetter(final Object target, final PropertyDescriptor prop, Object value)
throws SQLException {
final Method setter = getWriteMethod(target, prop, value);
if (setter == null || setter.getParameterTypes().length != 1) {
return;
}
try {
final Class<?> firstParam = setter.getParameterTypes()[0];
for (final PropertyHandler handler : PROPERTY_HANDLERS) {
if (handler.match(firstParam, value)) {
value = handler.apply(firstParam, value);
break;
}
}
// Don't call setter if the value object isn't the right type
if (!isCompatibleType(value, firstParam)) {
throw new SQLException(
"Cannot set " + prop.getName() + ": incompatible types, cannot convert " + value.getClass().getName() + " to " + firstParam.getName());
// value cannot be null here because isCompatibleType allows null
}
setter.invoke(target, value);
} catch (final IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
throw new SQLException("Cannot set " + prop.getName() + ": " + e.getMessage());
}
}