package com.github.britter.beanvalidators.file;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.validation.ValidationException;
import java.io.File;
import java.lang.annotation.Annotation;

import org.apache.commons.lang3.StringUtils;

abstract class AbstractFileConstraintValidator<A extends Annotation> implements ConstraintValidator<A, Object> {

    private Class<? extends Annotation> constraintAnnotation;

    @Override
    public void initialize(A constraintAnnotation) {
        this.constraintAnnotation = constraintAnnotation.annotationType();
    }

    @Override
    public boolean isValid(Object value, ConstraintValidatorContext context) {
        if (value == null) {
            return true;
        }
        if (value instanceof File) {
            return isValid((File) value, context);
        } else if (value instanceof String) {
            String str = (String) value;
            return StringUtils.isBlank(str) || isValid(new File(str), context);
        } else {
            throw new ValidationException("@" + constraintAnnotation.getSimpleName()
                    + " can not be applied to instances of " + value.getClass());
        }
    }

    public abstract boolean isValid(File value, ConstraintValidatorContext context);
}

@@ -446,27 +446,17 @@
 tation%3E 
-constraintA
+a
 nnotatio
@@ -456,16 +456,20 @@
 notation
+Type
 ;%0A%0A    @
@@ -543,27 +543,17 @@
    this.
-constraintA
+a
 nnotatio
@@ -553,16 +553,20 @@
 notation
+Type
  = const
@@ -1083,27 +1083,17 @@
 n(%22@%22 + 
-constraintA
+a
 nnotatio
@@ -1093,16 +1093,20 @@
 notation
+Type
 .getSimp

Fix checkstyle issue: parameter constraintAnnotation hides field