Hibernate SVN: r16051 - core/trunk/envers.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-02-27 23:55:29 -0500 (Fri, 27 Feb 2009)
New Revision: 16051
Modified:
core/trunk/envers/pom.xml
Log:
change to build with local entitymanager
Modified: core/trunk/envers/pom.xml
===================================================================
--- core/trunk/envers/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
+++ core/trunk/envers/pom.xml 2009-02-28 04:55:29 UTC (rev 16051)
@@ -84,42 +84,6 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
- <exclusions>
- <!-- todo : only needed until we migrate EM back to core -->
- <exclusion>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javassist</groupId>
- <artifactId>javassist</artifactId>
- </exclusion>
- <exclusion>
- <groupId>jboss</groupId>
- <artifactId>javassist</artifactId>
- </exclusion>
- <exclusion>
- <!-- OMG, YUCK YUCK YUCK -->
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator</artifactId>
- </exclusion>
- <exclusion>
- <groupId>net.sf.ehcache</groupId>
- <artifactId>ehcache</artifactId>
- </exclusion>
- <exclusion>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- </exclusion>
- <exclusion>
- <groupId>asm</groupId>
- <artifactId>asm</artifactId>
- </exclusion>
- <exclusion>
- <groupId>asm</groupId>
- <artifactId>asm-attrs</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -159,11 +123,6 @@
<version>${version}</version>
</dependency>
<dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>${version}</version>
@@ -177,7 +136,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
- <version>3.3.1.ga</version>
+ <version>${version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
@@ -185,6 +144,11 @@
<version>3.2.0.ga</version>
</dependency>
<dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
<version>1.6.5</version>
15 years, 10 months
Hibernate SVN: r16050 - in core/trunk: annotations and 24 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-02-27 23:45:24 -0500 (Fri, 27 Feb 2009)
New Revision: 16050
Modified:
core/trunk/annotations/pom.xml
core/trunk/cache-ehcache/pom.xml
core/trunk/cache-jbosscache/pom.xml
core/trunk/cache-jbosscache2/pom.xml
core/trunk/cache-oscache/pom.xml
core/trunk/cache-swarmcache/pom.xml
core/trunk/commons-annotations/
core/trunk/commons-annotations/pom.xml
core/trunk/connection-c3p0/pom.xml
core/trunk/connection-proxool/pom.xml
core/trunk/core/pom.xml
core/trunk/distribution/pom.xml
core/trunk/documentation/envers/pom.xml
core/trunk/documentation/jbosscache2/pom.xml
core/trunk/documentation/manual/pom.xml
core/trunk/documentation/pom.xml
core/trunk/documentation/releasenotes/pom.xml
core/trunk/entitymanager/
core/trunk/entitymanager/pom.xml
core/trunk/envers/pom.xml
core/trunk/jmx/pom.xml
core/trunk/parent/pom.xml
core/trunk/pom.xml
core/trunk/testing/pom.xml
core/trunk/testsuite/pom.xml
core/trunk/tutorials/eg/pom.xml
core/trunk/tutorials/pom.xml
core/trunk/tutorials/web/pom.xml
Log:
change versions from 3.4 to 3.5
Modified: core/trunk/annotations/pom.xml
===================================================================
--- core/trunk/annotations/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/annotations/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/cache-ehcache/pom.xml
===================================================================
--- core/trunk/cache-ehcache/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/cache-ehcache/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -91,4 +91,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/cache-jbosscache/pom.xml
===================================================================
--- core/trunk/cache-jbosscache/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/cache-jbosscache/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -122,4 +122,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/cache-jbosscache2/pom.xml
===================================================================
--- core/trunk/cache-jbosscache2/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/cache-jbosscache2/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/cache-oscache/pom.xml
===================================================================
--- core/trunk/cache-oscache/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/cache-oscache/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -28,4 +28,4 @@
<version>2.1</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/cache-swarmcache/pom.xml
===================================================================
--- core/trunk/cache-swarmcache/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/cache-swarmcache/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -28,4 +28,4 @@
<version>1.0RC2</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Property changes on: core/trunk/commons-annotations
___________________________________________________________________
Name: svn:ignore
- .*
build
test_output
target
+ target
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
Modified: core/trunk/commons-annotations/pom.xml
===================================================================
--- core/trunk/commons-annotations/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/commons-annotations/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/connection-c3p0/pom.xml
===================================================================
--- core/trunk/connection-c3p0/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/connection-c3p0/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -28,4 +28,4 @@
<version>0.9.1</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/connection-proxool/pom.xml
===================================================================
--- core/trunk/connection-proxool/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/connection-proxool/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -28,4 +28,4 @@
<version>0.8.3</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/core/pom.xml
===================================================================
--- core/trunk/core/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/core/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -135,4 +135,4 @@
<properties>
<antlrPluginVersion>2.1</antlrPluginVersion>
</properties>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/distribution/pom.xml
===================================================================
--- core/trunk/distribution/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/distribution/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -32,7 +32,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -168,4 +168,4 @@
</profile>
</profiles>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/documentation/envers/pom.xml
===================================================================
--- core/trunk/documentation/envers/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/documentation/envers/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/documentation/jbosscache2/pom.xml
===================================================================
--- core/trunk/documentation/jbosscache2/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/documentation/jbosscache2/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.3.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/documentation/manual/pom.xml
===================================================================
--- core/trunk/documentation/manual/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/documentation/manual/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
@@ -98,4 +98,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/documentation/pom.xml
===================================================================
--- core/trunk/documentation/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/documentation/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -25,4 +25,4 @@
-->
</modules>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/documentation/releasenotes/pom.xml
===================================================================
--- core/trunk/documentation/releasenotes/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/documentation/releasenotes/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
@@ -84,4 +84,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Property changes on: core/trunk/entitymanager
___________________________________________________________________
Name: svn:ignore
- .*
target
build
test_output
+ target
test_output
local
*.ipr
*.iws
*.iml
.classpath
.project
.nbattrs
*.log
*.properties
.clover
Modified: core/trunk/entitymanager/pom.xml
===================================================================
--- core/trunk/entitymanager/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/entitymanager/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/envers/pom.xml
===================================================================
--- core/trunk/envers/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/envers/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -7,7 +7,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/jmx/pom.xml
===================================================================
--- core/trunk/jmx/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/jmx/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -60,4 +60,4 @@
<version>1.2.14</version>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/parent/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -31,7 +31,7 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
<packaging>pom</packaging>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<name>Hibernate Core Parent POM</name>
<description>The base POM for all Hibernate Core modules.</description>
@@ -357,4 +357,4 @@
</snapshotRepository>
</distributionManagement>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/testing/pom.xml
===================================================================
--- core/trunk/testing/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/testing/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -42,4 +42,4 @@
</resource>
</resources>
</build>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/testsuite/pom.xml
===================================================================
--- core/trunk/testsuite/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/testsuite/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/tutorials/eg/pom.xml
===================================================================
--- core/trunk/tutorials/eg/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/tutorials/eg/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -32,7 +32,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tutorials</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -43,4 +43,4 @@
<name>Hibernate Example</name>
<description>A simple example of Hibernate functionality</description>
-</project>
\ No newline at end of file
+</project>
Modified: core/trunk/tutorials/pom.xml
===================================================================
--- core/trunk/tutorials/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/tutorials/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-parent</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
Modified: core/trunk/tutorials/web/pom.xml
===================================================================
--- core/trunk/tutorials/web/pom.xml 2009-02-27 17:04:57 UTC (rev 16049)
+++ core/trunk/tutorials/web/pom.xml 2009-02-28 04:45:24 UTC (rev 16050)
@@ -5,7 +5,7 @@
<parent>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tutorials</artifactId>
- <version>3.4.0-SNAPSHOT</version>
+ <version>3.5.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -24,4 +24,4 @@
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
15 years, 10 months
Hibernate SVN: r16049 - in validator/trunk/hibernate-validator/src: main/java/org/hibernate/validation/util and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-27 12:04:57 -0500 (Fri, 27 Feb 2009)
New Revision: 16049
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintViolationImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorContextImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ValidatorTypeHelper.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
Log:
- HV-106 Integrated TraversableResolver
- Some generic cleanup
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -67,7 +67,7 @@
* @return A list of <code>MetaConstraint</code> instances encapsulating the information of all the constraints
* defined on the bean.
*/
- List<MetaConstraint<T>> geMetaConstraintList();
+ List<MetaConstraint<T, ?>> geMetaConstraintList();
/**
* @return A map keying the property name of a constraint to its <code>ElementDescriptor</code>.
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -63,7 +63,7 @@
/**
* List of constraints.
*/
- private List<MetaConstraint<T>> metaConstraintList = new ArrayList<MetaConstraint<T>>();
+ private List<MetaConstraint<T, ?>> metaConstraintList = new ArrayList<MetaConstraint<T, ?>>();
/**
* List of cascaded fields.
@@ -171,12 +171,12 @@
}
}
- private void initFieldConstraints(Class clazz) {
+ private <A extends Annotation >void initFieldConstraints(Class clazz) {
for ( Field field : clazz.getDeclaredFields() ) {
List<ConstraintDescriptorImpl> fieldMetadata = findFieldLevelConstraints( field );
for ( ConstraintDescriptorImpl constraintDescription : fieldMetadata ) {
ReflectionHelper.setAccessibility( field );
- MetaConstraint<T> metaConstraint = new MetaConstraint<T>( field, beanClass, constraintDescription );
+ MetaConstraint<T, A> metaConstraint = new MetaConstraint<T, A>( field, beanClass, constraintDescription );
metaConstraintList.add( metaConstraint );
}
if ( field.isAnnotationPresent( Valid.class ) ) {
@@ -186,12 +186,12 @@
}
}
- private void initMethodConstraints(Class clazz) {
+ private <A extends Annotation> void initMethodConstraints(Class clazz) {
for ( Method method : clazz.getDeclaredMethods() ) {
List<ConstraintDescriptorImpl> methodMetadata = findMethodLevelConstraints( method );
for ( ConstraintDescriptorImpl constraintDescription : methodMetadata ) {
ReflectionHelper.setAccessibility( method );
- MetaConstraint<T> metaConstraint = new MetaConstraint<T>( method, beanClass, constraintDescription );
+ MetaConstraint<T, A> metaConstraint = new MetaConstraint<T, A>( method, beanClass, constraintDescription );
metaConstraintList.add( metaConstraint );
}
if ( method.isAnnotationPresent( Valid.class ) ) {
@@ -201,10 +201,10 @@
}
}
- private void initClassConstraints(Class clazz) {
+ private <A extends Annotation> void initClassConstraints(Class clazz) {
List<ConstraintDescriptorImpl> classMetadata = findClassLevelConstraints( clazz );
for ( ConstraintDescriptorImpl constraintDescription : classMetadata ) {
- MetaConstraint<T> metaConstraint = new MetaConstraint<T>( clazz, constraintDescription );
+ MetaConstraint<T, A> metaConstraint = new MetaConstraint<T, A>( clazz, constraintDescription );
metaConstraintList.add( metaConstraint );
}
}
@@ -349,7 +349,7 @@
return cascadedMembers;
}
- public List<MetaConstraint<T>> geMetaConstraintList() {
+ public List<MetaConstraint<T, ?>> geMetaConstraintList() {
return metaConstraintList;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -23,8 +23,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-
-import org.hibernate.validation.AmbiguousConstraintUsageException;
import javax.validation.ConstraintDescriptor;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorFactory;
@@ -33,6 +31,7 @@
import org.slf4j.Logger;
+import org.hibernate.validation.AmbiguousConstraintUsageException;
import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.ValidatorTypeHelper;
@@ -42,19 +41,19 @@
*
* @author Hardy Ferentschik
*/
-public class ConstraintTree<T extends Annotation> {
+public class ConstraintTree<A extends Annotation> {
private static final Logger log = LoggerFactory.make();
private final ConstraintTree<?> parent;
private final List<ConstraintTree<?>> children;
- private final ConstraintDescriptor<T> descriptor;
+ private final ConstraintDescriptor<A> descriptor;
- public ConstraintTree(ConstraintDescriptor<T> descriptor) {
+ public ConstraintTree(ConstraintDescriptor<A> descriptor) {
this( descriptor, null );
}
- private ConstraintTree(ConstraintDescriptor<T> descriptor, ConstraintTree<?> parent) {
+ private ConstraintTree(ConstraintDescriptor<A> descriptor, ConstraintTree<?> parent) {
this.parent = parent;
this.descriptor = descriptor;
final Set<ConstraintDescriptor<?>> composingConstraints = descriptor.getComposingConstraints();
@@ -86,23 +85,23 @@
return children.size() > 0;
}
- public ConstraintDescriptor<T> getDescriptor() {
+ public ConstraintDescriptor<A> getDescriptor() {
return descriptor;
}
- public <T> void validateConstraints(Object value, Class beanClass, ExecutionContext executionContext, List<ConstraintViolationImpl<T>> constraintViolations) {
- for ( ConstraintTree tree : getChildren() ) {
+ public <T, V> void validateConstraints(V value, Class<T> beanClass, ExecutionContext<T> executionContext, List<ConstraintViolationImpl<T>> constraintViolations) {
+ for ( ConstraintTree<?> tree : getChildren() ) {
tree.validateConstraints( value, beanClass, executionContext, constraintViolations );
}
final Object leafBeanInstance = executionContext.peekValidatedObject();
- ConstraintValidatorContextImpl constraintContext = new ConstraintValidatorContextImpl( descriptor );
if ( log.isTraceEnabled() ) {
log.trace( "Validating value {} against constraint defined by {}", value, descriptor );
}
- ConstraintValidator validator = getInitalizedValidator(
+ ConstraintValidator<A, V> validator = getInitalizedValidator(
value, executionContext.getConstraintValidatorFactory()
);
+ ConstraintValidatorContextImpl constraintContext = new ConstraintValidatorContextImpl( descriptor );
if ( !validator.isValid( value, constraintContext ) ) {
for ( ConstraintValidatorContextImpl.ErrorMessage error : constraintContext.getErrorMessages() ) {
final String message = error.getMessage();
@@ -156,8 +155,8 @@
*
* @return A initalized constraint validator matching the type of the value to be validated.
*/
- private ConstraintValidator getInitalizedValidator(Object value, ConstraintValidatorFactory constraintFactory) {
- Class<? extends ConstraintValidator<T, ?>> validatorClass;
+ private <V> ConstraintValidator<A, V> getInitalizedValidator(Object value, ConstraintValidatorFactory constraintFactory) {
+ Class<? extends ConstraintValidator<?, ?>> validatorClass;
//FIXME This sounds really bad, why value can be null. Why are we deciding of the validator based on the value?
if ( value == null ) {
validatorClass = descriptor.getConstraintValidatorClasses().get( 0 );
@@ -167,10 +166,10 @@
}
//
@SuppressWarnings("unchecked")
- ConstraintValidator<T,?> constraintValidator =
+ ConstraintValidator<?, ?> constraintValidator =
constraintFactory.getInstance( validatorClass );
initializeConstraint( descriptor, constraintValidator );
- return constraintValidator;
+ return ( ConstraintValidator<A, V> ) constraintValidator;
}
/**
@@ -180,12 +179,12 @@
*
* @return The class of a matching validator.
*/
- private Class findMatchingValidatorClass(Object value) {
+ private Class<? extends ConstraintValidator<?, ?>> findMatchingValidatorClass(Object value) {
Class valueClass = determineValueClass( value );
Map<Class<?>, Class<? extends ConstraintValidator<?, ?>>> validatorsTypes =
- ValidatorTypeHelper.getValidatorsTypes( descriptor.getConstraintValidatorClasses() );
+ ValidatorTypeHelper.getValidatorsTypes( ( List<Class<? extends ConstraintValidator<A, ?>>> ) descriptor.getConstraintValidatorClasses() );
List<Class> assignableClasses = findAssignableClasses( valueClass, validatorsTypes );
resolveAssignableClasses( assignableClasses );
@@ -258,7 +257,7 @@
}
private void initializeConstraint
- (ConstraintDescriptor<T>
+ (ConstraintDescriptor<A>
descriptor, ConstraintValidator
constraintValidator) {
try {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintViolationImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintViolationImpl.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintViolationImpl.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -17,8 +17,6 @@
*/
package org.hibernate.validation.engine;
-import java.util.HashSet;
-import java.util.Set;
import javax.validation.ConstraintDescriptor;
import javax.validation.ConstraintViolation;
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -18,24 +18,20 @@
package org.hibernate.validation.engine;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.MessageInterpolator;
+import javax.validation.TraversableResolver;
import org.hibernate.validation.util.IdentitySet;
/**
* Context object keeping track of all processed objects and all failing constraints.
* At the same time it keeps track of the currently validated object, the current group and property path.
- * The way the validation works at the moment the validated object and the property path have to be processed
- * in a stack fashion.
- * <p/>
- * all sort of information needed Introduced to reduce the parameters passed around between the different
- * validate methdods in <code>ValidatorImpl</code>.
+ * Currently the validated object and the property path are processed in a stack fashion.
*
* @author Hardy Ferentschik
* @author Emmanuel Bernard
@@ -72,7 +68,7 @@
* Stack for keeping track of the currently validated object.
*/
private Stack<Object> validatedObjectStack = new Stack<Object>();
-
+
/**
* The message resolver which should be used in this context.
*/
@@ -81,17 +77,20 @@
/**
* The constraint factory which should be used in this context.
*/
- ConstraintValidatorFactory constraintValidatorFactory;
+ private final ConstraintValidatorFactory constraintValidatorFactory;
+ private final TraversableResolver traversableResolver;
- public ExecutionContext(T object, MessageInterpolator messageResolver, ConstraintValidatorFactory constraintValidatorFactory) {
- this( object, object, messageResolver, constraintValidatorFactory );
+ public ExecutionContext(T object, MessageInterpolator messageResolver, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver) {
+ this( object, object, messageResolver, constraintValidatorFactory, traversableResolver );
}
- public ExecutionContext(T rootBean, Object object, MessageInterpolator messageResolver, ConstraintValidatorFactory constraintValidatorFactory) {
+ public ExecutionContext(T rootBean, Object object, MessageInterpolator messageResolver, ConstraintValidatorFactory constraintValidatorFactory, TraversableResolver traversableResolver) {
this.rootBean = rootBean;
this.messageResolver = messageResolver;
this.constraintValidatorFactory = constraintValidatorFactory;
+ this.traversableResolver = traversableResolver;
+
validatedObjectStack.push( object );
processedObjects = new HashMap<Class<?>, IdentitySet>();
propertyPath = "";
@@ -158,7 +157,7 @@
}
public void addConstraintFailures(List<ConstraintViolationImpl<T>> failingConstraintViolations) {
- for(ConstraintViolationImpl<T> violation : failingConstraintViolations) {
+ for ( ConstraintViolationImpl<T> violation : failingConstraintViolations ) {
addConstraintFailure( violation );
}
}
@@ -211,7 +210,28 @@
return propertyPath;
}
- public boolean checkValidationRequired(Collection<Class<?>> groups) {
- return groups.contains( currentGroup );
+ public String peekProperty() {
+ int lastIndex = propertyPath.lastIndexOf( '.' );
+ if ( lastIndex != -1 ) {
+ return propertyPath.substring( 0, lastIndex );
+ }
+ else {
+ return "";
+ }
}
+
+ public boolean isValidationRequired(MetaConstraint metaConstraint) {
+ if ( !metaConstraint.getGroupList().contains( currentGroup ) ) {
+ return false;
+ }
+
+ Class<?> rootBeanClass = rootBean == null ? null : rootBean.getClass();
+ return traversableResolver.isTraversable(
+ peekValidatedObject(),
+ peekProperty(),
+ rootBeanClass,
+ peekPropertyPath(),
+ metaConstraint.getElementType()
+ );
+ }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/MetaConstraint.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -17,6 +17,7 @@
*/
package org.hibernate.validation.engine;
+import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -35,12 +36,12 @@
*
* @author Hardy Ferentschik
*/
-public class MetaConstraint<T> {
+public class MetaConstraint<T, A extends Annotation> {
/**
* The constraint tree created from the constraint annotation.
*/
- private final ConstraintTree constraintTree;
+ private final ConstraintTree<A> constraintTree;
/**
* The type (class) the constraint was defined on. <code>null</code> if the constraint was specified on method or
@@ -76,11 +77,11 @@
*/
private final Class<T> beanClass;
- public MetaConstraint(Type t, ConstraintDescriptor constraintDescriptor) {
- this( t, null, null, ElementType.TYPE, (Class<T>) t.getClass(), constraintDescriptor, "" );
+ public MetaConstraint(Type t, ConstraintDescriptor<A> constraintDescriptor) {
+ this( t, null, null, ElementType.TYPE, ( Class<T> ) t.getClass(), constraintDescriptor, "" );
}
- public MetaConstraint(Method m, Class<T> beanClass, ConstraintDescriptor constraintDescriptor) {
+ public MetaConstraint(Method m, Class<T> beanClass, ConstraintDescriptor<A> constraintDescriptor) {
this(
null,
m,
@@ -92,18 +93,18 @@
);
}
- public MetaConstraint(Field f, Class<T> beanClass, ConstraintDescriptor constraintDescriptor) {
- this( null, null, f, ElementType.FIELD, beanClass, constraintDescriptor, f.getName());
+ public MetaConstraint(Field f, Class<T> beanClass, ConstraintDescriptor<A> constraintDescriptor) {
+ this( null, null, f, ElementType.FIELD, beanClass, constraintDescriptor, f.getName() );
}
- private MetaConstraint(Type t, Method m, Field f, ElementType elementType, Class<T> beanClass, ConstraintDescriptor constraintDescriptor, String property) {
+ private MetaConstraint(Type t, Method m, Field f, ElementType elementType, Class<T> beanClass, ConstraintDescriptor<A> constraintDescriptor, String property) {
this.type = t;
this.method = m;
this.field = f;
this.elementType = elementType;
this.propertyName = property;
this.beanClass = beanClass;
- constraintTree = new ConstraintTree( constraintDescriptor );
+ constraintTree = new ConstraintTree<A>( constraintDescriptor );
}
@@ -190,7 +191,7 @@
return constraintTree;
}
- public <T> boolean validateConstraint(Class beanClass, ExecutionContext<T> executionContext) {
+ public <T> boolean validateConstraint(Class<T> beanClass, ExecutionContext<T> executionContext) {
final Object leafBeanInstance = executionContext.peekValidatedObject();
Object value = getValue( leafBeanInstance );
List<ConstraintViolationImpl<T>> constraintViolations = new ArrayList<ConstraintViolationImpl<T>>();
@@ -202,7 +203,7 @@
return true;
}
- public <T> boolean validateConstraint(Class beanClass, Object value, ExecutionContext<T> executionContext) {
+ public <T> boolean validateConstraint(Class<T> beanClass, Object value, ExecutionContext<T> executionContext) {
List<ConstraintViolationImpl<T>> constraintViolations = new ArrayList<ConstraintViolationImpl<T>>();
constraintTree.validateConstraints( value, beanClass, executionContext, constraintViolations );
if ( constraintViolations.size() > 0 ) {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorContextImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorContextImpl.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorContextImpl.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -8,6 +8,7 @@
/**
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
public class ValidatorContextImpl implements ValidatorContext {
private MessageInterpolator messageInterpolator;
@@ -29,6 +30,9 @@
traversableResolver( factoryTraversableResolver );
}
+ /**
+ * {@inheritDoc}
+ */
public ValidatorContext messageInterpolator(MessageInterpolator messageInterpolator) {
if ( messageInterpolator == null ) {
this.messageInterpolator = factoryMessageInterpolator;
@@ -39,6 +43,9 @@
return this;
}
+ /**
+ * {@inheritDoc}
+ */
public ValidatorContext traversableResolver(TraversableResolver traversableResolver) {
if ( traversableResolver == null ) {
this.traversableResolver = factoryTraversableResolver;
@@ -49,7 +56,12 @@
return this;
}
+ /**
+ * {@inheritDoc}
+ */
public Validator getValidator() {
- return new ValidatorImpl( constraintValidatorFactory, messageInterpolator, constraintHelper );
+ return new ValidatorImpl(
+ constraintValidatorFactory, messageInterpolator, traversableResolver, constraintHelper
+ );
}
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorFactoryImpl.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -40,7 +40,6 @@
this.messageInterpolator = configurationState.getMessageInterpolator();
this.constraintValidatorFactory = configurationState.getConstraintValidatorFactory();
this.traversableResolver = configurationState.getTraversableResolver();
- //do init metadata from XML form
}
/**
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -32,6 +32,7 @@
import javax.validation.ConstraintValidatorFactory;
import javax.validation.ConstraintViolation;
import javax.validation.MessageInterpolator;
+import javax.validation.TraversableResolver;
import javax.validation.Validator;
import javax.validation.groups.Default;
@@ -86,11 +87,14 @@
private final MessageInterpolator messageInterpolator;
+ private final TraversableResolver traversableResolver;
+
private final ConstraintHelper constraintHelper;
- public ValidatorImpl(ConstraintValidatorFactory constraintValidatorFactory, MessageInterpolator messageInterpolator, ConstraintHelper constraintHelper) {
+ public ValidatorImpl(ConstraintValidatorFactory constraintValidatorFactory, MessageInterpolator messageInterpolator, TraversableResolver traversableResolver, ConstraintHelper constraintHelper) {
this.constraintValidatorFactory = constraintValidatorFactory;
this.messageInterpolator = messageInterpolator;
+ this.traversableResolver = traversableResolver;
this.constraintHelper = constraintHelper;
groupChainGenerator = new GroupChainGenerator();
@@ -106,7 +110,7 @@
GroupChain groupChain = determineGroupExecutionOrder( groups );
ExecutionContext<T> context = new ExecutionContext<T>(
- object, messageInterpolator, constraintValidatorFactory
+ object, messageInterpolator, constraintValidatorFactory, traversableResolver
);
List<ConstraintViolationImpl<T>> list = validateInContext( context, groupChain );
@@ -258,9 +262,9 @@
*/
private <T> boolean validateConstraintsForCurrentGroup(ExecutionContext<T> executionContext, BeanMetaData<T> beanMetaData) {
boolean validationSuccessful = true;
- for ( MetaConstraint<T> metaConstraint : beanMetaData.geMetaConstraintList() ) {
+ for ( MetaConstraint<T, ?> metaConstraint : beanMetaData.geMetaConstraintList() ) {
executionContext.pushProperty( metaConstraint.getPropertyName() );
- if ( executionContext.checkValidationRequired( metaConstraint.getGroupList() ) ) {
+ if ( executionContext.isValidationRequired( metaConstraint ) ) {
boolean tmp = metaConstraint.validateConstraint( beanMetaData.getBeanClass(), executionContext );
validationSuccessful = validationSuccessful && tmp;
}
@@ -355,7 +359,7 @@
@SuppressWarnings("unchecked")
final Class<T> beanType = ( Class<T> ) object.getClass();
- Set<MetaConstraint<T>> metaConstraints = new HashSet<MetaConstraint<T>>();
+ Set<MetaConstraint<T, ?>> metaConstraints = new HashSet<MetaConstraint<T, ?>>();
Object hostingBeanInstance = collectMetaConstraintsForPath( beanType, object, propertyIter, metaConstraints );
if ( hostingBeanInstance == null ) {
@@ -378,21 +382,21 @@
Iterator<List<Group>> sequenceIterator = groupChain.getSequenceIterator();
while ( sequenceIterator.hasNext() ) {
List<Group> sequence = sequenceIterator.next();
- int numberOfConstraintViolations = failingConstraintViolations.size();
+ int numberOfConstraintViolationsBefore = failingConstraintViolations.size();
for ( Group group : sequence ) {
validatePropertyForGroup(
object, propertyIter, failingConstraintViolations, metaConstraints, hostingBeanInstance, group
);
- if ( failingConstraintViolations.size() > numberOfConstraintViolations ) {
+ if ( failingConstraintViolations.size() > numberOfConstraintViolationsBefore ) {
break;
}
}
}
}
- private <T> int validatePropertyForGroup(T object, PropertyIterator propertyIter, List<ConstraintViolationImpl<T>> failingConstraintViolations, Set<MetaConstraint<T>> metaConstraints, Object hostingBeanInstance, Group group) {
- int numberOfConstraintViolations = failingConstraintViolations.size();
+ private <T> void validatePropertyForGroup(T object, PropertyIterator propertyIter, List<ConstraintViolationImpl<T>> failingConstraintViolations, Set<MetaConstraint<T, ?>> metaConstraints, Object hostingBeanInstance, Group group) {
+ int numberOfConstraintViolationsBefore = failingConstraintViolations.size();
BeanMetaData<T> beanMetaData = getBeanMetaData( metaConstraints.iterator().next().getBeanClass() );
List<Class<?>> groupList;
@@ -405,26 +409,30 @@
}
for ( Class<?> groupClass : groupList ) {
- for ( MetaConstraint<T> metaConstraint : metaConstraints ) {
- if ( metaConstraint.getGroupList().contains( groupClass ) ) {
- ExecutionContext<T> context = new ExecutionContext<T>(
- object, hostingBeanInstance, messageInterpolator, constraintValidatorFactory
- );
- context.pushProperty( propertyIter.getOriginalProperty() );
- metaConstraint.validateConstraint( object.getClass(), context );
+ for ( MetaConstraint<T, ?> metaConstraint : metaConstraints ) {
+ ExecutionContext<T> context = new ExecutionContext<T>(
+ object,
+ hostingBeanInstance,
+ messageInterpolator,
+ constraintValidatorFactory,
+ traversableResolver
+ );
+ context.pushProperty( propertyIter.getOriginalProperty() );
+ context.setCurrentGroup( groupClass );
+ if ( context.isValidationRequired( metaConstraint ) ) {
+ metaConstraint.validateConstraint( ( Class<T> ) object.getClass(), context );
failingConstraintViolations.addAll( context.getFailingConstraints() );
}
}
- if ( failingConstraintViolations.size() > numberOfConstraintViolations ) {
+ if ( failingConstraintViolations.size() > numberOfConstraintViolationsBefore ) {
break;
}
}
- return numberOfConstraintViolations;
}
@SuppressWarnings("unchecked")
private <T> void validateValue(Class<T> beanType, Object value, PropertyIterator propertyIter, List<ConstraintViolationImpl<T>> failingConstraintViolations, GroupChain groupChain) {
- Set<MetaConstraint<T>> metaConstraints = new HashSet<MetaConstraint<T>>();
+ Set<MetaConstraint<T, ?>> metaConstraints = new HashSet<MetaConstraint<T, ?>>();
collectMetaConstraintsForPath( beanType, null, propertyIter, metaConstraints );
if ( metaConstraints.size() == 0 ) {
@@ -467,7 +475,7 @@
}
}
- private <T> void validateValueForGroup(Class<T> beanType, Object value, PropertyIterator propertyIter, List<ConstraintViolationImpl<T>> failingConstraintViolations, Set<MetaConstraint<T>> metaConstraints, Group group) {
+ private <T> void validateValueForGroup(Class<T> beanType, Object value, PropertyIterator propertyIter, List<ConstraintViolationImpl<T>> failingConstraintViolations, Set<MetaConstraint<T, ?>> metaConstraints, Group group) {
int numberOfConstraintViolations = failingConstraintViolations.size();
BeanMetaData<T> beanMetaData = getBeanMetaData( metaConstraints.iterator().next().getBeanClass() );
@@ -481,13 +489,15 @@
}
for ( Class<?> groupClass : groupList ) {
- for ( MetaConstraint<T> metaConstraint : metaConstraints ) {
- if ( metaConstraint.getGroupList().contains( groupClass ) ) {
- ExecutionContext<T> context = new ExecutionContext<T>(
- ( T ) value, messageInterpolator, constraintValidatorFactory
- );
- context.pushProperty( propertyIter.getOriginalProperty() );
- metaConstraint.validateConstraint( beanType.getClass(), value, context );
+ for ( MetaConstraint<T, ?> metaConstraint : metaConstraints ) {
+ ExecutionContext<T> context = new ExecutionContext<T>(
+ ( T ) value, messageInterpolator, constraintValidatorFactory, traversableResolver
+ );
+ context.pushProperty( propertyIter.getOriginalProperty() );
+ context.setCurrentGroup( groupClass );
+
+ if ( context.isValidationRequired( metaConstraint ) ) {
+ metaConstraint.validateConstraint( beanType, value, context );
failingConstraintViolations.addAll( context.getFailingConstraints() );
}
}
@@ -511,7 +521,7 @@
* @return Returns the bean hosting the constraints which match the specified property path.
*/
@SuppressWarnings("unchecked")
- private <T> Object collectMetaConstraintsForPath(Class<T> clazz, Object value, PropertyIterator propertyIter, Set<MetaConstraint<T>> metaConstraints) {
+ private <T> Object collectMetaConstraintsForPath(Class<T> clazz, Object value, PropertyIterator propertyIter, Set<MetaConstraint<T, ?>> metaConstraints) {
propertyIter.split();
if ( !propertyIter.hasNext() ) {
@@ -519,8 +529,8 @@
throw new IllegalArgumentException( "Invalid property path." );
}
- List<MetaConstraint<T>> metaConstraintList = getBeanMetaData( clazz ).geMetaConstraintList();
- for ( MetaConstraint<T> metaConstraint : metaConstraintList ) {
+ List<MetaConstraint<T, ?>> metaConstraintList = getBeanMetaData( clazz ).geMetaConstraintList();
+ for ( MetaConstraint<T, ?> metaConstraint : metaConstraintList ) {
if ( metaConstraint.getPropertyName().equals( propertyIter.getHead() ) ) {
metaConstraints.add( metaConstraint );
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ValidatorTypeHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ValidatorTypeHelper.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ValidatorTypeHelper.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -46,7 +46,7 @@
* key is the type the validator accepts and value the validator class itself.
*/
public static <T extends Annotation> Map<Class<?>, Class<? extends ConstraintValidator<?, ?>>> getValidatorsTypes(
- List<Class<? extends ConstraintValidator<T, ?>>> validators) {
+ List<Class<? extends ConstraintValidator<T, ?>>> validators) {
if ( validators == null || validators.size() == 0 ) {
throw new ValidationException( "No ConstraintValidators associated to @Constraint" );
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -17,6 +17,7 @@
*/
package org.hibernate.validation.bootstrap;
+import java.lang.annotation.ElementType;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -28,6 +29,7 @@
import javax.validation.ConstraintValidatorFactory;
import javax.validation.ConstraintViolation;
import javax.validation.MessageInterpolator;
+import javax.validation.TraversableResolver;
import javax.validation.Validation;
import javax.validation.ValidationException;
import javax.validation.ValidationProviderResolver;
@@ -42,12 +44,12 @@
import static org.junit.Assert.fail;
import org.junit.Test;
-import org.hibernate.validation.engine.HibernateValidatorConfiguration;
import org.hibernate.validation.HibernateValidationProvider;
import org.hibernate.validation.constraints.NotNullValidator;
import org.hibernate.validation.eg.Customer;
import org.hibernate.validation.engine.ConfigurationImpl;
import org.hibernate.validation.engine.ConstraintValidatorFactoryImpl;
+import org.hibernate.validation.engine.HibernateValidatorConfiguration;
import org.hibernate.validation.engine.ValidatorFactoryImpl;
/**
@@ -91,7 +93,6 @@
assertEquals( "Wrong number of constraints", 0, constraintViolations.size() );
}
-
@Test
public void testCustomMessageInterpolator() {
@@ -100,7 +101,7 @@
assertDefaultBuilderAndFactory( configuration );
ValidatorFactory factory = configuration.buildValidatorFactory();
- Validator validator = factory.getValidator( );
+ Validator validator = factory.getValidator();
Customer customer = new Customer();
customer.setFirstName( "John" );
@@ -124,7 +125,7 @@
}
);
factory = configuration.buildValidatorFactory();
- validator = factory.getValidator( );
+ validator = factory.getValidator();
constraintViolations = validator.validate( customer );
assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
constraintViolation = constraintViolations.iterator().next();
@@ -138,7 +139,7 @@
assertDefaultBuilderAndFactory( configuration );
ValidatorFactory factory = configuration.buildValidatorFactory();
- Validator validator = factory.getValidator( );
+ Validator validator = factory.getValidator();
Customer customer = new Customer();
customer.setFirstName( "John" );
@@ -162,7 +163,7 @@
}
);
factory = configuration.buildValidatorFactory();
- validator = factory.getValidator( );
+ validator = factory.getValidator();
constraintViolations = validator.validate( customer );
assertEquals( "Wrong number of constraints", 0, constraintViolations.size() );
}
@@ -180,9 +181,9 @@
HibernateValidatorConfiguration configuration = Validation
- .byProvider( HibernateValidatorConfiguration.class )
- .providerResolver( resolver )
- .configure();
+ .byProvider( HibernateValidatorConfiguration.class )
+ .providerResolver( resolver )
+ .configure();
assertDefaultBuilderAndFactory( configuration );
}
@@ -199,9 +200,9 @@
Configuration<?> configuration = Validation
- .byDefaultProvider()
- .providerResolver( resolver )
- .configure();
+ .byDefaultProvider()
+ .providerResolver( resolver )
+ .configure();
assertDefaultBuilderAndFactory( configuration );
}
@@ -216,7 +217,7 @@
final ProviderSpecificBootstrap<HibernateValidatorConfiguration> providerSpecificBootstrap =
Validation
- .byProvider( HibernateValidatorConfiguration.class)
+ .byProvider( HibernateValidatorConfiguration.class )
.providerResolver( resolver );
try {
@@ -237,7 +238,7 @@
assertTrue( configuration instanceof ConfigurationImpl );
ValidatorFactory factory = configuration.buildValidatorFactory();
- assertDefaultFactory(factory);
+ assertDefaultFactory( factory );
}
private void assertDefaultFactory(ValidatorFactory factory) {
@@ -251,4 +252,36 @@
return true;
}
}
+
+ @Test
+ public void testCustomTraversableResolver() {
+
+ Configuration<?> configuration = Validation.byDefaultProvider().configure();
+ assertDefaultBuilderAndFactory( configuration );
+
+ ValidatorFactory factory = configuration.buildValidatorFactory();
+ Validator validator = factory.getValidator();
+
+ Customer customer = new Customer();
+ customer.setFirstName( "John" );
+
+ Set<ConstraintViolation<Customer>> constraintViolations = validator.validate( customer );
+ assertEquals( "Wrong number of constraints", 1, constraintViolations.size() );
+ ConstraintViolation<Customer> constraintViolation = constraintViolations.iterator().next();
+ assertEquals( "Wrong message", "may not be null", constraintViolation.getMessage() );
+
+ // get a new factory using a custom configuration
+ configuration = Validation.byDefaultProvider().configure();
+ configuration.traversableResolver(
+ new TraversableResolver() {
+ public boolean isTraversable(Object o, String s, Class<?> aClass, String s1, ElementType elementType) {
+ return false;
+ }
+ }
+ );
+ factory = configuration.buildValidatorFactory();
+ validator = factory.getValidator();
+ constraintViolations = validator.validate( customer );
+ assertEquals( "Wrong number of constraints", 0, constraintViolations.size() );
+ }
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-02-27 14:13:29 UTC (rev 16048)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-02-27 17:04:57 UTC (rev 16049)
@@ -455,7 +455,7 @@
);
}
- @org.junit.Test
+ @Test
public void testObjectTraversion() {
Validator validator = TestUtil.getValidator();
15 years, 10 months
Hibernate SVN: r16048 - beanvalidation/trunk/validation-api/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-27 09:13:29 -0500 (Fri, 27 Feb 2009)
New Revision: 16048
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDeclarationException.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDefinitionException.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolationException.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupDefinitionException.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/TraversableResolver.java
Log:
added file headers and updated some javadoc
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java 2009-02-27 13:39:53 UTC (rev 16047)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java 2009-02-27 14:13:29 UTC (rev 16048)
@@ -1,3 +1,20 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
package javax.validation;
import java.util.Set;
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDeclarationException.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDeclarationException.java 2009-02-27 13:39:53 UTC (rev 16047)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDeclarationException.java 2009-02-27 14:13:29 UTC (rev 16048)
@@ -1,3 +1,20 @@
+// $Id: Configuration.java 16026 2009-02-24 20:02:35Z epbernard $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
package javax.validation;
/**
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDefinitionException.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDefinitionException.java 2009-02-27 13:39:53 UTC (rev 16047)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDefinitionException.java 2009-02-27 14:13:29 UTC (rev 16048)
@@ -1,3 +1,20 @@
+// $Id: Configuration.java 16026 2009-02-24 20:02:35Z epbernard $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
package javax.validation;
/**
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-02-27 13:39:53 UTC (rev 16047)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-02-27 14:13:29 UTC (rev 16048)
@@ -1,3 +1,20 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
package javax.validation;
/**
@@ -24,16 +41,16 @@
/**
* Add a new error message. This error message will be interpolated.
* <p/>
- * If isValid returns false, a ConstraintViolation object will be built per error message
- * including the default one unless #disableDefaultError() has been called.
+ * If <code>isValid<code> returns <code>false</code>, a <code>ConstraintViolation</code> object will be built
+ * per error message including the default one unless {@link #disableDefaultError()} has been called.
* <p/>
- * Aside from the error message, ConstraintViolation objects generated from such a call
- * contains the same contextual information (root bean, path and so on)
+ * Aside from the error message, <code>ConstraintViolation</code> objects generated from such a call
+ * contain the same contextual information (root bean, path and so on)
* <p/>
- * This method can be called multiple time. One ConstraintViolation instance per
+ * This method can be called multiple times. One <code>ConstraintViolation</code> instance per
* call is created.
*
- * @param message new uninterpolated error message
+ * @param message new uninterpolated error message.
*/
void addError(String message);
@@ -41,13 +58,13 @@
* Add a new error message to a given sub property <code>property</code>.
* This error message will be interpolated.
* <p/>
- * If isValid returns false, a ConstraintViolation object will be built
- * per error message including the default one unless #disableDefaultError()
+ * If <code>isValid</code> returns <code>false</code>, a <code>ConstraintViolation</code> object will be built
+ * per error message including the default one unless {@link #disableDefaultError()}
* has been called.
* <p/>
*
- * @param message new uninterpolated error message
- * @param property property name the ConstraintViolation is targeting
+ * @param message new uninterpolated error message.
+ * @param property property name the </code>ConstraintViolation</code> is targeting.
*/
void addError(String message, String property);
}
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolationException.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolationException.java 2009-02-27 13:39:53 UTC (rev 16047)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolationException.java 2009-02-27 14:13:29 UTC (rev 16048)
@@ -1,3 +1,20 @@
+// $Id: Configuration.java 16026 2009-02-24 20:02:35Z epbernard $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
package javax.validation;
import java.util.Set;
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupDefinitionException.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupDefinitionException.java 2009-02-27 13:39:53 UTC (rev 16047)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupDefinitionException.java 2009-02-27 14:13:29 UTC (rev 16048)
@@ -1,3 +1,20 @@
+// $Id: Configuration.java 16026 2009-02-24 20:02:35Z epbernard $
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
package javax.validation;
/**
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/TraversableResolver.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/TraversableResolver.java 2009-02-27 13:39:53 UTC (rev 16047)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/TraversableResolver.java 2009-02-27 14:13:29 UTC (rev 16048)
@@ -1,3 +1,20 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
package javax.validation;
import java.lang.annotation.ElementType;
15 years, 10 months
Hibernate SVN: r16047 - beanvalidation/trunk/validation-api/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-02-27 08:39:53 -0500 (Fri, 27 Feb 2009)
New Revision: 16047
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
Log:
JavaDoc
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2009-02-26 16:26:54 UTC (rev 16046)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2009-02-27 13:39:53 UTC (rev 16047)
@@ -24,6 +24,7 @@
/**
* Describes a single constraint and its composing constraints.
+ * T is the constraint's annotation type.
*
* @author Emmanuel Bernard
* @author Hardy Ferentschik
15 years, 10 months
Hibernate SVN: r16046 - validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report.
by hibernate-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-02-26 11:26:54 -0500 (Thu, 26 Feb 2009)
New Revision: 16046
Modified:
validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
Log:
minor
Modified: validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java
===================================================================
--- validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-26 14:18:07 UTC (rev 16045)
+++ validator/trunk/tck-utils/impl/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-26 16:26:54 UTC (rev 16046)
@@ -425,7 +425,7 @@
if (coveragePercent >= 0)
{
- String bgColor = coveragePercent < 60 ? "#ffaaaa" : coveragePercent < 80 ? "#ffffaa" : "#aaffaa" ;
+ String bgColor = coveragePercent < 60 ? "#ffaaaa" : coveragePercent < 80 ? "#ffffaa" : coveragePercent > 100 ? "#FF00CC" : "#aaffaa" ;
sb.append("<td align=\"center\" style=\"background-color:" + bgColor + "\">");
sb.append(String.format("%.2f%%", coveragePercent));
@@ -584,7 +584,7 @@
if (coveragePercent >= 0)
{
- String bgColor = coveragePercent < 60 ? "#ffaaaa" : coveragePercent < 80 ? "#ffffaa" : "#aaffaa" ;
+ String bgColor = coveragePercent < 60 ? "#ffaaaa" : coveragePercent < 80 ? "#ffffaa" : coveragePercent > 100 ? "#FF00CC" : "#aaffaa" ;
sb.append("<td align=\"center\" style=\"background-color:" + bgColor + "\">");
sb.append(String.format("%.2f%%", coveragePercent));
@@ -725,6 +725,10 @@
sb.append(" </div>\n");
}
+ else if (!coverage.isEmpty())
+ {
+ sb.append("<b>A test exists for this untestable assertion!</b>");
+ }
sb.append("</div></div>");
}
15 years, 10 months
Hibernate SVN: r16045 - in validator/trunk/hibernate-validator: src/main/java/org/hibernate/validation/engine and 6 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-26 09:18:07 -0500 (Thu, 26 Feb 2009)
New Revision: 16045
Added:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/Junit4TestFactory.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/ValidationPerformace.java
Modified:
validator/trunk/hibernate-validator/pom.xml
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java
validator/trunk/hibernate-validator/src/test/resources/log4j.properties
Log:
HV-83 Improved the way the object graph is traveresed in a simpel way. Now the processing of groups is breadth first and sequences are processed depth first.
Also fixed a bug regarding indexed cascaded constraints.
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2009-02-26 13:52:37 UTC (rev 16044)
+++ validator/trunk/hibernate-validator/pom.xml 2009-02-26 14:18:07 UTC (rev 16045)
@@ -40,6 +40,12 @@
<version>4.4</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>junitperf</groupId>
+ <artifactId>junitperf</artifactId>
+ <version>1.8</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<resources>
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-02-26 13:52:37 UTC (rev 16044)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-02-26 14:18:07 UTC (rev 16045)
@@ -203,7 +203,8 @@
}
public void replacePropertyIndex(String index) {
- propertyPath = propertyPath.replaceAll( "\\{0\\}", index );
+ // replace the last occurance of [<oldIndex>] with [<index>]
+ propertyPath = propertyPath.replaceAll( "\\[[0-9]*\\]$", "[" + index + "]" );
}
public String peekPropertyPath() {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-02-26 13:52:37 UTC (rev 16044)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ValidatorImpl.java 2009-02-26 14:18:07 UTC (rev 16045)
@@ -183,16 +183,34 @@
return Collections.emptyList();
}
- while ( groupChain.hasNext() ) {
- int numberOfViolations = context.getFailingConstraints().size();
- Group group = groupChain.next();
+ // process all groups breadth-first
+ Iterator<Group> groupIterator = groupChain.getGroupIterator();
+ while ( groupIterator.hasNext() ) {
+ Group group = groupIterator.next();
context.setCurrentGroup( group.getGroup() );
-
validateConstraints( context );
+ }
+ groupIterator = groupChain.getGroupIterator();
+ while ( groupIterator.hasNext() ) {
+ Group group = groupIterator.next();
+ context.setCurrentGroup( group.getGroup() );
validateCascadedConstraints( context );
+ }
- if ( groupChain.inSequence() && context.getFailingConstraints().size() > numberOfViolations ) {
- groupChain.moveToLastInCurrentSequence();
+ // process sequences depth-first to guarantee that groups following a violation within a group won't get executed.
+ Iterator<List<Group>> sequenceIterator = groupChain.getSequenceIterator();
+ while ( sequenceIterator.hasNext() ) {
+ List<Group> sequence = sequenceIterator.next();
+ for ( Group group : sequence ) {
+ int numberOfViolations = context.getFailingConstraints().size();
+ context.setCurrentGroup( group.getGroup() );
+
+ validateConstraints( context );
+ validateCascadedConstraints( context );
+
+ if ( context.getFailingConstraints().size() > numberOfViolations ) {
+ break;
+ }
}
}
return context.getFailingConstraints();
@@ -209,8 +227,8 @@
BeanMetaData<T> beanMetaData = getBeanMetaData( ( Class<T> ) executionContext.peekValidatedObjectType() );
if ( executionContext.getCurrentGroup().getName().equals( Default.class.getName() ) ) {
List<Class<?>> defaultGroupSequence = beanMetaData.getDefaultGroupSequence();
- if ( log.isDebugEnabled() && defaultGroupSequence.size() > 0 ) {
- log.debug(
+ if ( log.isTraceEnabled() && defaultGroupSequence.size() > 0 && defaultGroupSequence.get( 0 ) != Default.class ) {
+ log.trace(
"Executing re-defined Default group for bean {} as sequence {}",
beanMetaData.getBeanClass().getName(),
defaultGroupSequence
@@ -220,12 +238,6 @@
executionContext.setCurrentGroup( defaultSequenceMember );
boolean validationSuccessful = validateConstraintsForCurrentGroup( executionContext, beanMetaData );
if ( !validationSuccessful ) {
- if ( log.isDebugEnabled() ) {
- log.debug(
- "Aborting validation of Default group sequence for {} due to constraint violation.",
- beanMetaData.getBeanClass().getName()
- );
- }
break;
}
}
@@ -293,12 +305,12 @@
( Iterable<?> ) value :
map.entrySet();
iter = elements.iterator();
- context.appendIndexToPropertyPath( "[{0}]" );
+ context.appendIndexToPropertyPath( "[]" );
}
else if ( ReflectionHelper.isArray( type ) ) {
List<?> arrayList = Arrays.asList( value );
iter = arrayList.iterator();
- context.appendIndexToPropertyPath( "[{0}]" );
+ context.appendIndexToPropertyPath( "[]" );
}
else {
List<Object> list = new ArrayList<Object>();
@@ -324,19 +336,16 @@
actualValue = ( ( Map.Entry ) actualValue ).getValue();
}
- if ( context.isProcessedForCurrentGroup( actualValue ) ) {
- i++;
- continue;
+ if ( !context.isProcessedForCurrentGroup( actualValue ) ) {
+ context.replacePropertyIndex( propertyIndex );
+
+ context.pushValidatedObject( actualValue );
+ validateInContext(
+ context,
+ groupChainGenerator.getGroupChainFor( Arrays.asList( new Class<?>[] { context.getCurrentGroup() } ) )
+ );
+ context.popValidatedObject();
}
-
- context.replacePropertyIndex( propertyIndex );
-
- context.pushValidatedObject( actualValue );
- validateInContext(
- context,
- groupChainGenerator.getGroupChainFor( Arrays.asList( new Class<?>[] { context.getCurrentGroup() } ) )
- );
- context.popValidatedObject();
i++;
}
}
@@ -357,40 +366,60 @@
return;
}
- while ( groupChain.hasNext() ) {
- Group group = groupChain.next();
+
+ Iterator<Group> groupIterator = groupChain.getGroupIterator();
+ while ( groupIterator.hasNext() ) {
+ Group group = groupIterator.next();
+ validatePropertyForGroup(
+ object, propertyIter, failingConstraintViolations, metaConstraints, hostingBeanInstance, group
+ );
+ }
+
+ Iterator<List<Group>> sequenceIterator = groupChain.getSequenceIterator();
+ while ( sequenceIterator.hasNext() ) {
+ List<Group> sequence = sequenceIterator.next();
int numberOfConstraintViolations = failingConstraintViolations.size();
- BeanMetaData<T> beanMetaData = getBeanMetaData( metaConstraints.iterator().next().getBeanClass() );
+ for ( Group group : sequence ) {
+ validatePropertyForGroup(
+ object, propertyIter, failingConstraintViolations, metaConstraints, hostingBeanInstance, group
+ );
- List<Class<?>> groupList;
- if ( group.isDefaultGroup() ) {
- groupList = beanMetaData.getDefaultGroupSequence();
- }
- else {
- groupList = new ArrayList<Class<?>>();
- groupList.add( group.getGroup() );
- }
-
- for ( Class<?> groupClass : groupList ) {
- for ( MetaConstraint<T> metaConstraint : metaConstraints ) {
- if ( metaConstraint.getGroupList().contains( groupClass ) ) {
- ExecutionContext<T> context = new ExecutionContext<T>(
- object, hostingBeanInstance, messageInterpolator, constraintValidatorFactory
- );
- context.pushProperty( propertyIter.getOriginalProperty() );
- metaConstraint.validateConstraint( object.getClass(), context );
- failingConstraintViolations.addAll( context.getFailingConstraints() );
- }
- }
- if ( failingConstraintViolations.size() > numberOfConstraintViolations) {
+ if ( failingConstraintViolations.size() > numberOfConstraintViolations ) {
break;
}
}
+ }
+ }
- if ( groupChain.inSequence() && failingConstraintViolations.size() > numberOfConstraintViolations ) {
- groupChain.moveToLastInCurrentSequence();
+ private <T> int validatePropertyForGroup(T object, PropertyIterator propertyIter, List<ConstraintViolationImpl<T>> failingConstraintViolations, Set<MetaConstraint<T>> metaConstraints, Object hostingBeanInstance, Group group) {
+ int numberOfConstraintViolations = failingConstraintViolations.size();
+ BeanMetaData<T> beanMetaData = getBeanMetaData( metaConstraints.iterator().next().getBeanClass() );
+
+ List<Class<?>> groupList;
+ if ( group.isDefaultGroup() ) {
+ groupList = beanMetaData.getDefaultGroupSequence();
+ }
+ else {
+ groupList = new ArrayList<Class<?>>();
+ groupList.add( group.getGroup() );
+ }
+
+ for ( Class<?> groupClass : groupList ) {
+ for ( MetaConstraint<T> metaConstraint : metaConstraints ) {
+ if ( metaConstraint.getGroupList().contains( groupClass ) ) {
+ ExecutionContext<T> context = new ExecutionContext<T>(
+ object, hostingBeanInstance, messageInterpolator, constraintValidatorFactory
+ );
+ context.pushProperty( propertyIter.getOriginalProperty() );
+ metaConstraint.validateConstraint( object.getClass(), context );
+ failingConstraintViolations.addAll( context.getFailingConstraints() );
+ }
}
+ if ( failingConstraintViolations.size() > numberOfConstraintViolations ) {
+ break;
+ }
}
+ return numberOfConstraintViolations;
}
@SuppressWarnings("unchecked")
@@ -402,39 +431,69 @@
return;
}
- while ( groupChain.hasNext() ) {
- Group group = groupChain.next();
+ // process groups
+ Iterator<Group> groupIterator = groupChain.getGroupIterator();
+ while ( groupIterator.hasNext() ) {
+ Group group = groupIterator.next();
+ validateValueForGroup(
+ beanType,
+ value,
+ propertyIter,
+ failingConstraintViolations,
+ metaConstraints,
+ group
+ );
+ }
+
+ // process squences
+ Iterator<List<Group>> sequenceIterator = groupChain.getSequenceIterator();
+ while ( sequenceIterator.hasNext() ) {
+ List<Group> sequence = sequenceIterator.next();
int numberOfConstraintViolations = failingConstraintViolations.size();
- BeanMetaData<T> beanMetaData = getBeanMetaData( metaConstraints.iterator().next().getBeanClass() );
+ for ( Group group : sequence ) {
+ validateValueForGroup(
+ beanType,
+ value,
+ propertyIter,
+ failingConstraintViolations,
+ metaConstraints,
+ group
+ );
- List<Class<?>> groupList;
- if ( group.isDefaultGroup() ) {
- groupList = beanMetaData.getDefaultGroupSequence();
- }
- else {
- groupList = new ArrayList<Class<?>>();
- groupList.add( group.getGroup() );
- }
-
- for ( Class<?> groupClass : groupList ) {
- for ( MetaConstraint<T> metaConstraint : metaConstraints ) {
- if ( metaConstraint.getGroupList().contains( groupClass ) ) {
- ExecutionContext<T> context = new ExecutionContext<T>(
- ( T ) value, messageInterpolator, constraintValidatorFactory
- );
- context.pushProperty( propertyIter.getOriginalProperty() );
- metaConstraint.validateConstraint( beanType.getClass(), value, context );
- failingConstraintViolations.addAll( context.getFailingConstraints() );
- }
- }
- if ( failingConstraintViolations.size() > numberOfConstraintViolations) {
+ if ( failingConstraintViolations.size() > numberOfConstraintViolations ) {
break;
}
}
+ }
+ }
- if ( groupChain.inSequence() && failingConstraintViolations.size() > numberOfConstraintViolations ) {
- groupChain.moveToLastInCurrentSequence();
+ private <T> void validateValueForGroup(Class<T> beanType, Object value, PropertyIterator propertyIter, List<ConstraintViolationImpl<T>> failingConstraintViolations, Set<MetaConstraint<T>> metaConstraints, Group group) {
+ int numberOfConstraintViolations = failingConstraintViolations.size();
+ BeanMetaData<T> beanMetaData = getBeanMetaData( metaConstraints.iterator().next().getBeanClass() );
+
+ List<Class<?>> groupList;
+ if ( group.isDefaultGroup() ) {
+ groupList = beanMetaData.getDefaultGroupSequence();
+ }
+ else {
+ groupList = new ArrayList<Class<?>>();
+ groupList.add( group.getGroup() );
+ }
+
+ for ( Class<?> groupClass : groupList ) {
+ for ( MetaConstraint<T> metaConstraint : metaConstraints ) {
+ if ( metaConstraint.getGroupList().contains( groupClass ) ) {
+ ExecutionContext<T> context = new ExecutionContext<T>(
+ ( T ) value, messageInterpolator, constraintValidatorFactory
+ );
+ context.pushProperty( propertyIter.getOriginalProperty() );
+ metaConstraint.validateConstraint( beanType.getClass(), value, context );
+ failingConstraintViolations.addAll( context.getFailingConstraints() );
+ }
}
+ if ( failingConstraintViolations.size() > numberOfConstraintViolations ) {
+ break;
+ }
}
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java 2009-02-26 13:52:37 UTC (rev 16044)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/groups/GroupChain.java 2009-02-26 14:18:07 UTC (rev 16045)
@@ -18,6 +18,7 @@
package org.hibernate.validation.engine.groups;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
/**
@@ -28,52 +29,27 @@
public class GroupChain {
/**
- * The actual list of groups maintained by this instance.
+ * The list of single groups.
*/
private List<Group> groupList = new ArrayList<Group>();
/**
- * A pointer to the next group element.
+ * The list of sequences.
*/
- private int nextGroupPointer = 0;
+ private List<List<Group>> sequenceList = new ArrayList<List<Group>>();
- /**
- * The current group.
- */
- private Class<?> currentSequence = null;
-
- /**
- * @return Returns <code>true</code> if there is another group in the chain <code>false</code> otherwise.
- */
- public boolean hasNext() {
- return nextGroupPointer < groupList.size();
+ public Iterator<Group> getGroupIterator() {
+ return groupList.iterator();
}
- /**
- * @return Returns the next group in the chain or <code>null</code> if there is none.
- */
- public Group next() {
- if ( !hasNext() ) {
- return null;
- }
-
- Group group = groupList.get( nextGroupPointer );
- nextGroupPointer++;
- currentSequence = group.getSequence();
- return group;
+ public Iterator<List<Group>> getSequenceIterator() {
+ return sequenceList.iterator();
}
- /**
- * @return The number of groups in this chain.
- */
- public int size() {
- return groupList.size();
- }
-
public boolean containsSequence(Class<?> groupSequence) {
boolean result = false;
- for ( Group group : groupList ) {
- if ( groupSequence.getName().equals( group.getSequence().getName() ) ) {
+ for ( List<Group> sequence : sequenceList ) {
+ if ( sequence.get( 0 ).getSequence().getName().equals( groupSequence.getName() ) ) {
result = true;
break;
}
@@ -81,30 +57,7 @@
return result;
}
- public void moveToLastInCurrentSequence() {
- if ( currentSequence == null ) {
- return;
- }
-
- while ( hasNext() ) {
- if ( currentSequence.getName().equals( groupList.get( nextGroupPointer ).getSequence().getName() ) ) {
- next();
- }
- else {
- break;
- }
- }
- }
-
- public boolean inSequence() {
- return currentSequence != null;
- }
-
void insertGroup(Group group) {
- if ( nextGroupPointer != 0 ) {
- throw new RuntimeException( "Trying to modify the GroupChain while iterating." );
- }
-
if ( !groupList.contains( group ) ) {
groupList.add( group );
}
@@ -115,16 +68,8 @@
return;
}
- if ( !containsSequence( groups.get( 0 ).getSequence() ) ) {
- groupList.addAll( groups );
+ if ( !sequenceList.contains( groups ) ) {
+ sequenceList.add( groups );
}
}
-
- @Override
- public String toString() {
- return "GroupChain{" +
- "groupList=" + groupList +
- ", nextGroupPointer=" + nextGroupPointer +
- '}';
- }
}
\ No newline at end of file
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-02-26 13:52:37 UTC (rev 16044)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-02-26 14:18:07 UTC (rev 16045)
@@ -40,6 +40,9 @@
import org.hibernate.validation.eg.Order;
import org.hibernate.validation.eg.Person;
import org.hibernate.validation.eg.UnconstraintEntity;
+import org.hibernate.validation.eg.groups.First;
+import org.hibernate.validation.eg.groups.Last;
+import org.hibernate.validation.eg.groups.Second;
import org.hibernate.validation.util.LoggerFactory;
import org.hibernate.validation.util.TestUtil;
import static org.hibernate.validation.util.TestUtil.assertConstraintViolation;
@@ -328,7 +331,7 @@
}
catch ( IllegalArgumentException e ) {
assertEquals( "Invalid property path.", e.getMessage() );
- }
+ }
}
@Test
@@ -451,4 +454,23 @@
groups.iterator().next()
);
}
+
+ @org.junit.Test
+ public void testObjectTraversion() {
+ Validator validator = TestUtil.getValidator();
+
+ Customer customer = new Customer();
+ customer.setFirstName( "John" );
+ customer.setLastName( "Doe" );
+
+ for ( int i = 0; i < 100; i++ ) {
+ Order order = new Order();
+ customer.addOrder( order );
+ }
+
+ Set<ConstraintViolation<Customer>> constraintViolations = validator.validate(
+ customer, Default.class, First.class, Second.class, Last.class
+ );
+ assertEquals( "Wrong number of constraints", 100, constraintViolations.size() );
+ }
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java 2009-02-26 13:52:37 UTC (rev 16044)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupChainGeneratorTest.java 2009-02-26 14:18:07 UTC (rev 16045)
@@ -18,12 +18,13 @@
package org.hibernate.validation.engine.groups;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
+import java.util.List;
import javax.validation.ValidationException;
import javax.validation.groups.Default;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
@@ -31,8 +32,6 @@
import org.hibernate.validation.eg.groups.Last;
import org.hibernate.validation.eg.groups.Second;
-import static junit.framework.Assert.assertFalse;
-
/**
* @author Hardy Ferentschik
*/
@@ -83,35 +82,44 @@
groups.add( Second.class );
groups.add( Last.class );
GroupChain chain = generator.getGroupChainFor( groups );
- assertEquals( "Wrong number of groups", 3, chain.size() );
+ int count = countGroups( chain );
+ assertEquals( "Wrong number of groups", 3, count );
groups.clear();
groups.add( First.class );
groups.add( First.class );
chain = generator.getGroupChainFor( groups );
- assertEquals( "Wrong number of groups", 1, chain.size() );
+ count = countGroups( chain );
+ assertEquals( "Wrong number of groups", 1, count );
groups.clear();
groups.add( First.class );
groups.add( Last.class );
groups.add( First.class );
chain = generator.getGroupChainFor( groups );
- assertEquals( "Wrong number of groups", 2, chain.size() );
+ count = countGroups( chain );
+ assertEquals( "Wrong number of groups", 2, count );
}
+ private int countGroups(GroupChain chain) {
+ Iterator<Group> groupIterator = chain.getGroupIterator();
+ int count = 0;
+ while (groupIterator.hasNext()) {
+ groupIterator.next();
+ count++;
+ }
+ return count;
+ }
+
@Test
public void testSequenceResolution() {
Set<Class<?>> groups = new HashSet<Class<?>>();
groups.add( Address.Complete.class );
GroupChain chain = generator.getGroupChainFor( groups );
- assertEquals( "Wrong number of groups", 2, chain.size() );
+ Iterator<List<Group>> sequences = chain.getSequenceIterator();
+ List<Group> sequence = sequences.next();
- assertTrue( "Should have more groups", chain.hasNext() );
- assertEquals( "Wrong groups", Default.class, chain.next().getGroup() );
-
- assertTrue( "Should have more groups", chain.hasNext() );
- assertEquals( "Wrong groups", Address.HighLevelCoherence.class, chain.next().getGroup() );
-
- assertFalse( "There should be no more groups", chain.hasNext() );
+ assertEquals( "Wrong group", Default.class, sequence.get(0).getGroup() );
+ assertEquals( "Wrong group", Address.HighLevelCoherence.class, sequence.get(1).getGroup() );
}
}
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/Junit4TestFactory.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/Junit4TestFactory.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/Junit4TestFactory.java 2009-02-26 14:18:07 UTC (rev 16045)
@@ -0,0 +1,52 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.util.performance;
+
+import java.util.List;
+
+import com.clarkware.junitperf.TestFactory;
+import junit.framework.JUnit4TestAdapter;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+class JUnit4TestFactory extends TestFactory {
+
+ static class DummyTestCase extends TestCase {
+ public void test() {
+ }
+ }
+
+ private List<Class<?>> junit4TestClass;
+
+ public JUnit4TestFactory(List<Class<?>> testClasses) {
+ super( DummyTestCase.class );
+ this.junit4TestClass = testClasses;
+ }
+
+ @Override
+ protected TestSuite makeTestSuite() {
+ TestSuite testSuite = new TestSuite( "JUnit4TestFactory" );
+ JUnit4TestAdapter unit4TestAdapter;
+ for ( Class<?> testClass : junit4TestClass ) {
+ unit4TestAdapter = new JUnit4TestAdapter( testClass );
+ testSuite.addTest( unit4TestAdapter );
+ }
+ return testSuite;
+ }
+}
+
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/Junit4TestFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id
Added: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/ValidationPerformace.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/ValidationPerformace.java (rev 0)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/ValidationPerformace.java 2009-02-26 14:18:07 UTC (rev 16045)
@@ -0,0 +1,50 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.validation.util.performance;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.clarkware.junitperf.TimedTest;
+import junit.framework.Test;
+
+import org.hibernate.validation.engine.ValidatorImplTest;
+
+/**
+ * Work in progress. Timings have no relevance. Using this class one can verify if applied changes affect the
+ * performance of the framework.
+ *
+ * @author Hardy Ferentschik
+ */
+public class ValidationPerformace {
+
+ public static Test suite() {
+
+ long maxTimeInMillis = 1000;
+ List<Class<?>> testClasses = new ArrayList<Class<?>>();
+ testClasses.add( ValidatorImplTest.class );
+ //testClasses.add( GroupTest.class );
+ //testClasses.add( ConstraintCompositionTest.class );
+ Test test = new JUnit4TestFactory( testClasses ).makeTestSuite();
+ return new TimedTest( test, maxTimeInMillis );
+ }
+
+ public static void main(String args[]) {
+ junit.textui.TestRunner.run( suite() );
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/performance/ValidationPerformace.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/test/resources/log4j.properties
===================================================================
--- validator/trunk/hibernate-validator/src/test/resources/log4j.properties 2009-02-26 13:52:37 UTC (rev 16044)
+++ validator/trunk/hibernate-validator/src/test/resources/log4j.properties 2009-02-26 14:18:07 UTC (rev 16045)
@@ -20,7 +20,7 @@
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=debug, stdout
-log4j.logger.org.hibernate.validation.engine.ValidatorImpl=debug
+log4j.logger.org.hibernate.validation.engine.ValidatorImpl=trace
log4j.logger.org.hibernate.validation.engine.ConstraintTree=trace
org.hibernate.validation.engine.ResourceBundleMessageInterpolator=info
15 years, 10 months
Hibernate SVN: r16044 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine and 7 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-02-26 08:52:37 -0500 (Thu, 26 Feb 2009)
New Revision: 16044
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ValidatorTypeHelper.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationDescriptor.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationFactory.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ValidatorTypeTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java
Log:
BVAL-130 Make ConstraintDescriptor generic: ConstraintDescriptor<T extends Annotation>
Fix a bunch of untypesafe calls to the codebase
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -28,7 +28,7 @@
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
-public interface ConstraintDescriptor {
+public interface ConstraintDescriptor<T extends Annotation> {
/**
* Returns the annotation describing the constraint declaration.
* If a composing constraint, parameter values are reflecting
@@ -36,7 +36,7 @@
*
* @return The annotation for this constraint.
*/
- Annotation getAnnotation();
+ T getAnnotation();
/**
* The Set of groups the constraint is applied on.
@@ -52,8 +52,8 @@
*
* @return list of the constraint validation implementation classes.
*/
- List<Class<? extends ConstraintValidator<?, ?>>>
- getConstraintValidatorClasses();
+ List<Class<? extends ConstraintValidator<T, ?>>>
+ getConstraintValidatorClasses();
/**
* Returns a map containing the annotation parameter names as keys and the
@@ -75,7 +75,7 @@
* @return a set of <code>ConstraintDescriptor<code> objects or an empty set
* in case there are no composing constraints.
*/
- Set<ConstraintDescriptor> getComposingConstraints();
+ Set<ConstraintDescriptor<?>> getComposingConstraints();
/**
* @return true if the constraint is annotated with @ReportAsSingleViolation
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -71,5 +71,5 @@
*
* @return constraint metadata
*/
- ConstraintDescriptor getConstraintDescriptor();
+ ConstraintDescriptor<?> getConstraintDescriptor();
}
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ElementDescriptor.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -45,5 +45,5 @@
*
* @return Set of constraint descriptors for this element
*/
- Set<ConstraintDescriptor> getConstraintDescriptors();
+ Set<ConstraintDescriptor<?>> getConstraintDescriptors();
}
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -39,7 +39,7 @@
* @return Interpolated error message.
*/
String interpolate(String message,
- ConstraintDescriptor constraintDescriptor,
+ ConstraintDescriptor<?> constraintDescriptor,
Object value);
/**
@@ -54,7 +54,7 @@
* @return Interpolated error message.
*/
String interpolate(String message,
- ConstraintDescriptor constraintDescriptor,
+ ConstraintDescriptor<?> constraintDescriptor,
Object value,
Locale locale);
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintDescriptorImpl.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -49,7 +49,7 @@
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
-public class ConstraintDescriptorImpl<U extends Annotation> implements ConstraintDescriptor {
+public class ConstraintDescriptorImpl<T extends Annotation> implements ConstraintDescriptor<T> {
private static final Logger log = LoggerFactory.make();
private static final Class<?>[] DEFAULT_GROUP = new Class<?>[] { Default.class };
private static final int OVERRIDES_PARAMETER_DEFAULT_INDEX = -1;
@@ -57,13 +57,13 @@
/**
* The actual constraint annotation.
*/
- private final U annotation;
+ private final T annotation;
/**
* The set of classes implementing the validation for this constraint. See also
* <code>ConstraintValidator</code> resolution algorithm.
*/
- private final List<Class<? extends ConstraintValidator<?, ?>>> constraintClasses = new ArrayList<Class<? extends ConstraintValidator<?, ?>>>();
+ private final List<Class<? extends ConstraintValidator<T, ?>>> constraintClasses = new ArrayList<Class<? extends ConstraintValidator<T, ?>>>();
/**
* The groups for which to apply this constraint.
@@ -79,7 +79,7 @@
/**
* The composing constraints for this constraints.
*/
- private final Set<ConstraintDescriptor> composingConstraints = new HashSet<ConstraintDescriptor>();
+ private final Set<ConstraintDescriptor<?>> composingConstraints = new HashSet<ConstraintDescriptor<?>>();
/**
* Override paramter values used for composing constraints.
@@ -96,7 +96,7 @@
*/
private final ConstraintHelper constraintHelper;
- public ConstraintDescriptorImpl(U annotation, Class<?>[] groups, ConstraintHelper constraintHelper) {
+ public ConstraintDescriptorImpl(T annotation, Class<?>[] groups, ConstraintHelper constraintHelper) {
this( annotation, new HashSet<Class<?>>(), constraintHelper );
if ( groups.length == 0 ) {
groups = DEFAULT_GROUP;
@@ -104,7 +104,7 @@
this.groups.addAll( Arrays.asList( groups ) );
}
- public ConstraintDescriptorImpl(U annotation, Set<Class<?>> groups, ConstraintHelper constraintHelper) {
+ private ConstraintDescriptorImpl(T annotation, Set<Class<?>> groups, ConstraintHelper constraintHelper) {
this.annotation = annotation;
this.groups = groups;
this.parameters = getAnnotationParameters( annotation );
@@ -125,15 +125,25 @@
constraintClasses.addAll( constraintHelper.getBuiltInConstraints( annotation ) );
}
else {
- Constraint constraint = annotation.annotationType().getAnnotation( Constraint.class );
- constraintClasses.addAll( Arrays.asList( constraint.validatedBy() ) );
+ //TODO are we sure a @Constraint is there?
+ final Class<? extends Annotation> annotationType = annotation.annotationType();
+ Class<? extends ConstraintValidator<?,?>>[] validatedBy = annotationType
+ .getAnnotation( Constraint.class )
+ .validatedBy();
+ for (Class<? extends ConstraintValidator<?,?>> validator : validatedBy) {
+ //FIXME does this create a CCE at runtime?
+ //FIXME if yes wrap into VE, if no we need to test the type here
+ //Once resolved,we can @SuppressWarning("unchecked") on the cast
+ Class<? extends ConstraintValidator<T,?>> safeValidator = (Class<? extends ConstraintValidator<T,?>>) validator;
+ constraintClasses.add( safeValidator );
+ }
}
}
/**
* {@inheritDoc}
*/
- public U getAnnotation() {
+ public T getAnnotation() {
return annotation;
}
@@ -147,7 +157,7 @@
/**
* {@inheritDoc}
*/
- public List<Class<? extends ConstraintValidator<?, ?>>> getConstraintValidatorClasses() {
+ public List<Class<? extends ConstraintValidator<T, ?>>> getConstraintValidatorClasses() {
return Collections.unmodifiableList( constraintClasses );
}
@@ -161,7 +171,7 @@
/**
* {@inheritDoc}
*/
- public Set<ConstraintDescriptor> getComposingConstraints() {
+ public Set<ConstraintDescriptor<?>> getComposingConstraints() {
return composingConstraints;
}
@@ -249,10 +259,7 @@
for ( Annotation declaredAnnotation : annotation.annotationType().getDeclaredAnnotations() ) {
if ( constraintHelper.isConstraintAnnotation( declaredAnnotation )
|| constraintHelper.isBuiltinConstraint( declaredAnnotation ) ) {
- ConstraintDescriptorImpl descriptor = createComposingConstraintDescriptor(
- OVERRIDES_PARAMETER_DEFAULT_INDEX,
- declaredAnnotation
- );
+ ConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor( declaredAnnotation, OVERRIDES_PARAMETER_DEFAULT_INDEX );
composingConstraints.add( descriptor );
log.debug( "Adding composing constraint: " + descriptor );
}
@@ -260,8 +267,8 @@
List<Annotation> multiValueConstraints = constraintHelper.getMultiValueConstraints( declaredAnnotation );
int index = 1;
for ( Annotation constraintAnnotation : multiValueConstraints ) {
- ConstraintDescriptorImpl descriptor = createComposingConstraintDescriptor(
- index, constraintAnnotation
+ ConstraintDescriptorImpl<?> descriptor = createComposingConstraintDescriptor(
+ constraintAnnotation, index
);
composingConstraints.add( descriptor );
log.debug( "Adding composing constraint: " + descriptor );
@@ -271,13 +278,25 @@
}
}
- private ConstraintDescriptorImpl createComposingConstraintDescriptor(int index, Annotation constraintAnnotation) {
- AnnotationDescriptor annotationDescriptor = new AnnotationDescriptor(
- constraintAnnotation.annotationType(), getAnnotationParameters( constraintAnnotation )
+ private <U extends Annotation> ConstraintDescriptorImpl<U> createComposingConstraintDescriptor(U declaredAnnotation, int index) {
+ //TODO don't quite understand this warning
+ //TODO assuming U.getClass() returns Class<U>
+ @SuppressWarnings("unchecked")
+ final Class<U> annotationType = (Class<U>) declaredAnnotation.annotationType();
+ return createComposingConstraintDescriptor(
+ index,
+ declaredAnnotation,
+ annotationType
+ );
+ }
+
+ private <U extends Annotation> ConstraintDescriptorImpl<U> createComposingConstraintDescriptor(int index, U constraintAnnotation, Class<U> annotationType) {
+ AnnotationDescriptor<U> annotationDescriptor = new AnnotationDescriptor<U>(
+ annotationType, getAnnotationParameters( constraintAnnotation )
);
Map<String, Object> overrides = overrideParameters.get(
new ClassIndexWrapper(
- constraintAnnotation.annotationType(), index
+ annotationType, index
)
);
if ( overrides != null ) {
@@ -285,8 +304,8 @@
annotationDescriptor.setValue( entry.getKey(), entry.getValue() );
}
}
- Annotation annotationProxy = AnnotationFactory.create( annotationDescriptor );
- return new ConstraintDescriptorImpl( annotationProxy, groups, constraintHelper );
+ U annotationProxy = AnnotationFactory.create( annotationDescriptor );
+ return new ConstraintDescriptorImpl<U>( annotationProxy, groups, constraintHelper );
}
private class ClassIndexWrapper {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintHelper.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -78,7 +78,8 @@
public ConstraintHelper() {
- List<Class<? extends ConstraintValidator<?, ?>>> constraintList = new ArrayList<Class<? extends ConstraintValidator<?, ?>>>();
+ List<Class<? extends ConstraintValidator<?, ?>>> constraintList =
+ new ArrayList<Class<? extends ConstraintValidator<?, ?>>>();
constraintList.add( AssertFalseValidator.class );
builtinConstraints.put( AssertFalse.class, constraintList );
@@ -131,16 +132,28 @@
builtinConstraints.put( Pattern.class, constraintList );
}
- public List<Class<? extends ConstraintValidator<?, ?>>> getBuiltInConstraints(Annotation annotation) {
- List<Class<? extends ConstraintValidator<?, ?>>> constraints = builtinConstraints.get( annotation.annotationType() );
+ public <T extends Annotation> List<Class<? extends ConstraintValidator<T, ?>>> getBuiltInConstraints(T annotation) {
+ final List<Class<? extends ConstraintValidator<?, ?>>> builtInList = getBuiltInFromAnnotationType( annotation.annotationType() );
- if ( constraints == null ) {
+ if (builtInList == null || builtInList.size() == 0) {
throw new ValidationException( "Unable to find constraints for " + annotation.annotationType() );
}
+ List<Class<? extends ConstraintValidator<T, ?>>> constraints =
+ new ArrayList<Class<? extends ConstraintValidator<T, ?>>>( builtInList.size() );
+ for (Class<? extends ConstraintValidator<?, ?>> validatorClass : builtInList) {
+ //safe cause all CV for a given annotation A are CV<A, ?>
+ @SuppressWarnings( "unchecked" )
+ Class<ConstraintValidator<T, ?>> safeValdiatorClass = (Class<ConstraintValidator<T, ?>>) validatorClass;
+ constraints.add( safeValdiatorClass );
+ }
return constraints;
}
+ private List<Class<? extends ConstraintValidator<?, ?>>> getBuiltInFromAnnotationType(Class<?> annotationType) {
+ return builtinConstraints.get( annotationType );
+ }
+
public boolean isBuiltinConstraint(Annotation annotation) {
return builtinConstraints.containsKey( annotation.annotationType() );
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -22,6 +22,8 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+
import org.hibernate.validation.AmbiguousConstraintUsageException;
import javax.validation.ConstraintDescriptor;
import javax.validation.ConstraintValidator;
@@ -40,29 +42,34 @@
*
* @author Hardy Ferentschik
*/
-public class ConstraintTree {
+public class ConstraintTree<T extends Annotation> {
private static final Logger log = LoggerFactory.make();
- private final ConstraintTree parent;
- private final List<ConstraintTree> children;
- private final ConstraintDescriptor descriptor;
+ private final ConstraintTree<?> parent;
+ private final List<ConstraintTree<?>> children;
+ private final ConstraintDescriptor<T> descriptor;
- public ConstraintTree(ConstraintDescriptor descriptor) {
+ public ConstraintTree(ConstraintDescriptor<T> descriptor) {
this( descriptor, null );
}
- private ConstraintTree(ConstraintDescriptor descriptor, ConstraintTree parent) {
+ private ConstraintTree(ConstraintDescriptor<T> descriptor, ConstraintTree<?> parent) {
this.parent = parent;
this.descriptor = descriptor;
- children = new ArrayList<ConstraintTree>( descriptor.getComposingConstraints().size() );
+ final Set<ConstraintDescriptor<?>> composingConstraints = descriptor.getComposingConstraints();
+ children = new ArrayList<ConstraintTree<?>>( composingConstraints.size() );
- for ( ConstraintDescriptor composingDescriptor : descriptor.getComposingConstraints() ) {
- ConstraintTree treeNode = new ConstraintTree( composingDescriptor, this );
+ for ( ConstraintDescriptor<?> composingDescriptor : composingConstraints ) {
+ ConstraintTree<?> treeNode = createConstraintTree( composingDescriptor );
children.add( treeNode );
}
}
+ private <U extends Annotation> ConstraintTree<U> createConstraintTree(ConstraintDescriptor<U> composingDescriptor) {
+ return new ConstraintTree<U>( composingDescriptor, this );
+ }
+
public boolean isRoot() {
return parent == null;
}
@@ -71,7 +78,7 @@
return parent;
}
- public List<ConstraintTree> getChildren() {
+ public List<ConstraintTree<?>> getChildren() {
return children;
}
@@ -79,7 +86,7 @@
return children.size() > 0;
}
- public ConstraintDescriptor getDescriptor() {
+ public ConstraintDescriptor<T> getDescriptor() {
return descriptor;
}
@@ -150,15 +157,18 @@
* @return A initalized constraint validator matching the type of the value to be validated.
*/
private ConstraintValidator getInitalizedValidator(Object value, ConstraintValidatorFactory constraintFactory) {
- ConstraintValidator constraintValidator;
- Class validatorClass;
+ Class<? extends ConstraintValidator<T, ?>> validatorClass;
+ //FIXME This sounds really bad, why value can be null. Why are we deciding of the validator based on the value?
if ( value == null ) {
validatorClass = descriptor.getConstraintValidatorClasses().get( 0 );
}
else {
validatorClass = findMatchingValidatorClass( value );
}
- constraintValidator = constraintFactory.getInstance( validatorClass );
+ //
+ @SuppressWarnings("unchecked")
+ ConstraintValidator<T,?> constraintValidator =
+ constraintFactory.getInstance( validatorClass );
initializeConstraint( descriptor, constraintValidator );
return constraintValidator;
}
@@ -174,9 +184,9 @@
Class valueClass = determineValueClass( value );
- Map<Class<?>, Class<? extends ConstraintValidator<? extends Annotation, ?>>> validatorsTypes = ValidatorTypeHelper
- .getValidatorsTypes( descriptor.getConstraintValidatorClasses() );
- List<Class> assignableClasses = findAssingableClasses( valueClass, validatorsTypes );
+ Map<Class<?>, Class<? extends ConstraintValidator<?, ?>>> validatorsTypes =
+ ValidatorTypeHelper.getValidatorsTypes( descriptor.getConstraintValidatorClasses() );
+ List<Class> assignableClasses = findAssignableClasses( valueClass, validatorsTypes );
resolveAssignableClasses( assignableClasses );
verifyResolveWasUnique( valueClass, assignableClasses );
@@ -202,7 +212,7 @@
}
}
- private List<Class> findAssingableClasses(Class valueClass, Map<Class<?>, Class<? extends ConstraintValidator<? extends Annotation, ?>>> validatorsTypes) {
+ private List<Class> findAssignableClasses(Class valueClass, Map<Class<?>, Class<? extends ConstraintValidator<?, ?>>> validatorsTypes) {
List<Class> assignableClasses = new ArrayList<Class>();
for ( Class clazz : validatorsTypes.keySet() ) {
if ( clazz.isAssignableFrom( valueClass ) ) {
@@ -247,9 +257,8 @@
} while ( classesToRemove.size() > 0 );
}
- @SuppressWarnings("unchecked")
private void initializeConstraint
- (ConstraintDescriptor
+ (ConstraintDescriptor<T>
descriptor, ConstraintValidator
constraintValidator) {
try {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ElementDescriptorImpl.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -35,7 +35,7 @@
public class ElementDescriptorImpl implements PropertyDescriptor {
private final Class<?> returnType;
private final boolean cascaded;
- private final Set<ConstraintDescriptor> constraintDescriptors = new HashSet<ConstraintDescriptor>();
+ private final Set<ConstraintDescriptor<?>> constraintDescriptors = new HashSet<ConstraintDescriptor<?>>();
private final String propertyPath;
@@ -72,7 +72,7 @@
/**
* {@inheritDoc}
*/
- public Set<ConstraintDescriptor> getConstraintDescriptors() {
+ public Set<ConstraintDescriptor<?>> getConstraintDescriptors() {
return Collections.unmodifiableSet( constraintDescriptors );
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ValidatorTypeHelper.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ValidatorTypeHelper.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/ValidatorTypeHelper.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -45,15 +45,15 @@
* @return Return a Map<Class, Class<? extends ConstraintValidator>> where the map
* key is the type the validator accepts and value the validator class itself.
*/
- public static Map<Class<?>, Class<? extends ConstraintValidator<? extends Annotation, ?>>>
- getValidatorsTypes(List<Class<? extends ConstraintValidator<?, ?>>> validators) {
+ public static <T extends Annotation> Map<Class<?>, Class<? extends ConstraintValidator<?, ?>>> getValidatorsTypes(
+ List<Class<? extends ConstraintValidator<T, ?>>> validators) {
if ( validators == null || validators.size() == 0 ) {
throw new ValidationException( "No ConstraintValidators associated to @Constraint" );
}
else {
- Map<Class<?>, Class<? extends ConstraintValidator<? extends Annotation, ?>>> validatorsTypes =
- new HashMap<Class<?>, Class<? extends ConstraintValidator<? extends Annotation, ?>>>();
- for ( Class<? extends ConstraintValidator<? extends Annotation, ?>> validator : validators ) {
+ Map<Class<?>, Class<? extends ConstraintValidator<?, ?>>> validatorsTypes =
+ new HashMap<Class<?>, Class<? extends ConstraintValidator<?, ?>>>();
+ for ( Class<? extends ConstraintValidator<?, ?>> validator : validators ) {
validatorsTypes.put( extractType( validator ), validator );
}
return validatorsTypes;
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationDescriptor.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationDescriptor.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationDescriptor.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -33,17 +33,17 @@
* @author Davide Marchignoli
* @author Hardy Ferentschik
*/
-public class AnnotationDescriptor {
+public class AnnotationDescriptor<T extends Annotation> {
- private final Class<? extends Annotation> type;
+ private final Class<T> type;
private final Map<String, Object> elements = new HashMap<String, Object>();
- public AnnotationDescriptor(Class<? extends Annotation> annotationType) {
+ public AnnotationDescriptor(Class<T> annotationType) {
this.type = annotationType;
}
- public AnnotationDescriptor(Class<? extends Annotation> annotationType, Map<String, Object> elements) {
+ public AnnotationDescriptor(Class<T> annotationType, Map<String, Object> elements) {
this.type = annotationType;
for (Map.Entry<String, Object> entry : elements.entrySet()) {
this.elements.put( entry.getKey(), entry.getValue() );
@@ -66,7 +66,7 @@
return elements.size();
}
- public Class<? extends Annotation> type() {
+ public Class<T> type() {
return type;
}
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationFactory.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationFactory.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/util/annotationfactory/AnnotationFactory.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -34,7 +34,7 @@
public class AnnotationFactory {
@SuppressWarnings("unchecked")
- public static <T extends Annotation> T create(AnnotationDescriptor descriptor) {
+ public static <T extends Annotation> T create(AnnotationDescriptor<T> descriptor) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
//TODO round 34ms to generate the proxy, hug! is Javassist Faster?
Class<T> proxyClass = (Class<T>) Proxy.getProxyClass( classLoader, descriptor.type() );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/bootstrap/ValidationTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -114,11 +114,11 @@
configuration = Validation.byDefaultProvider().configure();
configuration.messageInterpolator(
new MessageInterpolator() {
- public String interpolate(String message, ConstraintDescriptor constraintDescriptor, Object value) {
+ public String interpolate(String message, ConstraintDescriptor<?> constraintDescriptor, Object value) {
return "my custom message";
}
- public String interpolate(String message, ConstraintDescriptor constraintDescriptor, Object value, Locale locale) {
+ public String interpolate(String message, ConstraintDescriptor<?> constraintDescriptor, Object value, Locale locale) {
throw new UnsupportedOperationException( "No specific locale is possible" );
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForNumberTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -36,7 +36,7 @@
@Test
public void testIsValid() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Digits.class );
+ AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor( Digits.class );
descriptor.setValue( "integer", 5 );
descriptor.setValue( "fraction", 2 );
descriptor.setValue( "message", "{validator.digits}" );
@@ -64,7 +64,7 @@
@Test
public void testIsValidZeroLength() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Digits.class );
+ AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor( Digits.class );
descriptor.setValue( "integer", 0 );
descriptor.setValue( "fraction", 0 );
descriptor.setValue( "message", "{validator.digits}" );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/DigitsValidatorForStringTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -37,7 +37,7 @@
@BeforeClass
public static void init() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Digits.class );
+ AnnotationDescriptor<Digits> descriptor = new AnnotationDescriptor( Digits.class );
descriptor.setValue( "integer", 5 );
descriptor.setValue( "fraction", 2 );
descriptor.setValue( "message", "{validator.digits}" );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/LengthValidatorTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -36,7 +36,7 @@
@BeforeClass
public static void init() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Length.class );
+ AnnotationDescriptor<Length> descriptor = new AnnotationDescriptor<Length>( Length.class );
descriptor.setValue( "min", 1 );
descriptor.setValue( "max", 3 );
descriptor.setValue( "message", "{validator.length}" );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForNumberTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -39,7 +39,7 @@
@BeforeClass
public static void init() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Max.class );
+ AnnotationDescriptor<Max> descriptor = new AnnotationDescriptor( Max.class );
descriptor.setValue( "value", 15l );
descriptor.setValue( "message", "{validator.max}" );
Max m = AnnotationFactory.create( descriptor );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MaxValidatorForStringTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -37,7 +37,7 @@
@BeforeClass
public static void init() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Max.class );
+ AnnotationDescriptor<Max> descriptor = new AnnotationDescriptor( Max.class );
descriptor.setValue( "value", 15l );
descriptor.setValue( "message", "{validator.max}" );
Max m = AnnotationFactory.create( descriptor );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForNumberTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -39,7 +39,7 @@
@BeforeClass
public static void init() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Min.class );
+ AnnotationDescriptor<Min> descriptor = new AnnotationDescriptor<Min>( Min.class );
descriptor.setValue( "value", 15l );
descriptor.setValue( "message", "{validator.min}" );
Min m = AnnotationFactory.create( descriptor );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/MinValidatorForStringTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -36,7 +36,7 @@
@BeforeClass
public static void init() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Min.class );
+ AnnotationDescriptor<Min> descriptor = new AnnotationDescriptor( Min.class );
descriptor.setValue( "value", 15l );
descriptor.setValue( "message", "{validator.min}" );
Min m = AnnotationFactory.create( descriptor );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/constraints/PatternValidatorTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -37,7 +37,7 @@
@BeforeClass
public static void init() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Pattern.class );
+ AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor( Pattern.class );
descriptor.setValue( "regexp", "foobar" );
descriptor.setValue( "message", "{validator.pattern}" );
Pattern p = AnnotationFactory.create( descriptor );
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ResourceBundleMessageInterpolatorTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -49,11 +49,11 @@
public void setUp() {
interpolator = new ResourceBundleMessageInterpolator( new TestResources() );
- AnnotationDescriptor descriptor = new AnnotationDescriptor( NotNull.class );
+ AnnotationDescriptor<NotNull> descriptor = new AnnotationDescriptor<NotNull>( NotNull.class );
notNull = AnnotationFactory.create( descriptor );
- descriptor = new AnnotationDescriptor( Size.class );
- size = AnnotationFactory.create( descriptor );
+ AnnotationDescriptor<Size> sizeDescriptor = new AnnotationDescriptor<Size>( Size.class );
+ size = AnnotationFactory.create( sizeDescriptor );
}
@Test
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/ValidatorImplTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -439,7 +439,7 @@
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderNumber" );
- Set<ConstraintDescriptor> descriptors = propertyDescriptor.getConstraintDescriptors();
+ Set<ConstraintDescriptor<?>> descriptors = propertyDescriptor.getConstraintDescriptors();
assertEquals( "There should be only one constraint descriptor", 1, descriptors.size() );
ConstraintDescriptor descriptor = descriptors.iterator().next();
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ValidatorTypeTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ValidatorTypeTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/ValidatorTypeTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -27,6 +27,7 @@
import org.junit.Test;
import org.hibernate.validation.constraints.composition.FrenchZipcodeConstraintValidator;
+import org.hibernate.validation.constraints.composition.FrenchZipcode;
/**
* Tests for message resolution.
@@ -37,9 +38,10 @@
@Test
public void testTypeDiscovery() {
- List<Class<? extends ConstraintValidator<?, ?>>> validators = new ArrayList<Class<? extends ConstraintValidator<?, ?>>>();
+ List<Class<? extends ConstraintValidator<FrenchZipcode, ?>>> validators =
+ new ArrayList<Class<? extends ConstraintValidator<FrenchZipcode, ?>>>();
validators.add( FrenchZipcodeConstraintValidator.class );
- Map<Class<?>, Class<? extends ConstraintValidator<? extends Annotation, ?>>> validatorsTypes = ValidatorTypeHelper
+ Map<Class<?>, Class<? extends ConstraintValidator<?, ?>>> validatorsTypes = ValidatorTypeHelper
.getValidatorsTypes( validators );
assertEquals( FrenchZipcodeConstraintValidator.class, validatorsTypes.get( String.class ) );
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java 2009-02-26 11:48:50 UTC (rev 16043)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/annotationfactory/AnnotationFactoryTest.java 2009-02-26 13:52:37 UTC (rev 16044)
@@ -31,7 +31,7 @@
@Test
public void createAnnotationProxy() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Size.class );
+ AnnotationDescriptor<Size> descriptor = new AnnotationDescriptor<Size>( Size.class );
descriptor.setValue( "min", 5 );
descriptor.setValue( "max", 10 );
@@ -43,13 +43,13 @@
@Test(expected = IllegalArgumentException.class)
public void createAnnotationProxyMissingRequiredParamter() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Pattern.class );
+ AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
AnnotationFactory.create( descriptor );
}
@Test
public void createAnnotationProxyWithRequiredParamter() {
- AnnotationDescriptor descriptor = new AnnotationDescriptor( Pattern.class );
+ AnnotationDescriptor<Pattern> descriptor = new AnnotationDescriptor<Pattern>( Pattern.class );
descriptor.setValue( "regexp", ".*" );
Pattern pattern = AnnotationFactory.create( descriptor );
15 years, 10 months
Hibernate SVN: r16043 - in branches/Branch_3_2/HibernateExt/tools/src: test/org/hibernate/tool/hbm2x/hbm2hbmxml and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2009-02-26 06:48:50 -0500 (Thu, 26 Feb 2009)
New Revision: 16043
Modified:
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java
Log:
JBIDE-3712 various fixes to make hbm.xml more complete
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2009-02-26 10:52:09 UTC (rev 16042)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/hbm2x/Cfg2HbmTool.java 2009-02-26 11:48:50 UTC (rev 16043)
@@ -371,7 +371,7 @@
public String getProxyInterfaceName(PersistentClass pc) {
if (pc.hasPojoRepresentation() ) {
- return pc.getClassName();
+ return pc.getProxyInterfaceName();
}
else {
throw new ExporterException(pc + " does not have a pojo rep.");
Modified: branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java 2009-02-26 10:52:09 UTC (rev 16042)
+++ branches/Branch_3_2/HibernateExt/tools/src/test/org/hibernate/tool/hbm2x/hbm2hbmxml/Cfg2HbmAllTests.java 2009-02-26 11:48:50 UTC (rev 16043)
@@ -1,21 +1,23 @@
package org.hibernate.tool.hbm2x.hbm2hbmxml;
-
import junit.framework.Test;
import junit.framework.TestSuite;
public class Cfg2HbmAllTests {
public static Test suite() {
- TestSuite suite = new TestSuite( "Test for org.hibernate.tool.cfg2hbm" );
+ TestSuite suite = new TestSuite("Test for org.hibernate.tool.cfg2hbm");
//$JUnit-BEGIN$
- suite.addTest( ManyToManyTest.suite() );
- suite.addTest( Hbm2HbmXmlTest.suite() );
- suite.addTest( InheritanceTest.suite() );
- suite.addTest( SetElementTest.suite() );
- suite.addTest( IdBagTest.suite() );
- suite.addTest( ListArrayTest.suite() );
- suite.addTest( MapAndAnyTest.suite() );
+ suite.addTest(ListArrayTest.suite());
+ suite.addTest(CompositeElementTest.suite());
+ suite.addTest(MapAndAnyTest.suite());
+ suite.addTest(DynamicComponentTest.suite());
+ suite.addTest(IdBagTest.suite());
+ suite.addTest(Hbm2HbmXmlTest.suite());
+ suite.addTest(ManyToManyTest.suite());
+ suite.addTest(OneToOneTest.suite());
+ suite.addTest(InheritanceTest.suite());
+ suite.addTest(SetElementTest.suite());
//$JUnit-END$
return suite;
}
15 years, 10 months
Hibernate SVN: r16042 - branches/Branch_3_2/HibernateExt/tools/src/templates/hbm.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2009-02-26 05:52:09 -0500 (Thu, 26 Feb 2009)
New Revision: 16042
Modified:
branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl
Log:
backref fix for JBIDE-3712
Modified: branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl 2009-02-26 10:36:59 UTC (rev 16041)
+++ branches/Branch_3_2/HibernateExt/tools/src/templates/hbm/persistentclass.hbm.ftl 2009-02-26 10:52:09 UTC (rev 16042)
@@ -108,7 +108,7 @@
<#include "${c2h.getTag(property)}.hbm.ftl"/>
</#if>
-<#foreach property in clazz.getUnjoinedPropertyIterator()>
+<#foreach property in c2h.getProperties(clazz)>
<#if c2h.getTag(property)!="version" && c2h.getTag(property)!="timestamp">
<#include "${c2h.getTag(property)}.hbm.ftl"/>
</#if>
15 years, 10 months