[hibernate-commits] Hibernate SVN: r20127 - validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Sun Aug 8 13:45:25 EDT 2010


Author: gunnar.morling
Date: 2010-08-08 13:45:24 -0400 (Sun, 08 Aug 2010)
New Revision: 20127

Modified:
   validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/ConstraintValidatorCheck.java
Log:
HV-299: Removed direct access to Constraint#validatedBy(), using mirror-based API instead in order to avoid MirrorTypeException

Modified: validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/ConstraintValidatorCheck.java
===================================================================
--- validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/ConstraintValidatorCheck.java	2010-08-08 16:45:57 UTC (rev 20126)
+++ validator/trunk/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks/ConstraintValidatorCheck.java	2010-08-08 17:45:24 UTC (rev 20127)
@@ -48,10 +48,14 @@
 	@Override
 	public Set<ConstraintCheckError> checkAnnotationType(TypeElement element, AnnotationMirror annotation) {
 
-		Constraint constraint = element.getAnnotation( Constraint.class );
+		AnnotationMirror constraintMirror = annotationApiHelper.getMirror(
+				element.getAnnotationMirrors(), Constraint.class
+		);
+		boolean atLeastOneValidatorGiven = !annotationApiHelper.getAnnotationArrayValue(
+				constraintMirror, "validatedBy"
+		).isEmpty();
 
-		//raise an error if neither a validator is given and this is not a composed constraint
-		if ( !( constraint.validatedBy().length > 0 || constraintHelper.isComposedConstraint( element ) ) ) {
+		if ( !( atLeastOneValidatorGiven || constraintHelper.isComposedConstraint( element ) ) ) {
 
 			return CollectionHelper.asSet(
 					new ConstraintCheckError(



More information about the hibernate-commits mailing list