protected AbstractValidationRule createValidationRule(Annotation annotation, Class clazz, String propertyName) {
if (Length.class.isInstance(annotation)) {
Length length = (Length)annotation;
validateMinMax(length.min(), length.max(), clazz, propertyName);
return new LengthValidationRule(length.min(), length.max());
}
if (MinLength.class.isInstance(annotation)) {
MinLength minLength = (MinLength)annotation;
validateMin(minLength.value(), clazz, propertyName);
return new MinLengthValidationRule(minLength.value());
}
if (Length.class.isInstance(annotation)) {
Length length = (Length)annotation;
validateMinMax(length.min(), length.max(), clazz, propertyName);
return new LengthValidationRule(length.min(), length.max());
}
throw new IllegalArgumentException("LengthValidationAnnotationHandler does not suppport annotations of type: " +
annotation.getClass().getName());
}