Hibernate SVN: r19559 - in validator/trunk/hibernate-validator/src: test/java/org/hibernate/validator/test/engine/groups and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-19 12:20:53 -0400 (Wed, 19 May 2010)
New Revision: 19559
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintsForType.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/engine/groups/GroupA.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/engine/groups/GroupB.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/engine/groups/GroupChainTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/engine/groups/TestSequence.java
Log:
HV-274 Made sure keyword substitution is enabled
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintsForType.java
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/engine/groups/GroupA.java
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/engine/groups/GroupB.java
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/engine/groups/GroupChainTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Property changes on: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/engine/groups/TestSequence.java
___________________________________________________________________
Name: svn:keywords
+ Id
14 years, 7 months
Hibernate SVN: r19558 - in validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator: cfg and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-19 11:52:05 -0400 (Wed, 19 May 2010)
New Revision: 19558
Added:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintsForType.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java
Log:
HV-274 First cut of porgrammatic api (work in progress)
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java 2010-05-19 15:52:05 UTC (rev 19558)
@@ -0,0 +1,134 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.cfg;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.security.AccessController;
+import java.util.HashMap;
+import java.util.Map;
+import javax.validation.ValidationException;
+
+import org.hibernate.validator.util.NewInstance;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ConstraintDefinition<A extends Annotation> {
+ private final Class<A> constraintType;
+ private final Map<String, Object> parameters;
+ private final Class<?> beanType;
+ private final ElementType elementType;
+ private final String property;
+ private final ConstraintMapping mapping;
+
+ public ConstraintDefinition(Class<?> beanType, Class<A> constraintType, String property, ElementType elementType, ConstraintMapping mapping) {
+ if ( beanType == null ) {
+ throw new ValidationException( "Null is not a valid bean type" );
+ }
+
+ if ( constraintType == null ) {
+ throw new ValidationException( "Null is not a valid constraint type" );
+ }
+
+ if ( mapping == null ) {
+ throw new ValidationException( "ConstraintMapping cannot be null" );
+ }
+
+ if ( ( ElementType.FIELD.equals( elementType ) || ElementType.METHOD.equals( elementType ) )
+ && ( property == null || property.length() == 0 ) ) {
+ throw new ValidationException( "A property level constraint cannot have a null or empty property name" );
+ }
+
+ this.beanType = beanType;
+ this.constraintType = constraintType;
+ this.parameters = new HashMap<String, Object>();
+ this.property = property;
+ this.elementType = elementType;
+ this.mapping = mapping;
+ }
+
+ protected ConstraintDefinition addParameter(String key, Object value) {
+ parameters.put( key, value );
+ return this;
+ }
+
+ public <A extends Annotation, T extends ConstraintDefinition<A>> T constraint(Class<T> definition) {
+ T constraintDefinition = createConstraintDefinition( definition );
+ mapping.addConstraintConfig( constraintDefinition );
+ return constraintDefinition;
+ }
+
+ public ConstraintsForType property(String property, ElementType type) {
+ return new ConstraintsForType( beanType, property, type, mapping );
+ }
+
+ public ConstraintsForType type(Class<?> type) {
+ return new ConstraintsForType( type, mapping );
+ }
+
+ public ConstraintsForType valid(String property, ElementType type) {
+ return null;
+ }
+
+ public Class<A> getConstraintType() {
+ return constraintType;
+ }
+
+ public Map<String, Object> getParameters() {
+ return parameters;
+ }
+
+ public ElementType getElementType() {
+ return elementType;
+ }
+
+ public Class<?> getBeanType() {
+ return beanType;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ private <A extends Annotation, T extends ConstraintDefinition<A>> T createConstraintDefinition(Class<T> definition) {
+ T constraintDefinition;
+ NewInstance<T> newInstance = NewInstance.action( definition, "", beanType, property, elementType, mapping );
+
+ if ( System.getSecurityManager() != null ) {
+ constraintDefinition = AccessController.doPrivileged( newInstance );
+ }
+ else {
+ constraintDefinition = newInstance.run();
+ }
+ return constraintDefinition;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "ConstraintDefinition" );
+ sb.append( "{beanType=" ).append( beanType );
+ sb.append( ", constraintType=" ).append( constraintType );
+ sb.append( ", parameters=" ).append( parameters );
+ sb.append( ", elementType=" ).append( elementType );
+ sb.append( ", property='" ).append( property ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java 2010-05-19 15:52:05 UTC (rev 19558)
@@ -0,0 +1,65 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.cfg;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ConstraintMapping {
+ private final Map<Class<?>, List<ConstraintDefinition<?>>> configData;
+
+ public ConstraintMapping() {
+ configData = new HashMap<Class<?>, List<ConstraintDefinition<?>>>();
+ }
+
+ public ConstraintsForType type(Class<?> beanClass) {
+ return new ConstraintsForType( beanClass, this );
+ }
+
+ protected void addConstraintConfig(ConstraintDefinition<?> definition) {
+ Class<?> beanClass = definition.getBeanType();
+ if(configData.containsKey( beanClass )) {
+ configData.get( beanClass ).add( definition );
+ } else {
+ List<ConstraintDefinition<?>> definitionList = new ArrayList<ConstraintDefinition<?>>();
+ definitionList.add( definition );
+ configData.put(beanClass, definitionList);
+ }
+ }
+
+ public Map<Class<?>, List<ConstraintDefinition<?>>> getConfigData() {
+ return configData;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "ConstraintMapping" );
+ sb.append( "{configData=" ).append( configData );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
+
+
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintsForType.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintsForType.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintsForType.java 2010-05-19 15:52:05 UTC (rev 19558)
@@ -0,0 +1,76 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.cfg;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.security.AccessController;
+
+import org.hibernate.validator.util.NewInstance;
+
+import static java.lang.annotation.ElementType.TYPE;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ConstraintsForType {
+ private final ConstraintMapping mapping;
+ private final Class<?> beanClass;
+ private String property;
+ private ElementType elementType;
+
+ public ConstraintsForType(Class<?> beanClass, ConstraintMapping mapping) {
+ this( beanClass, "", TYPE, mapping );
+ }
+
+ public ConstraintsForType(Class<?> beanClass, String property, ElementType type, ConstraintMapping mapping) {
+ this.beanClass = beanClass;
+ this.mapping = mapping;
+ this.property = property;
+ this.elementType = type;
+ }
+
+ public <A extends Annotation, T extends ConstraintDefinition<A>> T constraint(Class<T> definition) {
+ T constraintDefinition = createConstraintDefinition( definition );
+ mapping.addConstraintConfig( constraintDefinition );
+ return constraintDefinition;
+ }
+
+ public ConstraintsForType property(String property, ElementType type) {
+ return new ConstraintsForType( beanClass, property, type, mapping );
+ }
+
+ public ConstraintsForType valid(String property, ElementType type) {
+ return null;
+ }
+
+ private <A extends Annotation, T extends ConstraintDefinition<A>> T createConstraintDefinition(Class<T> definition) {
+ T constraintDefinition;
+ NewInstance<T> newInstance = NewInstance.action( definition, "", beanClass, property, elementType, mapping );
+
+ if ( System.getSecurityManager() != null ) {
+ constraintDefinition = AccessController.doPrivileged( newInstance );
+ }
+ else {
+ constraintDefinition = newInstance.run();
+ }
+ return constraintDefinition;
+ }
+}
+
+
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java 2010-05-19 15:52:05 UTC (rev 19558)
@@ -0,0 +1,52 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.cfg;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Min;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class MinDefinition extends ConstraintDefinition<Min> {
+
+ public MinDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Min.class, property, elementType, mapping );
+ }
+
+ public MinDefinition message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public MinDefinition groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public MinDefinition payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public MinDefinition value(long min) {
+ addParameter( "value", min );
+ return this;
+ }
+}
\ No newline at end of file
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java 2010-05-19 15:52:05 UTC (rev 19558)
@@ -0,0 +1,46 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.cfg;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class NotNullDefinition extends ConstraintDefinition<NotNull> {
+ public NotNullDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, NotNull.class, property, elementType, mapping );
+ }
+
+ public NotNullDefinition message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public NotNullDefinition groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public NotNullDefinition payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java 2010-05-19 15:52:05 UTC (rev 19558)
@@ -0,0 +1,58 @@
+// $Id:$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.validator.cfg;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Pattern;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class PatternDefinition extends ConstraintDefinition<Pattern> {
+
+ public PatternDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Pattern.class, property, elementType, mapping );
+ }
+
+ public PatternDefinition message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public PatternDefinition groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public PatternDefinition payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public PatternDefinition flags(Pattern.Flag[] flags) {
+ addParameter( "flags", flags );
+ return this;
+ }
+
+ public PatternDefinition regexp(String regexp) {
+ addParameter( "regexp", regexp );
+ return this;
+ }
+}
\ No newline at end of file
Added: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java 2010-05-19 15:52:05 UTC (rev 19558)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.
+ */
+
+// $Id:$
+package org.hibernate.validator.cfg;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SizeDefinition extends ConstraintDefinition<Size> {
+
+ public SizeDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Size.class, property, elementType, mapping );
+ }
+
+ public SizeDefinition message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public SizeDefinition groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public SizeDefinition payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public SizeDefinition min(int min) {
+ addParameter( "min", min );
+ return this;
+ }
+
+ public SizeDefinition max(int max) {
+ addParameter( "max", max );
+ return this;
+ }
+}
+
+
14 years, 7 months
Hibernate SVN: r19557 - in validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator: resourceloading and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-19 11:50:47 -0400 (Wed, 19 May 2010)
New Revision: 19557
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/groups/GroupChain.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/resourceloading/AggregateResourceBundleLocator.java
Log:
HV-274 some changes due to the test refactoring
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/groups/GroupChain.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/groups/GroupChain.java 2010-05-19 15:50:04 UTC (rev 19556)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/groups/GroupChain.java 2010-05-19 15:50:47 UTC (rev 19557)
@@ -51,13 +51,13 @@
return sequenceMap.values().iterator();
}
- void insertGroup(Group group) {
+ public void insertGroup(Group group) {
if ( !groupList.contains( group ) ) {
groupList.add( group );
}
}
- void insertSequence(List<Group> groups) {
+ public void insertSequence(List<Group> groups) {
if ( groups == null || groups.size() == 0 ) {
return;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/resourceloading/AggregateResourceBundleLocator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/resourceloading/AggregateResourceBundleLocator.java 2010-05-19 15:50:04 UTC (rev 19556)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/resourceloading/AggregateResourceBundleLocator.java 2010-05-19 15:50:47 UTC (rev 19557)
@@ -107,7 +107,7 @@
*
* @author Gunnar Morling
*/
- static class AggregateBundle extends ResourceBundle {
+ public static class AggregateBundle extends ResourceBundle {
private Map<String, Object> contents = new HashMap<String, Object>();
/**
14 years, 7 months
Hibernate SVN: r19556 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-19 11:50:04 -0400 (Wed, 19 May 2010)
New Revision: 19556
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/NewInstance.java
Log:
HV-274 changed the way new instances are created. Now you can also pass a vararg argument of constructor parameters and the matching constructor will be located and executed
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/NewInstance.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/NewInstance.java 2010-05-19 15:48:49 UTC (rev 19555)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/NewInstance.java 2010-05-19 15:50:04 UTC (rev 19556)
@@ -17,28 +17,41 @@
*/
package org.hibernate.validator.util;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.security.PrivilegedAction;
import javax.validation.ValidationException;
/**
+ * Execute instance creation as privileged action.
+ *
* @author Emmanuel Bernard
+ * @author Hardy Ferentschik
*/
public class NewInstance<T> implements PrivilegedAction<T> {
private final Class<T> clazz;
private final String message;
+ private final Class<?>[] parameterTypes;
+ private final Object[] initArgs;
- public static <T> NewInstance<T> action(Class<T> clazz, String message) {
- return new NewInstance<T>( clazz, message );
+ public static <T> NewInstance<T> action(Class<T> clazz, String message, Object... initArgs) {
+ return new NewInstance<T>( clazz, message, initArgs );
}
- private NewInstance(Class<T> clazz, String message) {
+ private NewInstance(Class<T> clazz, String message, Object... initArgs) {
this.clazz = clazz;
this.message = message;
+ this.initArgs = initArgs;
+ this.parameterTypes = new Class<?>[initArgs.length];
+ for ( int i = 0; i < initArgs.length; i++ ) {
+ this.parameterTypes[i] = initArgs[i].getClass();
+ }
}
public T run() {
try {
- return clazz.newInstance();
+ Constructor<T> constructor = clazz.getConstructor( parameterTypes );
+ return constructor.newInstance( initArgs );
}
catch ( InstantiationException e ) {
throw new ValidationException( "Unable to instantiate " + message + ": " + clazz, e );
@@ -46,6 +59,12 @@
catch ( IllegalAccessException e ) {
throw new ValidationException( "Unable to instantiate " + clazz, e );
}
+ catch ( NoSuchMethodException e ) {
+ throw new ValidationException( "Unable to instantiate " + clazz, e );
+ }
+ catch ( InvocationTargetException e ) {
+ throw new ValidationException( "Unable to instantiate " + clazz, e );
+ }
catch ( RuntimeException e ) {
throw new ValidationException( "Unable to instantiate " + clazz, e );
}
14 years, 7 months
Hibernate SVN: r19555 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/xml.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-19 11:48:49 -0400 (Wed, 19 May 2010)
New Revision: 19555
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/xml/XmlMappingParser.java
Log:
Renamed getProcessedClasses() to getXmlConfiguredClasses()
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/xml/XmlMappingParser.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/xml/XmlMappingParser.java 2010-05-19 15:48:07 UTC (rev 19554)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/xml/XmlMappingParser.java 2010-05-19 15:48:49 UTC (rev 19555)
@@ -111,7 +111,7 @@
}
}
- public Set<Class<?>> getProcessedClasses() {
+ public Set<Class<?>> getXmlConfiguredClasses() {
return processedClasses;
}
14 years, 7 months
Hibernate SVN: r19554 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-19 11:48:07 -0400 (Wed, 19 May 2010)
New Revision: 19554
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java
Log:
HV-274 Uses now the new ReflectionHelper.computeClassHierarchy method
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java 2010-05-19 15:47:21 UTC (rev 19553)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/BeanMetaDataImpl.java 2010-05-19 15:48:07 UTC (rev 19554)
@@ -252,8 +252,7 @@
private void createMetaData(AnnotationIgnores annotationIgnores, BeanMetaDataCache beanMetaDataCache) {
beanDescriptor = new BeanDescriptorImpl<T>( this );
initDefaultGroupSequence();
- List<Class<?>> classes = new ArrayList<Class<?>>();
- ReflectionHelper.computeClassHierarchy( beanClass, classes );
+ List<Class<?>> classes = ReflectionHelper.computeClassHierarchy( beanClass );
for ( Class<?> current : classes ) {
initClass( current, annotationIgnores, beanMetaDataCache );
}
14 years, 7 months
Hibernate SVN: r19553 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-19 11:47:21 -0400 (Wed, 19 May 2010)
New Revision: 19553
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/HibernateValidator.java
Log:
HV-274 Typo
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/HibernateValidator.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/HibernateValidator.java 2010-05-19 15:46:47 UTC (rev 19552)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/HibernateValidator.java 2010-05-19 15:47:21 UTC (rev 19553)
@@ -28,7 +28,7 @@
import org.hibernate.validator.engine.ValidatorFactoryImpl;
/**
- * Default implementation of <code>ValidationProvider</code> within Hibernate validator.
+ * Default implementation of {@code ValidationProvider} within Hibernate Validator.
*
* @author Emmanuel Bernard
* @author Hardy Ferentschik
14 years, 7 months
Hibernate SVN: r19552 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-19 11:46:47 -0400 (Wed, 19 May 2010)
New Revision: 19552
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/GetClassLoader.java
Log:
HV-274 Made class final and applied coding standard
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/GetClassLoader.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/GetClassLoader.java 2010-05-19 15:46:02 UTC (rev 19551)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/GetClassLoader.java 2010-05-19 15:46:47 UTC (rev 19552)
@@ -22,7 +22,7 @@
/**
* @author Emmanuel Bernard
*/
-public class GetClassLoader implements PrivilegedAction<ClassLoader> {
+public final class GetClassLoader implements PrivilegedAction<ClassLoader> {
private final Class<?> clazz;
public static GetClassLoader fromContext() {
@@ -30,7 +30,9 @@
}
public static GetClassLoader fromClass(Class<?> clazz) {
- if ( clazz == null ) throw new IllegalArgumentException("Class is null");
+ if ( clazz == null ) {
+ throw new IllegalArgumentException( "Class is null" );
+ }
return new GetClassLoader( clazz );
}
@@ -39,7 +41,7 @@
}
public ClassLoader run() {
- if (clazz != null) {
+ if ( clazz != null ) {
return clazz.getClassLoader();
}
else {
14 years, 7 months
Hibernate SVN: r19551 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-19 11:46:02 -0400 (Wed, 19 May 2010)
New Revision: 19551
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/LoggerFactory.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/Version.java
Log:
HV-274 Made sure helper classes cannot be instantiated
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/LoggerFactory.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/LoggerFactory.java 2010-05-19 15:44:55 UTC (rev 19550)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/LoggerFactory.java 2010-05-19 15:46:02 UTC (rev 19551)
@@ -28,5 +28,10 @@
StackTraceElement directCaller = t.getStackTrace()[1];
return org.slf4j.LoggerFactory.getLogger( directCaller.getClassName() );
}
+
+ // private constructor to avoid instantiation
+ private LoggerFactory(){
+
+ }
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/Version.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/Version.java 2010-05-19 15:44:55 UTC (rev 19550)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/Version.java 2010-05-19 15:46:02 UTC (rev 19551)
@@ -58,4 +58,9 @@
public static void touch() {
}
+
+ // helper class should not have a public constructor
+ private Version() {
+
+ }
}
14 years, 7 months
Hibernate SVN: r19550 - validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-19 11:44:55 -0400 (Wed, 19 May 2010)
New Revision: 19550
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java
Log:
HV-274 Fixed typo
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java 2010-05-19 15:44:12 UTC (rev 19549)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/metadata/ConstraintDescriptorImpl.java 2010-05-19 15:44:55 UTC (rev 19550)
@@ -109,7 +109,7 @@
private final ElementType elementType;
/**
- * The oririgin of the constraint. Defined on the actual root class or somehwere in the class hierarchy
+ * The origin of the constraint. Defined on the actual root class or somehwere in the class hierarchy
*/
private final ConstraintOrigin definedOn;
14 years, 7 months