branch develop updated (ecb5c52 -> 07d19ab)
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 ecb5c52 Be able to transform target values in a Binder (fixes #3759) new 07d19ab Add also generic type methods (refs #3757) The 1 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 07d19ab3c0fde7f2c56520b2b2574948cc9a130a Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Aug 20 14:14:23 2015 +0200 Add also generic type methods (refs #3757) Summary of changes: src/main/java/org/nuiton/util/beans/Binder.java | 35 ++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 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 07d19ab3c0fde7f2c56520b2b2574948cc9a130a Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Aug 20 14:14:23 2015 +0200 Add also generic type methods (refs #3757) --- src/main/java/org/nuiton/util/beans/Binder.java | 35 ++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/nuiton/util/beans/Binder.java b/src/main/java/org/nuiton/util/beans/Binder.java index c261551..81a6a6d 100644 --- a/src/main/java/org/nuiton/util/beans/Binder.java +++ b/src/main/java/org/nuiton/util/beans/Binder.java @@ -31,6 +31,7 @@ import org.nuiton.util.ObjectUtil; import java.beans.PropertyDescriptor; import java.io.Serializable; import java.lang.reflect.Method; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -356,12 +357,26 @@ public class Binder<I, O> implements Serializable { */ public Class<?> getSourcePropertyType(String propertyName) { if (!model.containsSourceProperty(propertyName)) { - throw new IllegalArgumentException("Binder "+this+" does not contains source property: "+propertyName); + throw new IllegalArgumentException("Binder " + this + " does not contains source property: " + propertyName); } return model.getSourceReadMethod(propertyName).getReturnType(); } /** + * Get the generic type of a source property. + * + * @param propertyName name of the source property + * @return the generic type of the source property + * @throws IllegalArgumentException if binder does not define this source property + */ + public Type getSourcePropertyGenericType(String propertyName) { + if (!model.containsSourceProperty(propertyName)) { + throw new IllegalArgumentException("Binder " + this + " does not contains source property: " + propertyName); + } + return model.getSourceReadMethod(propertyName).getGenericReturnType(); + } + + /** * Get the type of a target property. * * @param propertyName name of the target property @@ -370,12 +385,26 @@ public class Binder<I, O> implements Serializable { */ public Class<?> getTargetPropertyType(String propertyName) { if (!model.containsTargetProperty(propertyName)) { - throw new IllegalArgumentException("Binder "+this+" does not contains target property: "+propertyName); + throw new IllegalArgumentException("Binder " + this + " does not contains target property: " + propertyName); } return model.getTargetWriteMethod(propertyName).getParameterTypes()[0]; } /** + * Get the generic type of a target property. + * + * @param propertyName name of the target property + * @return the generic type of the target property + * @throws IllegalArgumentException if binder does not define this target property + */ + public Type getTargetPropertyGenericType(String propertyName) { + if (!model.containsTargetProperty(propertyName)) { + throw new IllegalArgumentException("Binder " + this + " does not contains target property: " + propertyName); + } + return model.getTargetWriteMethod(propertyName).getGenericParameterTypes()[0]; + } + + /** * Copy properties from a source bean to a destination one according to * the model of the binder. * <p/> @@ -733,7 +762,7 @@ public class Binder<I, O> implements Serializable { /** * Dictonnary of function to apply by source class type. */ - protected final Map<Class<?>, Function<?,?>> functions; + protected final Map<Class<?>, Function<?, ?>> functions; private static final long serialVersionUID = 2L; -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm