You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by th...@apache.org on 2017/07/07 02:06:07 UTC
[32/50] commons-dbutils git commit: DBUTILS-121 Let subclasses have a
chance to determine the write method to use for assigning property values
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 <th...@apache.org>
Authored: Fri Jan 2 18:49:12 2015 +0000
Committer: Carl Franklin Hall <th...@apache.org>
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