branch develop updated (8fa9bba -> 73c480d)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository nuiton-utils. See http://git.nuiton.org/nuiton-utils.git from 8fa9bba Add a method *buildInverseModelBuilder* to create an new BinderBuilder from another builder switching exterma (fixes #3755) new 78ed643 Add Binder#getSourcePropertyType and Binder#getTargetPropertyType methods (fixes #3757) new 73c480d Catch more exception while binding (fixes #3758) The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 73c480d3cfa4b44f91ff93d997bea5e3879e4b1c Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Aug 19 14:01:16 2015 +0200 Catch more exception while binding (fixes #3758) commit 78ed643d62d182bce4f513759fbe290a97499eb7 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Aug 19 13:58:29 2015 +0200 Add Binder#getSourcePropertyType and Binder#getTargetPropertyType methods (fixes #3757) Summary of changes: src/main/java/org/nuiton/util/beans/Binder.java | 39 ++++++++++++++++++++----- 1 file changed, 31 insertions(+), 8 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-utils. See http://git.nuiton.org/nuiton-utils.git commit 78ed643d62d182bce4f513759fbe290a97499eb7 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Aug 19 13:58:29 2015 +0200 Add Binder#getSourcePropertyType and Binder#getTargetPropertyType methods (fixes #3757) --- src/main/java/org/nuiton/util/beans/Binder.java | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/main/java/org/nuiton/util/beans/Binder.java b/src/main/java/org/nuiton/util/beans/Binder.java index f4a630a..befc994 100644 --- a/src/main/java/org/nuiton/util/beans/Binder.java +++ b/src/main/java/org/nuiton/util/beans/Binder.java @@ -335,6 +335,34 @@ public class Binder<I, O> implements Serializable { } /** + * Get the type of a source property. + * + * @param propertyName name of the source property + * @return the type of the source property + * @throws IllegalArgumentException if binder does not define this source property + */ + public Class<?> getSourcePropertyType(String propertyName) { + if (!model.containsSourceProperty(propertyName)) { + throw new IllegalArgumentException("Binder "+this+" does not contains source property: "+propertyName); + } + return model.getSourceReadMethod(propertyName).getReturnType(); + } + + /** + * Get the type of a target property. + * + * @param propertyName name of the target property + * @return the type of the target property + * @throws IllegalArgumentException if binder does not define this target property + */ + public Class<?> getTargetPropertyType(String propertyName) { + if (!model.containsTargetProperty(propertyName)) { + throw new IllegalArgumentException("Binder "+this+" does not contains target property: "+propertyName); + } + return model.getTargetWriteMethod(propertyName).getParameterTypes()[0]; + } + + /** * Copy properties from a source bean to a destination one according to * the model of the binder. * <p/> -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository nuiton-utils. See http://git.nuiton.org/nuiton-utils.git commit 73c480d3cfa4b44f91ff93d997bea5e3879e4b1c Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Aug 19 14:01:16 2015 +0200 Catch more exception while binding (fixes #3758) --- src/main/java/org/nuiton/util/beans/Binder.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/nuiton/util/beans/Binder.java b/src/main/java/org/nuiton/util/beans/Binder.java index befc994..d85b150 100644 --- a/src/main/java/org/nuiton/util/beans/Binder.java +++ b/src/main/java/org/nuiton/util/beans/Binder.java @@ -29,7 +29,6 @@ import org.nuiton.util.ObjectUtil; import java.beans.PropertyDescriptor; import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -217,12 +216,8 @@ public class Binder<I, O> implements Serializable { if (include) { result.put(sourceProperty, read); } - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } catch (InstantiationException e) { - throw new RuntimeException(e); + } catch (Exception e) { + throw new RuntimeException("Could not obtain property: " + sourceProperty, e); } } return result; @@ -286,7 +281,7 @@ public class Binder<I, O> implements Serializable { Method writeMethod = getModel().getTargetWriteMethod(propertyName); try { writeMethod.invoke(target, propertyValue); - } catch (IllegalAccessException | InvocationTargetException e) { + } catch (Exception e) { throw new RuntimeException( "Could not set property [" + target.getClass().getName() + ":" + -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm