Author: tchemit Date: 2011-01-18 09:41:16 +0100 (Tue, 18 Jan 2011) New Revision: 2155 Url: http://nuiton.org/repositories/revision/jaxx/2155 Log: Evolution #1206: Can skip null value in CollectionUniqueKeyValidator validator Pass to version 2.3 Modified: trunk/jaxx-compiler/pom.xml trunk/jaxx-demo/pom.xml trunk/jaxx-runtime/pom.xml trunk/jaxx-tutorial-config/pom.xml trunk/jaxx-tutorial-css/pom.xml trunk/jaxx-tutorial-databinding/pom.xml trunk/jaxx-tutorial-helloworld/pom.xml trunk/jaxx-tutorial-helloworld2/pom.xml trunk/jaxx-tutorial/pom.xml trunk/jaxx-validator/pom.xml trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java trunk/jaxx-widgets/pom.xml trunk/maven-jaxx-plugin/pom.xml trunk/pom.xml Modified: trunk/jaxx-compiler/pom.xml =================================================================== --- trunk/jaxx-compiler/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-compiler/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -34,7 +34,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> Modified: trunk/jaxx-demo/pom.xml =================================================================== --- trunk/jaxx-demo/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-demo/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -35,7 +35,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> Modified: trunk/jaxx-runtime/pom.xml =================================================================== --- trunk/jaxx-runtime/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-runtime/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -34,7 +34,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> Modified: trunk/jaxx-tutorial/pom.xml =================================================================== --- trunk/jaxx-tutorial/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-tutorial/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -35,7 +35,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> Modified: trunk/jaxx-tutorial-config/pom.xml =================================================================== --- trunk/jaxx-tutorial-config/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-tutorial-config/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -35,7 +35,7 @@ <parent> <groupId>org.nuiton.jaxx</groupId> <artifactId>jaxx-tutorial</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> <relativePath>../jaxx-tutorial</relativePath> </parent> Modified: trunk/jaxx-tutorial-css/pom.xml =================================================================== --- trunk/jaxx-tutorial-css/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-tutorial-css/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton.jaxx</groupId> <artifactId>jaxx-tutorial</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> <relativePath>../jaxx-tutorial</relativePath> </parent> Modified: trunk/jaxx-tutorial-databinding/pom.xml =================================================================== --- trunk/jaxx-tutorial-databinding/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-tutorial-databinding/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton.jaxx</groupId> <artifactId>jaxx-tutorial</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> <relativePath>../jaxx-tutorial</relativePath> </parent> Modified: trunk/jaxx-tutorial-helloworld/pom.xml =================================================================== --- trunk/jaxx-tutorial-helloworld/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-tutorial-helloworld/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton.jaxx</groupId> <artifactId>jaxx-tutorial</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> <relativePath>../jaxx-tutorial</relativePath> </parent> Modified: trunk/jaxx-tutorial-helloworld2/pom.xml =================================================================== --- trunk/jaxx-tutorial-helloworld2/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-tutorial-helloworld2/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -10,7 +10,7 @@ <parent> <groupId>org.nuiton.jaxx</groupId> <artifactId>jaxx-tutorial</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> <relativePath>../jaxx-tutorial</relativePath> </parent> Modified: trunk/jaxx-validator/pom.xml =================================================================== --- trunk/jaxx-validator/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-validator/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -34,7 +34,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> Modified: trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java =================================================================== --- trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java 2011-01-18 08:41:16 UTC (rev 2155) @@ -85,6 +85,14 @@ */ protected String againstIndexExpression; + /** + * Pour ne pas traiter les valeurs nulles (si positionné à {@code true} les + * valeurs nulles ne sont pas considérée comme unique). + * + * @since 2.2.6 + */ + protected boolean nullValueSkipped; + public String getCollectionFieldName() { return collectionFieldName; } @@ -129,6 +137,14 @@ this.againstMe = againstMe; } + public boolean isNullValueSkipped() { + return nullValueSkipped; + } + + public void setNullValueSkipped(boolean nullValueSkipped) { + this.nullValueSkipped = nullValueSkipped; + } + @Override public void validate(Object object) throws ValidationException { @@ -176,16 +192,31 @@ if (log.isDebugEnabled()) { log.debug("hash for new key " + againstHashCode); } + + if (againstHashCode == null && nullValueSkipped) { + + // clef nulle, donc pas d'erreur vu que le flag a ete positionne + return; + } List<Integer> hashCodes = new ArrayList<Integer>(); int index = 0; for (Object o : col) { Integer hash = getUniqueKeyHashCode(o); + if (log.isDebugEnabled()) { log.debug("hash for object " + o + " = " + hash); } + + if (hash == null && nullValueSkipped) { + + // clef nulle, donc pas d'erreur vu que le flag a ete positionne + continue; + } + if (againstBean == null) { if (hashCodes.contains(hash)) { + // on a deja rencontre cette clef unique, // donc la validation a echouee answer = false; @@ -239,6 +270,12 @@ HashCodeBuilder builder = new HashCodeBuilder(); for (String key : keys) { Object property = getFieldValue(key, o); + if (property == null && nullValueSkipped) { + // une valeur nulle a ete trouvee et le flag de skip est positionne + // on retourne alors null comme cas limite + return null; + } + builder.append(property); } return builder.toHashCode(); Modified: trunk/jaxx-widgets/pom.xml =================================================================== --- trunk/jaxx-widgets/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/jaxx-widgets/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -35,7 +35,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> Modified: trunk/maven-jaxx-plugin/pom.xml =================================================================== --- trunk/maven-jaxx-plugin/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/maven-jaxx-plugin/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -35,7 +35,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>jaxx</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> </parent> <groupId>org.nuiton.jaxx</groupId> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-01-01 18:39:45 UTC (rev 2154) +++ trunk/pom.xml 2011-01-18 08:41:16 UTC (rev 2155) @@ -38,7 +38,7 @@ </parent> <artifactId>jaxx</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3-SNAPSHOT</version> <modules> <module>jaxx-runtime</module>