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 b8981d96cbe0cd16d8279f1841f7c8476ad31e24 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Aug 19 09:00:26 2015 +0200 Add an option *canMismatchType* in BinderModelBuilder to be able to bind properties with different types (fixes #3754) --- .../java/org/nuiton/util/beans/BinderModelBuilder.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java b/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java index 3009147..bdb0b2d 100644 --- a/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java +++ b/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java @@ -105,6 +105,11 @@ import java.util.TreeMap; */ public class BinderModelBuilder<S, T> { + /** + * Can the source and target type mismatch for a property ? + */ + protected boolean canTypeMismatch; + /** current model used to build the binder */ protected Binder.BinderModel<S, T> model; @@ -228,6 +233,17 @@ public class BinderModelBuilder<S, T> { } /** + * Change the value of property {@code canTypeMismatch}. + * + * @param canTypeMismatch new {@code canTypeMismatch} value + * @return the builder + */ + public BinderModelBuilder<S, T> canTypeMismatch(boolean canTypeMismatch) { + this.canTypeMismatch = canTypeMismatch; + return this; + } + + /** * Convinient method to create directly a {@link Binder} using the * underlying {@link #model} the builder contains. * <p/> @@ -534,7 +550,7 @@ public class BinderModelBuilder<S, T> { Class<?> sourceType = sourceDescriptor.getPropertyType(); Class<?> targetType = targetDescriptor.getPropertyType(); //TODO-TC20100221 : should check if primitive and boxed it in such case - if (!sourceType.equals(targetType)) { + if (!sourceType.equals(targetType) && !canTypeMismatch) { throw new IllegalArgumentException("source property '" + sourceProperty + "' and target property '" + targetProperty + "' are not compatible ( sourceType : " + -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.