class FileExtensionValidator implements ConstraintValidator<FileExtension, File> {

    @Override
    public boolean isValid(File value, ConstraintValidatorContext context) {
        if (value != null && value.isFile()) {
            String extension = FilenameUtils.getExtension(value.getName());
            return equalsIgnoreCase(expectedExtension, extension) && indexOfExtension(value.getName()) > 0;
        }
        return true;
    }

}