Author: hardy.ferentschik
Date: 2009-06-21 05:37:10 -0400 (Sun, 21 Jun 2009)
New Revision: 16845
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanMetaDataImpl.java
Log:
Made sure the right type of exceptions are thrown when the default group is re-defined.
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanMetaDataImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanMetaDataImpl.java 2009-06-21
09:36:16 UTC (rev 16844)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/metadata/BeanMetaDataImpl.java 2009-06-21
09:37:10 UTC (rev 16845)
@@ -30,6 +30,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.validation.GroupDefinitionException;
import javax.validation.GroupSequence;
import javax.validation.Valid;
import javax.validation.ValidationException;
@@ -138,17 +139,22 @@
public void setDefaultGroupSequence(List<Class<?>> groupSequence) {
defaultGroupSequence = new ArrayList<Class<?>>();
+ boolean groupSequenceContainsDefault = false;
for ( Class<?> group : groupSequence ) {
if ( group.getName().equals( beanClass.getName() ) ) {
defaultGroupSequence.add( Default.class );
+ groupSequenceContainsDefault = true;
}
else if ( group.getName().equals( Default.class.getName() ) ) {
- throw new ValidationException( "'Default.class' cannot appear in default
group sequence list." );
+ throw new GroupDefinitionException( "'Default.class' cannot appear in
default group sequence list." );
}
else {
defaultGroupSequence.add( group );
}
}
+ if ( !groupSequenceContainsDefault ) {
+ throw new GroupDefinitionException( beanClass.getName() + " must be part of the
redefined default group sequence." );
+ }
if ( log.isTraceEnabled() ) {
log.trace(
"Members of the default group sequence for bean {} are: {}",
Show replies by date