public NotationParser<Object, File> asNotationParser() { return new NotationParser<Object, File>() { public File parseNotation(Object notation) throws UnsupportedNotationException { // TODO Further differentiate between unsupported notation errors and others (particularly when we remove the deprecated 'notation.toString()' resolution) return resolve(notation, PathValidation.NONE); } @Override public void describe(DiagnosticsVisitor visitor) { visitor.candidate("Anything that can be converted to a file, as per Project.file()"); } }; }
protected void validate(File file, PathValidation validation) { 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; } }
public NotationParser<Object, File> asNotationParser() { return new NotationParser<Object, File>() { public File parseNotation(Object notation) throws UnsupportedNotationException { // TODO Further differentiate between unsupported notation errors and others (particularly when we remove the deprecated 'notation.toString()' resolution) return resolve(notation, PathValidation.NONE); } public void describe(Collection<String> candidateFormats) { candidateFormats.add("Anything that can be converted to a file, as per Project.file()"); } }; }
public File file(Object path, PathValidation validation) { return getFileOperations().file(path, validation); }
public File resolve(Object path) { return resolve(path, PathValidation.NONE); }
public File file(Object path, PathValidation validation) { return fileResolver.resolve(path, validation); }
@Override public File file(Object path, PathValidation validation) { return fileOperations.file(path, validation); }
public File file(Object path, PathValidation validation) { return fileOperations.file(path, validation); }
@Override public File resolve(final Object path, final PathValidation validation) { return resolve(path); }
public File resolve(Object path, PathValidation validation) { File file = doResolve(path); file = fileNormaliser.normalise(file); validate(file, validation); return file; }
public File resolve(Object path, PathValidation validation) { File file = doResolve(path); file = normalise(file); validate(file, validation); return file; }
File file(Object path, PathValidation validation);
File resolve(Object path, PathValidation validation);