branch develop updated (4ba4357 -> 8fa9bba)
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 4ba4357 fix test (see #3753) new b8981d9 Add an option *canMismatchType* in BinderModelBuilder to be able to bind properties with different types (fixes #3754) new 8fa9bba Add a method *buildInverseModelBuilder* to create an new BinderBuilder from another builder switching exterma (fixes #3755) 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 8fa9bba37c6e07e942066a6bb618e6149d2ba0ed Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Aug 19 09:01:20 2015 +0200 Add a method *buildInverseModelBuilder* to create an new BinderBuilder from another builder switching exterma (fixes #3755) 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) Summary of changes: .../org/nuiton/util/beans/BinderModelBuilder.java | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) -- 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 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>.
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 8fa9bba37c6e07e942066a6bb618e6149d2ba0ed Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed Aug 19 09:01:20 2015 +0200 Add a method *buildInverseModelBuilder* to create an new BinderBuilder from another builder switching exterma (fixes #3755) --- .../org/nuiton/util/beans/BinderModelBuilder.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java b/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java index bdb0b2d..1964158 100644 --- a/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java +++ b/src/main/java/org/nuiton/util/beans/BinderModelBuilder.java @@ -447,6 +447,29 @@ public class BinderModelBuilder<S, T> { return this; } + /** + * Creates a new model builder inversing the the source and target of this builder. + * + * the result build will contains the inversed properties mapping of the original builder. + * + * Other builder attributes are not used used + * + * @return the new model builder + */ + public BinderModelBuilder<T, S> buildInverseModelBuilder() { + + BinderModelBuilder<T, S> builder = new BinderModelBuilder<>(model.getTargetType(), model.getSourceType()) + .canTypeMismatch(canTypeMismatch); + + for (Map.Entry<String, String> entry : model.getPropertiesMapping().entrySet()) { + String sourcePropertyName = entry.getKey(); + String targetPropertyName = entry.getValue(); + builder.addProperty(targetPropertyName, sourcePropertyName); + } + return builder; + + } + protected BinderModelBuilder<S, T> addCollectionStrategy0(String propertyName, Binder.CollectionStrategy strategy, Binder binder) { -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm