private void assertValidationAppliesToParameterSetUpCorrectly(Class<? extends Annotation> annotationType) { boolean hasGenericValidators = !findValidatorDescriptors( annotationType, ValidationTarget.ANNOTATED_ELEMENT ).isEmpty(); boolean hasCrossParameterValidator = !findValidatorDescriptors( annotationType, ValidationTarget.PARAMETERS ).isEmpty(); final Method method = run( GetMethod.action( annotationType, VALIDATION_APPLIES_TO ) ); if ( hasGenericValidators && hasCrossParameterValidator ) { if ( method == null ) { throw LOG.getGenericAndCrossParameterConstraintDoesNotDefineValidationAppliesToParameterException( annotationType ); } if ( method.getReturnType() != ConstraintTarget.class ) { throw LOG.getValidationAppliesToParameterMustHaveReturnTypeConstraintTargetException( annotationType ); } ConstraintTarget defaultValue = (ConstraintTarget) method.getDefaultValue(); if ( defaultValue != ConstraintTarget.IMPLICIT ) { throw LOG.getValidationAppliesToParameterMustHaveDefaultValueImplicitException( annotationType ); } } else if ( method != null ) { throw LOG.getValidationAppliesToParameterMustNotBeDefinedForNonGenericAndCrossParameterConstraintException( annotationType ); } }
private void assertValidationAppliesToParameterSetUpCorrectly(Class<? extends Annotation> annotationType) { boolean hasGenericValidators = !findValidatorClasses( annotationType, ValidationTarget.ANNOTATED_ELEMENT ).isEmpty(); boolean hasCrossParameterValidator = !findValidatorClasses( annotationType, ValidationTarget.PARAMETERS ).isEmpty(); final Method method = run( GetMethod.action( annotationType, VALIDATION_APPLIES_TO ) ); if ( hasGenericValidators && hasCrossParameterValidator ) { if ( method == null ) { throw log.getGenericAndCrossParameterConstraintDoesNotDefineValidationAppliesToParameterException( annotationType ); } if ( method.getReturnType() != ConstraintTarget.class ) { throw log.getValidationAppliesToParameterMustHaveReturnTypeConstraintTargetException( annotationType ); } ConstraintTarget defaultValue = (ConstraintTarget) method.getDefaultValue(); if ( defaultValue != ConstraintTarget.IMPLICIT ) { throw log.getValidationAppliesToParameterMustHaveDefaultValueImplicitException( annotationType ); } } else if ( method != null ) { throw log.getValidationAppliesToParameterMustNotBeDefinedForNonGenericAndCrossParameterConstraintException( annotationType ); } }