DBUTILS-121 Let subclasses have a chance to determine the write method to use for assigning property values
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/dbutils/trunk@1649089 13f79535-47bb-0310-9956-ffa450edef68 Project: http://git-wip-us.apache.org/repos/asf/commons-dbutils/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-dbutils/commit/156945b7 Tree: http://git-wip-us.apache.org/repos/asf/commons-dbutils/tree/156945b7 Diff: http://git-wip-us.apache.org/repos/asf/commons-dbutils/diff/156945b7 Branch: refs/heads/master Commit: 156945b7f1b1760d60789d996f14b9cc0942d393 Parents: 4c584ee Author: Carl Franklin Hall <[email protected]> Authored: Fri Jan 2 18:49:12 2015 +0000 Committer: Carl Franklin Hall <[email protected]> Committed: Fri Jan 2 18:49:12 2015 +0000 ---------------------------------------------------------------------- .../org/apache/commons/dbutils/BeanProcessor.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-dbutils/blob/156945b7/src/main/java/org/apache/commons/dbutils/BeanProcessor.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java index 9c3752f..f1dfe47 100644 --- a/src/main/java/org/apache/commons/dbutils/BeanProcessor.java +++ b/src/main/java/org/apache/commons/dbutils/BeanProcessor.java @@ -247,7 +247,7 @@ public class BeanProcessor { private void callSetter(Object target, PropertyDescriptor prop, Object value) throws SQLException { - Method setter = prop.getWriteMethod(); + Method setter = getWriteMethod(target, prop, value); if (setter == null) { return; @@ -345,6 +345,20 @@ public class BeanProcessor { } /** + * Get the write method to use when setting {@code value} to the {@code target}. + * + * @param target Object where the write method will be called. + * @param prop BeanUtils information. + * @param value The value that will be passed to the write method. + * @return The {@link java.lang.reflect.Method} to call on {@code target} to write {@code value} or {@code null} if + * there is no suitable write method. + */ + protected Method getWriteMethod(Object target, PropertyDescriptor prop, Object value) { + Method method = prop.getWriteMethod(); + return method; + } + + /** * Factory method that returns a new instance of the given Class. This * is called at the start of the bean creation process and may be * overridden to provide custom behavior like returning a cached bean
