switch (validation) {
case NONE:
break;
case EXISTS:
if (!file.exists()) {
throw new InvalidUserDataException(String.format("File '%s' does not exist.", file));
}
break;
case FILE:
if (!file.exists()) {
throw new InvalidUserDataException(String.format("File '%s' does not exist.", file));
}
if (!file.isFile()) {
throw new InvalidUserDataException(String.format("File '%s' is not a file.", file));
}
break;
case DIRECTORY:
if (!file.exists()) {
throw new InvalidUserDataException(String.format("Directory '%s' does not exist.", file));
}
if (!file.isDirectory()) {
throw new InvalidUserDataException(String.format("Directory '%s' is not a directory.", file));
}
break;
}
}