Hibernate SVN: r16873 - in core/branches/Branch_3_2: src/org/hibernate and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-22 18:00:05 -0400 (Mon, 22 Jun 2009)
New Revision: 16873
Modified:
core/branches/Branch_3_2/build.xml
core/branches/Branch_3_2/src/org/hibernate/Version.java
Log:
HHH-3781 - Echo version information to the console in main()
Modified: core/branches/Branch_3_2/build.xml
===================================================================
--- core/branches/Branch_3_2/build.xml 2009-06-22 21:58:45 UTC (rev 16872)
+++ core/branches/Branch_3_2/build.xml 2009-06-22 22:00:05 UTC (rev 16873)
@@ -575,7 +575,9 @@
<attribute name="Implementation-Title" value="Hibernate3"/>
<attribute name="Implementation-Version" value="${version.full}"/>
<attribute name="Implementation-Vendor" value="hibernate.org"/>
+ <attribute name="Implementation-URL" value="http://hibernate.org" />
<attribute name="Hibernate-Version" value="${version.full}"/>
+ <attribute name="Main-Class" value="org.hibernate.Version" />
</manifest>
</jar>
Modified: core/branches/Branch_3_2/src/org/hibernate/Version.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/Version.java 2009-06-22 21:58:45 UTC (rev 16872)
+++ core/branches/Branch_3_2/src/org/hibernate/Version.java 2009-06-22 22:00:05 UTC (rev 16873)
@@ -32,4 +32,8 @@
public static String getVersionString() {
return "3.2.8-SNAPSHOT";
}
+
+ public static void main(String[] args) {
+ System.out.println( "Hibernate version " + getVersionString() );
+ }
}
15 years, 5 months
Hibernate SVN: r16872 - in core/branches/Branch_3_3: core/src/main/java/org/hibernate and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-22 17:58:45 -0400 (Mon, 22 Jun 2009)
New Revision: 16872
Modified:
core/branches/Branch_3_3/core/pom.xml
core/branches/Branch_3_3/core/src/main/java/org/hibernate/Version.java
core/branches/Branch_3_3/parent/pom.xml
Log:
HHH-3781 - Echo version information to the console in main()
Modified: core/branches/Branch_3_3/core/pom.xml
===================================================================
--- core/branches/Branch_3_3/core/pom.xml 2009-06-22 21:58:23 UTC (rev 16871)
+++ core/branches/Branch_3_3/core/pom.xml 2009-06-22 21:58:45 UTC (rev 16872)
@@ -88,6 +88,16 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.hibernate.Version</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
</plugins>
</build>
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/Version.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/Version.java 2009-06-22 21:58:23 UTC (rev 16871)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/Version.java 2009-06-22 21:58:45 UTC (rev 16872)
@@ -32,4 +32,8 @@
public static String getVersionString() {
return "3.3.2-SNAPSHOT";
}
+
+ public static void main(String[] args) {
+ System.out.println( "Hibernate version " + getVersionString() );
+ }
}
Modified: core/branches/Branch_3_3/parent/pom.xml
===================================================================
--- core/branches/Branch_3_3/parent/pom.xml 2009-06-22 21:58:23 UTC (rev 16871)
+++ core/branches/Branch_3_3/parent/pom.xml 2009-06-22 21:58:45 UTC (rev 16872)
@@ -156,7 +156,7 @@
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
- <Implementation-URL>${pom.url}</Implementation-URL>
+ <Implementation-URL>http://hibernate.org</Implementation-URL>
</manifestEntries>
</archive>
</configuration>
15 years, 5 months
Hibernate SVN: r16871 - in core/trunk: core/src/main/java/org/hibernate and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-22 17:58:23 -0400 (Mon, 22 Jun 2009)
New Revision: 16871
Modified:
core/trunk/core/pom.xml
core/trunk/core/src/main/java/org/hibernate/Version.java
core/trunk/parent/pom.xml
Log:
HHH-3781 - Echo version information to the console in main()
Modified: core/trunk/core/pom.xml
===================================================================
--- core/trunk/core/pom.xml 2009-06-22 21:22:27 UTC (rev 16870)
+++ core/trunk/core/pom.xml 2009-06-22 21:58:23 UTC (rev 16871)
@@ -87,6 +87,16 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.hibernate.Version</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
</plugins>
</build>
Modified: core/trunk/core/src/main/java/org/hibernate/Version.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Version.java 2009-06-22 21:22:27 UTC (rev 16870)
+++ core/trunk/core/src/main/java/org/hibernate/Version.java 2009-06-22 21:58:23 UTC (rev 16871)
@@ -32,4 +32,8 @@
public static String getVersionString() {
return "3.5.0-SNAPSHOT";
}
+
+ public static void main(String[] args) {
+ System.out.println( "Hibernate version " + getVersionString() );
+ }
}
Modified: core/trunk/parent/pom.xml
===================================================================
--- core/trunk/parent/pom.xml 2009-06-22 21:22:27 UTC (rev 16870)
+++ core/trunk/parent/pom.xml 2009-06-22 21:58:23 UTC (rev 16871)
@@ -157,7 +157,7 @@
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
- <Implementation-URL>${pom.url}</Implementation-URL>
+ <Implementation-URL>http://hibernate.org</Implementation-URL>
</manifestEntries>
</archive>
</configuration>
15 years, 5 months
Hibernate SVN: r16870 - in core/branches/Branch_3_3/core/src/main/java/org/hibernate: cfg and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-22 17:22:27 -0400 (Mon, 22 Jun 2009)
New Revision: 16870
Added:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/Version.java
Modified:
core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Environment.java
Log:
HHH-3978 - Expose Hibernate version via non-compile-time constant expression
Added: core/branches/Branch_3_3/core/src/main/java/org/hibernate/Version.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/Version.java (rev 0)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/Version.java 2009-06-22 21:22:27 UTC (rev 16870)
@@ -0,0 +1,35 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate;
+
+/**
+ * Information about the Hibernate version.
+ *
+ * @author Steve Ebersole
+ */
+public class Version {
+ public static String getVersionString() {
+ return "3.3.2-SNAPSHOT";
+ }
+}
Modified: core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Environment.java 2009-06-22 21:21:42 UTC (rev 16869)
+++ core/branches/Branch_3_3/core/src/main/java/org/hibernate/cfg/Environment.java 2009-06-22 21:22:27 UTC (rev 16870)
@@ -38,6 +38,7 @@
import org.slf4j.LoggerFactory;
import org.hibernate.HibernateException;
+import org.hibernate.Version;
import org.hibernate.bytecode.BytecodeProvider;
import org.hibernate.util.ConfigHelper;
import org.hibernate.util.PropertiesHelper;
@@ -176,7 +177,14 @@
*/
public final class Environment {
- public static final String VERSION = "3.3.1.GA";
+ /**
+ * The Hibernate version.
+ *
+ * @deprecated To be removed in 3.5. Use Version#getVersionString instead. See
+ * <a href="http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#13.4.9">Java Language Specification</a>
+ * for details about compile-time constant expression for the reasons why this is being removed.
+ */
+ public static final String VERSION = Version.getVersionString();
/**
* <tt>ConnectionProvider</tt> implementor to use when obtaining connections
15 years, 5 months
Hibernate SVN: r16869 - in core/branches/Branch_3_2/src/org/hibernate: cfg and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-22 17:21:42 -0400 (Mon, 22 Jun 2009)
New Revision: 16869
Added:
core/branches/Branch_3_2/src/org/hibernate/Version.java
Modified:
core/branches/Branch_3_2/src/org/hibernate/cfg/Environment.java
Log:
HHH-3978 - Expose Hibernate version via non-compile-time constant expression
Added: core/branches/Branch_3_2/src/org/hibernate/Version.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/Version.java (rev 0)
+++ core/branches/Branch_3_2/src/org/hibernate/Version.java 2009-06-22 21:21:42 UTC (rev 16869)
@@ -0,0 +1,35 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate;
+
+/**
+ * Information about the Hibernate version.
+ *
+ * @author Steve Ebersole
+ */
+public class Version {
+ public static String getVersionString() {
+ return "3.2.8-SNAPSHOT";
+ }
+}
Modified: core/branches/Branch_3_2/src/org/hibernate/cfg/Environment.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/cfg/Environment.java 2009-06-22 21:21:25 UTC (rev 16868)
+++ core/branches/Branch_3_2/src/org/hibernate/cfg/Environment.java 2009-06-22 21:21:42 UTC (rev 16869)
@@ -15,6 +15,7 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
+import org.hibernate.Version;
import org.hibernate.bytecode.BytecodeProvider;
import org.hibernate.util.ConfigHelper;
import org.hibernate.util.PropertiesHelper;
@@ -153,7 +154,14 @@
*/
public final class Environment {
- public static final String VERSION = "3.2.8-SNAPSHOT";
+ /**
+ * The Hibernate version.
+ *
+ * @deprecated To be removed in 3.5. Use Version#getVersionString instead. See
+ * <a href="http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#13.4.9">Java Language Specification</a>
+ * for details about compile-time constant expression for the reasons why this is being removed.
+ */
+ public static final String VERSION = Version.getVersionString();
/**
* <tt>ConnectionProvider</tt> implementor to use when obtaining connections
15 years, 5 months
Hibernate SVN: r16868 - in core/trunk/core/src/main/java/org/hibernate: cfg and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-22 17:21:25 -0400 (Mon, 22 Jun 2009)
New Revision: 16868
Added:
core/trunk/core/src/main/java/org/hibernate/Version.java
Modified:
core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
Log:
HHH-3978 - Expose Hibernate version via non-compile-time constant expression
Added: core/trunk/core/src/main/java/org/hibernate/Version.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/Version.java (rev 0)
+++ core/trunk/core/src/main/java/org/hibernate/Version.java 2009-06-22 21:21:25 UTC (rev 16868)
@@ -0,0 +1,35 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate;
+
+/**
+ * Information about the Hibernate version.
+ *
+ * @author Steve Ebersole
+ */
+public class Version {
+ public static String getVersionString() {
+ return "3.5.0-SNAPSHOT";
+ }
+}
Modified: core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2009-06-22 21:07:00 UTC (rev 16867)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/Environment.java 2009-06-22 21:21:25 UTC (rev 16868)
@@ -38,6 +38,7 @@
import org.slf4j.LoggerFactory;
import org.hibernate.HibernateException;
+import org.hibernate.Version;
import org.hibernate.bytecode.BytecodeProvider;
import org.hibernate.util.ConfigHelper;
import org.hibernate.util.PropertiesHelper;
@@ -175,9 +176,6 @@
* @author Gavin King
*/
public final class Environment {
-
- public static final String VERSION = "3.3.0.GA";
-
/**
* <tt>ConnectionProvider</tt> implementor to use when obtaining connections
*/
@@ -557,7 +555,7 @@
static {
- log.info("Hibernate " + VERSION);
+ log.info( "Hibernate " + Version.getVersionString() );
RENAMED_PROPERTIES.put( "hibernate.cglib.use_reflection_optimizer", USE_REFLECTION_OPTIMIZER );
15 years, 5 months
Hibernate SVN: r16867 - beanvalidation/trunk/validation-api/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-22 17:07:00 -0400 (Mon, 22 Jun 2009)
New Revision: 16867
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java
Log:
javadoc
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-06-22 21:06:03 UTC (rev 16866)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-06-22 21:07:00 UTC (rev 16867)
@@ -58,28 +58,29 @@
* ConstraintValidatorContext
*
* Here are a few usage examples:
- * <pre>//create new error with the default path the constraint
- * //is located on
+ * <pre>
+ * {@code
+ * // create new error with the default path the constraint is located on
* context.buildErrorWithMessageTemplate( "way too long" )
* .addError();
*
- * //create new error in the "street" subnode of the default
- * //path the constraint is located on
+ * // create new error in the "street" subnode of the default path the constraint is located on
* context.buildErrorWithMessageTemplate( "way too long" )
* .inSubNode( "street" )
* .addError();
*
- * //create new error in the "addresses["home"].city.name
- * //subnode of the default path the constraint is located on
+ * //create new error in the "addresses["home"].city.name subnode of the default path the constraint is located on
* context.buildErrorWithMessageTemplate( "this detail is wrong" )
* .inSubNode( "addresses" )
* .inSubNode( "country" )
* .inIterable().atKey( "home" )
* .inSubNode( "name" )
* .addError();
+ * }
* </pre>
*
* @param messageTemplate new uninterpolated error message.
+ * @return Returns an error builder
*/
ErrorBuilder buildErrorWithMessageTemplate(String messageTemplate);
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java 2009-06-22 21:06:03 UTC (rev 16866)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java 2009-06-22 21:07:00 UTC (rev 16867)
@@ -18,7 +18,6 @@
package javax.validation;
import javax.validation.metadata.ConstraintDescriptor;
-import javax.validation.Path;
/**
* Describe a constraint violation. This object describe the error context as
@@ -39,7 +38,7 @@
String getMessageTemplate();
/**
- * @return The root bean being validated. Null when returned by
+ * @return The root bean being validated. Null when returned by
* {@link javax.validation.Validator#validateValue(Class, String, Object, Class[])}
*/
T getRootBean();
@@ -53,14 +52,14 @@
* If a bean constraint, the bean instance the constraint is applied on
* If a property constraint, the bean instance hosting the property the
* constraint is applied on
- *
- * @return the leaf bean the constraint is applied on. Null when returned by
+ *
+ * @return the leaf bean the constraint is applied on. Null when returned by
* {@link javax.validation.Validator#validateValue(Class, String, Object, Class[])}
*/
Object getLeafBean();
/**
- * @return the property path to the value from <code>rootBean</code>.
+ * @return the property path to the value from {@code rootBean}.
*/
Path getPropertyPath();
@@ -72,7 +71,7 @@
/**
* Constraint metadata reported to fail.
* The returned instance is immutable.
- *
+ *
* @return constraint metadata
*/
ConstraintDescriptor<?> getConstraintDescriptor();
15 years, 5 months
Hibernate SVN: r16866 - in beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck: tests/constraints/builtinconstraints and 7 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-22 17:06:03 -0400 (Mon, 22 Jun 2009)
New Revision: 16866
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateValueTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/SnifferTraversableResolver.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
Log:
started integrating the new path API
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -31,6 +31,7 @@
import javax.validation.Configuration;
import javax.validation.ConstraintViolation;
import javax.validation.MessageInterpolator;
+import javax.validation.Path;
import javax.validation.TraversableResolver;
import javax.validation.Validation;
import javax.validation.Validator;
@@ -73,8 +74,7 @@
Set<ConstraintViolation<Person>> constraintViolations = validator.validate( person );
assertEquals( constraintViolations.size(), 3, "Wrong number of constraints" );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "firstName", "lastName", "personalNumber" }
+ constraintViolations, "firstName", "lastName", "personalNumber"
);
person.setFirstName( "John" );
@@ -244,15 +244,12 @@
}
private static class DummyTraversableResolver implements TraversableResolver {
- public boolean isReachable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
- return false;
- }
- public boolean isCascadable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return false;
}
- public boolean isTraversable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return false;
}
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/builtinconstraints/BuiltinConstraintsTest.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -178,8 +178,7 @@
// only the min constraints on the primitive values should fail. Object values re still null and should pass per spec
assertCorrectNumberOfViolations( constraintViolations, 4 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive" }
+ constraintViolations, "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive"
);
@@ -198,8 +197,7 @@
constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 6 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger" }
+ constraintViolations, "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger"
);
dummy.intObject = Integer.valueOf( "101" );
@@ -231,8 +229,7 @@
// only the max constraints on the primitive values should fail. Object values re still null and should pass per spec
assertCorrectNumberOfViolations( constraintViolations, 4 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive" }
+ constraintViolations, "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive"
);
@@ -251,8 +248,7 @@
constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 6 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger" }
+ constraintViolations, "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger"
);
dummy.intObject = Integer.valueOf( "101" );
@@ -279,8 +275,7 @@
// only the min constraints on the primitive values should fail. Object values re still null and should pass per spec
assertCorrectNumberOfViolations( constraintViolations, 4 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive" }
+ constraintViolations, "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive"
);
@@ -299,8 +294,7 @@
constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 6 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger" }
+ constraintViolations, "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger"
);
dummy.intObject = Integer.valueOf( "101" );
@@ -332,8 +326,7 @@
// only the max constraints on the primitive values should fail. Object values re still null and should pass per spec
assertCorrectNumberOfViolations( constraintViolations, 4 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive" }
+ constraintViolations, "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive"
);
@@ -352,8 +345,7 @@
constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 6 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger" }
+ constraintViolations, "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger"
);
dummy.intObject = Integer.valueOf( "101" );
@@ -396,8 +388,7 @@
constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 5 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "collection", "map", "string", "integerArray", "intArray" }
+ constraintViolations, "collection", "map", "string", "integerArray", "intArray"
);
dummy.collection.remove( "bar" );
@@ -427,8 +418,7 @@
// only the max constraints on the primitive values should fail. Object values re still null and should pass per spec
assertCorrectNumberOfViolations( constraintViolations, 4 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive" }
+ constraintViolations, "bytePrimitive", "intPrimitive", "longPrimitive", "shortPrimitive"
);
@@ -447,8 +437,7 @@
constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 6 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger" }
+ constraintViolations, "byteObject", "intObject", "longObject", "shortObject", "bigDecimal", "bigInteger"
);
dummy.intObject = Integer.valueOf( "1" );
@@ -483,8 +472,7 @@
constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 2 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "date", "calendar" }
+ constraintViolations, "date", "calendar"
);
cal.add( Calendar.YEAR, -2 );
@@ -515,8 +503,7 @@
constraintViolations = validator.validate( dummy );
assertCorrectNumberOfViolations( constraintViolations, 2 );
assertCorrectPropertyPaths(
- constraintViolations,
- new String[] { "date", "calendar" }
+ constraintViolations, "date", "calendar"
);
cal.add( Calendar.YEAR, 2 );
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -34,7 +34,7 @@
}
if ( "00000".equals( zip ) ) {
constraintValidatorContext.disableDefaultError();
- constraintValidatorContext.addError( "00000 is a reserved code" );
+ constraintValidatorContext.buildErrorWithMessageTemplate( "00000 is a reserved code" ).addError();
return false;
}
else {
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -38,6 +38,7 @@
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
/**
* Tests for the group and group sequence feature.
@@ -181,7 +182,7 @@
assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity" );
assertEquals( constraintViolation.getInvalidValue(), book.getTitle(), "Wrong value" );
- assertEquals( "title", constraintViolation.getPropertyPath(), "Wrong propertyName" );
+ assertEquals( constraintViolation.getPropertyPath().toString(), "title", "Wrong propertyName" );
book.setTitle( "Hibernate Persistence with JPA" );
book.setSubtitle( "Revised Edition of Hibernate in Action" );
@@ -189,10 +190,10 @@
constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
constraintViolation = constraintViolations.iterator().next();
- assertEquals( "size must be between 0 and 30", constraintViolation.getMessage(), "Wrong message" );
+ assertEquals( constraintViolation.getMessage(), "size must be between 0 and 30", "Wrong message" );
assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity" );
assertEquals( constraintViolation.getInvalidValue(), book.getSubtitle(), "Wrong value" );
- assertEquals( "subtitle", constraintViolation.getPropertyPath(), "Wrong propertyName" );
+ assertCorrectPropertyPaths(constraintViolations, "subtitle");
book.setSubtitle( "Revised Edition" );
author.setCompany( "JBoss a divison of RedHat" );
@@ -200,10 +201,10 @@
constraintViolations = validator.validate( book, First.class, Second.class, Last.class );
constraintViolation = constraintViolations.iterator().next();
assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
- assertEquals( "size must be between 0 and 20", constraintViolation.getMessage() );
+ assertEquals( constraintViolation.getMessage(), "size must be between 0 and 20" );
assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity" );
assertEquals( constraintViolation.getInvalidValue(), author.getCompany(), "Wrong value" );
- assertEquals( "author.company", constraintViolation.getPropertyPath(), "Wrong propertyName" );
+ assertCorrectPropertyPaths(constraintViolations, "author.company");
author.setCompany( "JBoss" );
@@ -230,10 +231,10 @@
constraintViolations = validator.validate( book, Book.All.class );
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
- assertEquals( "may not be null", constraintViolation.getMessage(), "Wrong message" );
+ assertEquals( constraintViolation.getMessage(), "may not be null", "Wrong message" );
assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity" );
assertEquals( constraintViolation.getInvalidValue(), book.getTitle(), "Wrong value" );
- assertEquals( "title", constraintViolation.getPropertyPath(), "Wrong propertyName" );
+ assertCorrectPropertyPaths(constraintViolations, "title");
book.setTitle( "Hibernate Persistence with JPA" );
book.setSubtitle( "Revised Edition of Hibernate in Action" );
@@ -305,7 +306,7 @@
);
for ( ConstraintViolation<User> constraintViolation : constraintViolations ) {
- if ( constraintViolation.getPropertyPath().equals( "defaultCreditCard" ) ) {
+ if ( constraintViolation.getPropertyPath().toString().equals( "defaultCreditCard" ) ) {
TestUtil.assertConstraintViolation(
constraintViolation,
User.class,
@@ -313,7 +314,7 @@
"defaultCreditCard"
);
}
- else if ( constraintViolation.getPropertyPath().equals( "phoneNumber" ) ) {
+ else if ( constraintViolation.getPropertyPath().toString().equals( "phoneNumber" ) ) {
TestUtil.assertConstraintViolation(
constraintViolation,
User.class,
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateTest.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -40,6 +40,7 @@
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
/**
* Tests for the implementation of <code>Validator</code>.
@@ -134,7 +135,7 @@
violation.getConstraintDescriptor().getAnnotation().annotationType(),
Pattern.class, "Wrong annotation type"
);
- assertEquals( violation.getPropertyPath(), "serialNumber", "Wrong property path." );
+ assertCorrectPropertyPaths(constraintViolations, "serialNumber");
engine.setSerialNumber( "ABCD-EFGH-1234" );
constraintViolations = validator.validate( engine );
@@ -160,7 +161,7 @@
assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
assertEquals( constraintViolation.getRootBean(), customer, "Wrong root entity" );
assertEquals( constraintViolation.getInvalidValue(), order.getOrderNumber(), "Wrong value" );
- assertEquals( "orders[].orderNumber", constraintViolation.getPropertyPath(), "Wrong propertyName" );
+ assertCorrectPropertyPaths(constraintViolations, "orders[].orderNumber");
}
@Test
@@ -186,9 +187,7 @@
assertEquals( "Everyone has a last name.", constraintViolation.getMessage(), "Wrong message" );
org.testng.Assert.assertEquals( constraintViolation.getRootBean(), clint, "Wrong root entity" );
org.testng.Assert.assertEquals( constraintViolation.getInvalidValue(), morgan.getLastName(), "Wrong value" );
- assertEquals(
- constraintViolation.getPropertyPath(), "playedWith[0].playedWith[1].lastName", "Wrong propertyName"
- );
+ assertCorrectPropertyPaths(constraintViolations, "playedWith[0].playedWith[1].lastName");
}
@Test
@@ -213,6 +212,7 @@
assertEquals( "Everyone has a last name.", constraintViolation.getMessage(), "Wrong message" );
org.testng.Assert.assertEquals( constraintViolation.getRootBean(), clint, "Wrong root entity" );
org.testng.Assert.assertEquals( constraintViolation.getInvalidValue(), morgan.getLastName(), "Wrong value" );
+
assertEquals(
constraintViolation.getPropertyPath(), "playedWith[0].playedWith[1].lastName", "Wrong propertyName"
);
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateValueTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateValueTest.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidateValueTest.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -30,6 +30,7 @@
import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectPropertyPaths;
/**
* Tests for the implementation of <code>Validator</code>.
@@ -147,11 +148,11 @@
ConstraintViolation constraintViolation = constraintViolations.iterator().next();
assertEquals( constraintViolations.size(), 1, "Wrong number of constraints" );
- assertEquals( "may not be null", constraintViolation.getMessage(), "Wrong message" );
+ assertEquals( constraintViolation.getMessage(), "may not be null", "Wrong message" );
assertEquals( constraintViolation.getRootBean(), null, "Wrong root entity" );
assertEquals( constraintViolation.getRootBeanClass(), Customer.class, "Wrong root bean class" );
assertEquals( constraintViolation.getInvalidValue(), null, "Wrong value" );
- assertEquals( "orders[0].orderNumber", constraintViolation.getPropertyPath(), "Wrong propertyName" );
+ assertCorrectPropertyPaths( constraintViolations, "orders[0].orderNumber" );
constraintViolations = validator.validateValue( Customer.class, "orders[0].orderNumber", 1234 );
assertEquals( constraintViolations.size(), 0, "Wrong number of constraints" );
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/graphnavigation/GraphNavigationTest.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -74,11 +74,10 @@
Set<ConstraintViolation<Order>> constraintViolations = validator.validate( order );
assertEquals( constraintViolations.size(), 3, "Wrong number of constraints" );
assertCorrectPropertyPaths(
- constraintViolations, new String[] {
- "shippingAddress.addressline1",
- "customer.addresses[0].addressline1",
- "billingAddress.inhabitant.addresses[0].addressline1"
- }
+ constraintViolations,
+ "shippingAddress.addressline1",
+ "customer.addresses[0].addressline1",
+ "billingAddress.inhabitant.addresses[0].addressline1"
);
}
@@ -125,6 +124,6 @@
Validator validator = TestUtil.getDefaultValidator();
Set<ConstraintViolation<Parent>> errors = validator.validate( p, ProperOrder.class );
assertEquals( 1, errors.size() );
- assertEquals( "child.name", errors.iterator().next().getPropertyPath() );
+ assertCorrectPropertyPaths( errors, "child.name" );
}
}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/SnifferTraversableResolver.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/SnifferTraversableResolver.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/traversableresolver/SnifferTraversableResolver.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -21,6 +21,7 @@
import java.util.HashSet;
import java.util.Set;
import javax.validation.TraversableResolver;
+import javax.validation.Path;
/**
* @author Emmanuel Bernard
@@ -65,6 +66,10 @@
return true;
}
+
+
+
+
public boolean isReachable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
return isTraversable(
reachCalls,
@@ -89,6 +94,14 @@
);
}
+ public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
private static final class Call {
private Object traversableObject;
private String traversableProperty;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/ConstraintValidatorContextTest.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -106,10 +106,10 @@
boolean validatedNestedBean = false;
for ( ConstraintViolation<DummyBean> violation : constraintViolations ) {
- if ( violation.getPropertyPath().equals( "value" ) ) {
+ if ( violation.getPropertyPath().toString().equals( "value" ) ) {
assertEquals( "dummy message", violation.getMessage(), "Wrong message" );
}
- else if ( violation.getPropertyPath().equals( "nestedDummy.value" ) ) {
+ else if ( violation.getPropertyPath().toString().equals( "nestedDummy.value" ) ) {
assertEquals( "dummy message", violation.getMessage(), "Wrong message" );
validatedNestedBean = true;
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/validatorcontext/DummyValidator.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -41,7 +41,8 @@
if ( errorMessages != null ) {
for ( Map.Entry<String, String> entry : errorMessages.entrySet() ) {
- constraintValidatorContext.addError( entry.getKey(), entry.getValue() );
+ constraintValidatorContext.buildErrorWithMessageTemplate( entry.getKey() )
+ .inSubNode( entry.getValue() );
}
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-22 21:05:28 UTC (rev 16865)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/TestUtil.java 2009-06-22 21:06:03 UTC (rev 16866)
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Set;
import javax.validation.ConstraintViolation;
+import javax.validation.Path;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.metadata.ConstraintDescriptor;
@@ -80,10 +81,10 @@
}
}
- public static <T> void assertCorrectPropertyPaths(Set<ConstraintViolation<T>> violations, String[] propertyPaths) {
+ public static <T> void assertCorrectPropertyPaths(Set<ConstraintViolation<T>> violations, String... propertyPaths) {
List<String> propertyPathsOfViolations = new ArrayList<String>();
for ( ConstraintViolation<?> violation : violations ) {
- propertyPathsOfViolations.add( violation.getPropertyPath() );
+ propertyPathsOfViolations.add( violation.getPropertyPath().toString() );
}
for ( String propertyPath : propertyPaths ) {
@@ -96,7 +97,7 @@
public static <T> void assertConstraintViolation(ConstraintViolation<T> violation, Class<?> rootBean, Object invalidValue, String propertyPath) {
assertEquals(
- violation.getPropertyPath(),
+ violation.getPropertyPath().toString(),
propertyPath,
"Wrong propertyPath."
);
15 years, 5 months
Hibernate SVN: r16865 - in validator/trunk/hibernate-validator/src: main/java/org/hibernate/validation/engine/resolver and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-22 17:05:28 -0400 (Mon, 22 Jun 2009)
New Revision: 16865
Added:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/NodeImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/PathImpl.java
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/ConstraintValidatorContextImpl.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/resolver/DefaultTraversableResolver.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/JPATraversableResolver.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/SingleThreadCachedTraversableResolver.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/traversableresolver/CachedTraversableResolverTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
Log:
started integrating the new path API
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-06-22 21:05:07 UTC (rev 16864)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintTree.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -113,7 +113,7 @@
}
ConstraintValidatorContextImpl constraintValidatorContext = new ConstraintValidatorContextImpl(
- executionContext.peekParentPath(), executionContext.peekProperty(), descriptor
+ executionContext.peekPropertyPath(), descriptor
);
// we could have a composing constraint which does not need its own validator.
@@ -133,9 +133,8 @@
if ( reportAsSingleViolation() && constraintViolations.size() > 0 ) {
constraintViolations.clear();
final String message = ( String ) getParent().getDescriptor().getAttributes().get( "message" );
- final String property = executionContext.peekPropertyPath();
ConstraintValidatorContextImpl.ErrorMessage error = constraintValidatorContext.new ErrorMessage(
- message, property
+ message, executionContext.peekPropertyPath()
);
constraintViolations.add( executionContext.createConstraintViolation( value, error, descriptor ) );
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java 2009-06-22 21:05:07 UTC (rev 16864)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintValidatorContextImpl.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -19,8 +19,9 @@
import java.util.ArrayList;
import java.util.List;
-import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.ConstraintValidatorContext;
+import javax.validation.Path;
+import javax.validation.metadata.ConstraintDescriptor;
/**
* @author Hardy Ferentschik
@@ -28,15 +29,13 @@
public class ConstraintValidatorContextImpl implements ConstraintValidatorContext {
private final List<ErrorMessage> errorMessages = new ArrayList<ErrorMessage>( 3 );
- private final String property;
- private final String propertyParent;
+ private final Path propertyPath;
private final ConstraintDescriptor<?> constraintDescriptor;
private boolean defaultDisabled;
- public ConstraintValidatorContextImpl(String propertyParent, String property, ConstraintDescriptor<?> constraintDescriptor) {
- this.property = property;
- this.propertyParent = propertyParent;
+ public ConstraintValidatorContextImpl(Path propertyPath, ConstraintDescriptor<?> constraintDescriptor) {
+ this.propertyPath = propertyPath;
this.constraintDescriptor = constraintDescriptor;
}
@@ -44,18 +43,14 @@
defaultDisabled = true;
}
- public String getDefaultErrorMessage() {
+ public String getDefaultErrorMessageTemplate() {
return ( String ) constraintDescriptor.getAttributes().get( "message" );
}
- public void addError(String message) {
- errorMessages.add( new ErrorMessage( message, buildPropertyPath( propertyParent, property ) ) );
+ public ErrorBuilder buildErrorWithMessageTemplate(String messageTemplate) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
}
- public void addError(String message, String property) {
- errorMessages.add( new ErrorMessage( message, buildPropertyPath( propertyParent, property ) ) );
- }
-
public ConstraintDescriptor<?> getConstraintDescriptor() {
return constraintDescriptor;
}
@@ -68,39 +63,27 @@
List<ErrorMessage> returnedErrorMessages = new ArrayList<ErrorMessage>( errorMessages );
if ( !defaultDisabled ) {
returnedErrorMessages.add(
- new ErrorMessage( getDefaultErrorMessage(), buildPropertyPath( propertyParent, property ) )
+ new ErrorMessage( getDefaultErrorMessageTemplate(), propertyPath )
);
}
return returnedErrorMessages;
}
- private String buildPropertyPath(String parent, String leaf) {
- if ( ExecutionContext.PROPERTY_ROOT.equals( parent ) ) {
- return leaf;
- }
- else {
- return new StringBuilder().append( parent )
- .append( ExecutionContext.PROPERTY_PATH_SEPERATOR )
- .append( leaf )
- .toString();
- }
- }
-
public class ErrorMessage {
private final String message;
- private final String property;
+ private final Path propertyPath;
- public ErrorMessage(String message, String property) {
+ public ErrorMessage(String message, Path property) {
this.message = message;
- this.property = property;
+ this.propertyPath = property;
}
public String getMessage() {
return message;
}
- public String getProperty() {
- return property;
+ public Path getPath() {
+ return propertyPath;
}
}
}
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-06-22 21:05:07 UTC (rev 16864)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintViolationImpl.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -18,6 +18,7 @@
package org.hibernate.validation.engine;
import javax.validation.ConstraintViolation;
+import javax.validation.Path;
import javax.validation.metadata.ConstraintDescriptor;
/**
@@ -28,7 +29,7 @@
private final String interpolatedMessage;
private final T rootBean;
private final Object value;
- private final String propertyPath;
+ private final Path propertyPath;
private final Object leafBeanInstance;
private final ConstraintDescriptor constraintDescriptor;
private final String rawMessage;
@@ -37,7 +38,7 @@
public ConstraintViolationImpl(String messageTemplate, String interpolatedMessage, Class<T> rootBeanClass,
T rootBean, Object leafBeanInstance, Object value,
- String propertyPath, ConstraintDescriptor constraintDescriptor) {
+ Path propertyPath, ConstraintDescriptor constraintDescriptor) {
this.rawMessage = messageTemplate;
this.interpolatedMessage = interpolatedMessage;
this.rootBean = rootBean;
@@ -48,9 +49,6 @@
this.rootBeanClass = rootBeanClass;
}
- /**
- * {@inheritDoc}
- */
public String getMessage() {
return interpolatedMessage;
}
@@ -59,9 +57,6 @@
return rawMessage;
}
- /**
- * {@inheritDoc}
- */
public T getRootBean() {
return rootBean;
}
@@ -74,17 +69,11 @@
return leafBeanInstance;
}
- /**
- * {@inheritDoc}
- */
public Object getInvalidValue() {
return value;
}
- /**
- * {@inheritDoc}
- */
- public String getPropertyPath() {
+ public Path getPropertyPath() {
return propertyPath;
}
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-06-22 21:05:07 UTC (rev 16864)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -17,25 +17,26 @@
*/
package org.hibernate.validation.engine;
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Stack;
-import java.lang.reflect.Member;
-import java.lang.reflect.Field;
-import java.lang.annotation.ElementType;
-import javax.validation.metadata.ConstraintDescriptor;
+import java.util.HashSet;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.ConstraintViolation;
import javax.validation.MessageInterpolator;
+import javax.validation.Path;
import javax.validation.TraversableResolver;
+import javax.validation.metadata.ConstraintDescriptor;
-import org.hibernate.validation.util.IdentitySet;
import org.hibernate.validation.metadata.MetaConstraint;
+import org.hibernate.validation.util.IdentitySet;
/**
* Context object keeping track of all processed objects and failing constraints.
@@ -48,10 +49,6 @@
*/
public class ExecutionContext<T> {
- public static final String PROPERTY_ROOT = "";
-
- public static final String PROPERTY_PATH_SEPERATOR = ".";
-
/**
* The root bean of the validation.
*/
@@ -71,7 +68,7 @@
/**
* Maps an object to a list of paths in which it has been invalidated.
*/
- private final Map<Object, Set<String>> processedPaths;
+ private final Map<Object, Set<Path>> processedPaths;
/**
* A list of all failing constraints so far.
@@ -79,9 +76,9 @@
private final List<ConstraintViolation<T>> failingConstraintViolations;
/**
- * The current property based based from the root bean.
+ * The current property path we are validating.
*/
- private List<String> propertyPath;
+ private PathImpl propertyPath;
/**
* The current group we are validating.
@@ -98,7 +95,7 @@
*
* @todo Make this boolean a configurable item.
*/
- private boolean allowOneValidationPerPath = true;
+ private boolean allowOneValidationPerPath = false;
/**
* The message resolver which should be used in this context.
@@ -151,8 +148,8 @@
beanStack.push( object );
processedObjects = new HashMap<Class<?>, IdentitySet>();
- processedPaths = new IdentityHashMap<Object, Set<String>>();
- propertyPath = new ArrayList<String>();
+ processedPaths = new IdentityHashMap<Object, Set<Path>>();
+ propertyPath = new PathImpl();
failingConstraintViolations = new ArrayList<ConstraintViolation<T>>();
}
@@ -212,20 +209,6 @@
return alreadyValidated;
}
- private boolean isAlreadyValidatedForPath(Object value) {
- for ( String path : processedPaths.get( value ) ) {
- if ( path.contains( peekPropertyPath() ) || peekPropertyPath().contains( path ) ) {
- return true;
- }
- }
- return false;
- }
-
- private boolean isAlreadyValidatedForCurrentGroup(Object value) {
- final IdentitySet objectsProcessedInCurrentGroups = processedObjects.get( currentGroup );
- return objectsProcessedInCurrentGroups != null && objectsProcessedInCurrentGroups.contains( value );
- }
-
public void addConstraintFailures(List<ConstraintViolation<T>> failingConstraintViolations) {
for ( ConstraintViolation<T> violation : failingConstraintViolations ) {
addConstraintFailure( violation );
@@ -242,47 +225,34 @@
* @param property the new property to add to the current path.
*/
public void pushProperty(String property) {
- propertyPath.add( property );
+ propertyPath.addNode( new NodeImpl( property ) );
}
/**
* Drops the last level of the current property path of this context.
*/
public void popProperty() {
- if ( propertyPath.size() > 0 ) {
- propertyPath.remove( propertyPath.size() - 1 );
- }
+ propertyPath.removeLast();
}
public void markCurrentPropertyAsIterable() {
- String property = peekProperty();
- property += "[]";
- propertyPath.remove( propertyPath.size() - 1 );
- pushProperty( property );
+ ((NodeImpl)propertyPath.getLast()).setInIterable( true );
}
public void setPropertyIndex(String index) {
- String property = peekProperty();
-
- // replace the last occurance of [<oldIndex>] with [<index>]
- property = property.replaceAll( "\\[[0-9]*\\]$", "[" + index + "]" );
- propertyPath.remove( propertyPath.size() - 1 );
- pushProperty( property );
+ ((NodeImpl)propertyPath.getLast()).setIndex( Integer.getInteger( index ) );
}
- public String peekPropertyPath() {
- return buildPath( propertyPath.size() - 1 );
+ public Path peekPropertyPath() {
+ return new PathImpl(propertyPath);
}
- public String peekProperty() {
- if ( propertyPath.size() == 0 ) {
- return PROPERTY_ROOT;
- }
- return propertyPath.get( propertyPath.size() - 1 );
+ public Path.Node peekProperty() {
+ return propertyPath.getLast();
}
- public String peekParentPath() {
- return buildPath( propertyPath.size() - 2 );
+ public Path peekParentPath() {
+ return propertyPath.getParentPath();
}
@SuppressWarnings("SimplifiableIfStatement")
@@ -302,22 +272,20 @@
public boolean isCascadeRequired(Member member) {
final ElementType type = member instanceof Field ? ElementType.FIELD : ElementType.METHOD;
- final String parentPath = peekParentPath();
final Class<T> rootBeanType = getRootBeanClass();
- final String traversableProperty = peekProperty();
final Object traversableobject = peekCurrentBean();
return traversableResolver.isReachable(
traversableobject,
- traversableProperty,
+ peekProperty(),
rootBeanType,
- parentPath,
+ peekParentPath(),
type
)
&& traversableResolver.isCascadable(
traversableobject,
- traversableProperty,
+ peekProperty(),
rootBeanType,
- parentPath,
+ peekParentPath(),
type
);
}
@@ -346,23 +314,24 @@
getRootBean(),
peekCurrentBean(),
value,
- error.getProperty(),
+ error.getPath(),
descriptor
);
}
- private String buildPath(int index) {
- if (index < 0) return PROPERTY_ROOT;
- StringBuilder builder = new StringBuilder();
- for ( int i = 0; i <= index; i++ ) {
- builder.append( propertyPath.get( i ) );
- if ( i < index ) {
- builder.append( PROPERTY_PATH_SEPERATOR );
- }
+ private boolean isAlreadyValidatedForPath(Object value) {
+ Set<Path> pathSet = processedPaths.get( value );
+ if(pathSet != null && pathSet.contains( peekPropertyPath() )) {
+ return true;
}
- return builder.toString();
+ return false;
}
+ private boolean isAlreadyValidatedForCurrentGroup(Object value) {
+ final IdentitySet objectsProcessedInCurrentGroups = processedObjects.get( currentGroup );
+ return objectsProcessedInCurrentGroups != null && objectsProcessedInCurrentGroups.contains( value );
+ }
+
private void markProcessed() {
markProcessForCurrentGroup();
if ( allowOneValidationPerPath ) {
@@ -375,12 +344,13 @@
processedPaths.get( peekCurrentBean() ).add( peekPropertyPath() );
}
else {
- Set<String> set = new HashSet<String>();
+ Set<Path> set = new HashSet<Path>();
set.add( peekPropertyPath() );
processedPaths.put( peekCurrentBean(), set );
}
}
+
private void markProcessForCurrentGroup() {
if ( processedObjects.containsKey( currentGroup ) ) {
processedObjects.get( currentGroup ).add( peekCurrentBean() );
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/NodeImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/NodeImpl.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/NodeImpl.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -0,0 +1,105 @@
+// $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.engine;
+
+import javax.validation.Path;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class NodeImpl implements Path.Node {
+ private final String name;
+ private boolean isInIterable;
+ private Integer index;
+ private Object key;
+
+
+ public NodeImpl(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public boolean isInIterable() {
+ return isInIterable;
+ }
+
+ public void setInIterable(boolean inIterable) {
+ isInIterable = inIterable;
+ }
+
+ public Integer getIndex() {
+ return index;
+ }
+
+ public void setIndex(Integer index) {
+ this.index = index;
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ @Override
+ public String toString() {
+ return "NodeImpl{" +
+ "name='" + name + '\'' +
+ ", isInIterable=" + isInIterable +
+ ", index=" + index +
+ ", key=" + key +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ NodeImpl node = ( NodeImpl ) o;
+
+ if ( isInIterable != node.isInIterable ) {
+ return false;
+ }
+ if ( index != null ? !index.equals( node.index ) : node.index != null ) {
+ return false;
+ }
+ if ( key != null ? !key.equals( node.key ) : node.key != null ) {
+ return false;
+ }
+ if ( name != null ? !name.equals( node.name ) : node.name != null ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = name != null ? name.hashCode() : 0;
+ result = 31 * result + ( isInIterable ? 1 : 0 );
+ result = 31 * result + ( index != null ? index.hashCode() : 0 );
+ result = 31 * result + ( key != null ? key.hashCode() : 0 );
+ return result;
+ }
+}
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/PathImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/PathImpl.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/PathImpl.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -0,0 +1,133 @@
+// $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.engine;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.validation.Path;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class PathImpl implements Path {
+
+ public static final String PROPERTY_PATH_SEPERATOR = ".";
+
+ private final List<Node> nodeList;
+
+ public PathImpl() {
+ nodeList = new ArrayList<Node>();
+ Node root = new NodeImpl( null );
+ nodeList.add( root );
+ }
+
+ public PathImpl(PathImpl path) {
+ this();
+ Iterator<Node> iter = path.iterator();
+ while(iter.hasNext()) {
+ Node node = iter.next();
+ nodeList.add(node);
+ }
+ }
+
+ public PathImpl(List<Node> nodeList) {
+ this.nodeList = nodeList;
+ }
+
+ public Path getParentPath() {
+ List<Node> nodes = new ArrayList<Node>( nodeList );
+ if ( nodes.size() > 1 ) {
+ nodes.remove( nodes.size() - 1 );
+ }
+ return new PathImpl( nodes );
+ }
+
+ public void addNode(Node node) {
+ nodeList.add( node );
+ }
+
+ public Node removeLast() {
+ if ( nodeList.size() < 1 ) {
+ throw new IllegalStateException();
+ }
+ return nodeList.remove( nodeList.size() - 1 );
+ }
+
+ public Node getLast() {
+ if ( nodeList.size() < 1 ) {
+ throw new IllegalStateException();
+ }
+ return nodeList.get( nodeList.size() - 1 );
+ }
+
+ public Iterator<Path.Node> iterator() {
+ return nodeList.iterator();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ Iterator<Path.Node> iter = iterator();
+ while ( iter.hasNext() ) {
+ Node node = iter.next();
+ if ( node.getName() != null ) {
+ builder.append( node.getName() );
+
+ if ( node.isInIterable() ) {
+ builder.append( "[" );
+ if ( node.getIndex() != null ) {
+ builder.append( node.getIndex() );
+ }
+ else if ( node.getKey() != null ) {
+ builder.append( node.getKey() );
+ }
+ builder.append( "]" );
+ }
+ if ( iter.hasNext() ) {
+ builder.append( PROPERTY_PATH_SEPERATOR );
+
+ }
+ }
+ }
+ return builder.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() ) {
+ return false;
+ }
+
+ PathImpl path = ( PathImpl ) o;
+
+ if ( nodeList != null ? !nodeList.equals( path.nodeList ) : path.nodeList != null ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return nodeList != null ? nodeList.hashCode() : 0;
+ }
+}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/DefaultTraversableResolver.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/DefaultTraversableResolver.java 2009-06-22 21:05:07 UTC (rev 16864)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/DefaultTraversableResolver.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -1,6 +1,7 @@
package org.hibernate.validation.engine.resolver;
import java.lang.annotation.ElementType;
+import javax.validation.Path;
import javax.validation.TraversableResolver;
import org.slf4j.Logger;
@@ -83,13 +84,13 @@
}
}
- public boolean isReachable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return jpaTraversableResolver == null || jpaTraversableResolver.isReachable(
traversableObject, traversableProperty, rootBeanType, pathToTraversableObject, elementType
);
}
- public boolean isCascadable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return jpaTraversableResolver == null || jpaTraversableResolver.isCascadable(
traversableObject, traversableProperty, rootBeanType, pathToTraversableObject, elementType
);
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/JPATraversableResolver.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/JPATraversableResolver.java 2009-06-22 21:05:07 UTC (rev 16864)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/JPATraversableResolver.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -20,6 +20,7 @@
import java.lang.annotation.ElementType;
import javax.persistence.Persistence;
import javax.validation.TraversableResolver;
+import javax.validation.Path;
/**
* @author Hardy Ferentschik
@@ -27,12 +28,13 @@
*/
public class JPATraversableResolver implements TraversableResolver {
- public boolean isReachable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ // TODO Check the call to PeristenceUtil. traversableProperty.getName() is this correct?
+ public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return traversableObject == null ||
- Persistence.getPersistenceUtil().isLoaded( traversableObject, traversableProperty );
+ Persistence.getPersistenceUtil().isLoaded( traversableObject, traversableProperty.getName() );
}
- public boolean isCascadable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return true;
}
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/SingleThreadCachedTraversableResolver.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/SingleThreadCachedTraversableResolver.java 2009-06-22 21:05:07 UTC (rev 16864)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/resolver/SingleThreadCachedTraversableResolver.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -20,6 +20,7 @@
import java.lang.annotation.ElementType;
import java.util.HashMap;
import java.util.Map;
+import javax.validation.Path;
import javax.validation.TraversableResolver;
/**
@@ -37,16 +38,19 @@
this.delegate = delegate;
}
- public boolean isReachable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
- TraversableHolder currentLH = new TraversableHolder( traversableObject, traversableProperty, rootBeanType, pathToTraversableObject, elementType );
+ public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
+ TraversableHolder currentLH = new TraversableHolder(
+ traversableObject, traversableProperty, rootBeanType, pathToTraversableObject, elementType
+ );
TraversableHolder cachedLH = traversables.get( currentLH );
- if (cachedLH == null) {
+ if ( cachedLH == null ) {
currentLH.isReachable = delegate.isReachable(
traversableObject,
traversableProperty,
rootBeanType,
pathToTraversableObject,
- elementType );
+ elementType
+ );
traversables.put( currentLH, currentLH );
cachedLH = currentLH;
}
@@ -56,21 +60,25 @@
traversableProperty,
rootBeanType,
pathToTraversableObject,
- elementType );
+ elementType
+ );
}
return cachedLH.isReachable;
}
- public boolean isCascadable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
- TraversableHolder currentLH = new TraversableHolder( traversableObject, traversableProperty, rootBeanType, pathToTraversableObject, elementType );
+ public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
+ TraversableHolder currentLH = new TraversableHolder(
+ traversableObject, traversableProperty, rootBeanType, pathToTraversableObject, elementType
+ );
TraversableHolder cachedLH = traversables.get( currentLH );
- if (cachedLH == null) {
+ if ( cachedLH == null ) {
currentLH.isCascadable = delegate.isCascadable(
traversableObject,
traversableProperty,
rootBeanType,
pathToTraversableObject,
- elementType );
+ elementType
+ );
traversables.put( currentLH, currentLH );
cachedLH = currentLH;
}
@@ -80,28 +88,29 @@
traversableProperty,
rootBeanType,
pathToTraversableObject,
- elementType );
+ elementType
+ );
}
return cachedLH.isCascadable;
}
-
+
private static class TraversableHolder {
private final Object traversableObject;
- private final String traversableProperty;
+ private final Path.Node traversableProperty;
private final Class<?> rootBeanType;
- private final String pathToTraversableObject;
+ private final Path pathToTraversableObject;
private final ElementType elementType;
private final int hashCode;
-
+
private Boolean isReachable;
private Boolean isCascadable;
- private TraversableHolder(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ private TraversableHolder(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
this.traversableObject = traversableObject;
this.traversableProperty = traversableProperty;
this.rootBeanType = rootBeanType;
- this.pathToTraversableObject = pathToTraversableObject == null ? "" : pathToTraversableObject;
+ this.pathToTraversableObject = pathToTraversableObject;
this.elementType = elementType;
this.hashCode = buildHashCode();
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/traversableresolver/CachedTraversableResolverTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/traversableresolver/CachedTraversableResolverTest.java 2009-06-22 21:05:07 UTC (rev 16864)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/traversableresolver/CachedTraversableResolverTest.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -25,6 +25,7 @@
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
+import javax.validation.Path;
import javax.validation.groups.Default;
import static org.testng.Assert.fail;
@@ -77,7 +78,7 @@
private Set<Holder> askedReach = new HashSet<Holder>();
private Set<Holder> askedCascade = new HashSet<Holder>();
- private boolean isTraversable(Set<Holder> asked, Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ private boolean isTraversable(Set<Holder> asked, Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
Holder h = new Holder( traversableObject, traversableProperty );
if ( asked.contains( h ) ) {
throw new IllegalStateException( "Called twice" );
@@ -86,7 +87,7 @@
return true;
}
- public boolean isReachable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return isTraversable(
askedReach,
traversableObject,
@@ -97,7 +98,7 @@
);
}
- public boolean isCascadable(Object traversableObject, String traversableProperty, Class<?> rootBeanType, String pathToTraversableObject, ElementType elementType) {
+ public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return isTraversable(
askedCascade,
traversableObject,
@@ -111,9 +112,9 @@
public static class Holder {
Object NULL = new Object();
Object to;
- String tp;
+ Path.Node tp;
- public Holder(Object traversableObject, String traversableProperty) {
+ public Holder(Object traversableObject, Path.Node traversableProperty) {
to = traversableObject == null ? NULL : traversableObject;
tp = traversableProperty;
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java 2009-06-22 21:05:07 UTC (rev 16864)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/util/TestUtil.java 2009-06-22 21:05:28 UTC (rev 16865)
@@ -114,7 +114,7 @@
public static void assertConstraintViolation(ConstraintViolation violation, String errorMessage, Class rootBean, Object invalidValue, String propertyPath) {
assertEquals(
- violation.getPropertyPath(),
+ violation.getPropertyPath().toString(),
propertyPath,
"Wrong propertyPath"
);
15 years, 5 months
Hibernate SVN: r16864 - validator/tags.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-22 17:05:07 -0400 (Mon, 22 Jun 2009)
New Revision: 16864
Added:
validator/tags/pre_path_integration/
Log:
Created tag pre_path_integration.
Copied: validator/tags/pre_path_integration (from rev 16863, validator/trunk)
15 years, 5 months