@Test(expected = ArgumentParserException.class) public void testInvalidPath() throws ArgumentParserException { ArgumentParser ap = ArgumentParsers .newFor("argparse4j").locale(Locale.US).build(); PathArgumentType type = new PathArgumentType( new AlwaysInvalidPathFileSystem()); type.convert(ap, new MockArgument(), ALWAYS_INVALID_PATH); }
@Override public Path convert(ArgumentParser parser, Argument arg, String value) throws ArgumentParserException { Path path; try { path = fileSystem.getPath(value); } catch (InvalidPathException e) { String localizedTypeName = Java7ExtensionResourceBundle .get(parser.getConfig().getLocale()).getString("path"); throw new ArgumentParserException( String.format(TextHelper.LOCALE_ROOT, MessageLocalization .localize(parser.getConfig().getResourceBundle(), "couldNotConvertToError"), value, localizedTypeName), e.getCause(), parser, arg); } try { File file = path.toFile(); if (!isSystemIn(value)) { firstFileVerification.verify(parser, arg, file); } } catch (UnsupportedOperationException e) { } return path; }
PathArgumentType implements ArgumentType<Path> { @Override public Path convert(ArgumentParser parser, Argument arg, String value) throws ArgumentParserException { Path path; try { path = fileSystem.getPath(value); } catch (InvalidPathException e) { String localizedTypeName = Java7ExtensionResourceBundle .get(parser.getConfig().getLocale()).getString("path"); throw new ArgumentParserException( String.format(TextHelper.LOCALE_ROOT, MessageLocalization .localize(parser.getConfig().getResourceBundle(), "couldNotConvertToError"), value, localizedTypeName), e.getCause(), parser, arg); } try { File file = path.toFile(); if (!isSystemIn(value)) { firstFileVerification.verify(parser, arg, file); } } catch (UnsupportedOperationException e) { } return path; } }
PathArgumentType implements ArgumentType<Path> { @Override public Path convert(ArgumentParser parser, Argument arg, String value) throws ArgumentParserException { Path path; try { path = fileSystem.getPath(value); } catch (InvalidPathException e) { String localizedTypeName = Java7ExtensionResourceBundle .get(parser.getConfig().getLocale()).getString("path"); throw new ArgumentParserException( String.format(TextHelper.LOCALE_ROOT, MessageLocalization .localize(parser.getConfig().getResourceBundle(), "couldNotConvertToError"), value, localizedTypeName), e.getCause(), parser, arg); } try { File file = path.toFile(); if (!isSystemIn(value)) { firstFileVerification.verify(parser, arg, file); } } catch (UnsupportedOperationException e) { } return path; } PathArgumentType();  PathArgumentType(FileSystem fileSystem); }
PathArgumentType implements ArgumentType<Path> { @Override public Path convert(ArgumentParser parser, Argument arg, String value) throws ArgumentParserException { Path path; try { path = fileSystem.getPath(value); } catch (InvalidPathException e) { String localizedTypeName = Java7ExtensionResourceBundle .get(parser.getConfig().getLocale()).getString("path"); throw new ArgumentParserException( String.format(TextHelper.LOCALE_ROOT, MessageLocalization .localize(parser.getConfig().getResourceBundle(), "couldNotConvertToError"), value, localizedTypeName), e.getCause(), parser, arg); } try { File file = path.toFile(); if (!isSystemIn(value)) { firstFileVerification.verify(parser, arg, file); } } catch (UnsupportedOperationException e) { } return path; } PathArgumentType();  PathArgumentType(FileSystem fileSystem); PathArgumentType acceptSystemIn(); PathArgumentType verifyExists(); PathArgumentType verifyNotExists(); PathArgumentType verifyIsFile(); PathArgumentType verifyIsDirectory(); PathArgumentType verifyCanRead(); PathArgumentType verifyCanWrite(); PathArgumentType verifyCanWriteParent(); PathArgumentType verifyCanCreate(); PathArgumentType verifyCanExecute(); PathArgumentType verifyIsAbsolute(); PathArgumentType or(); @Override Path convert(ArgumentParser parser, Argument arg,
            String value); }
PathArgumentType implements ArgumentType<Path> { @Override public Path convert(ArgumentParser parser, Argument arg, String value) throws ArgumentParserException { Path path; try { path = fileSystem.getPath(value); } catch (InvalidPathException e) { String localizedTypeName = Java7ExtensionResourceBundle .get(parser.getConfig().getLocale()).getString("path"); throw new ArgumentParserException( String.format(TextHelper.LOCALE_ROOT, MessageLocalization .localize(parser.getConfig().getResourceBundle(), "couldNotConvertToError"), value, localizedTypeName), e.getCause(), parser, arg); } try { File file = path.toFile(); if (!isSystemIn(value)) { firstFileVerification.verify(parser, arg, file); } } catch (UnsupportedOperationException e) { } return path; } PathArgumentType();  PathArgumentType(FileSystem fileSystem); PathArgumentType acceptSystemIn(); PathArgumentType verifyExists(); PathArgumentType verifyNotExists(); PathArgumentType verifyIsFile(); PathArgumentType verifyIsDirectory(); PathArgumentType verifyCanRead(); PathArgumentType verifyCanWrite(); PathArgumentType verifyCanWriteParent(); PathArgumentType verifyCanCreate(); PathArgumentType verifyCanExecute(); PathArgumentType verifyIsAbsolute(); PathArgumentType or(); @Override Path convert(ArgumentParser parser, Argument arg,
            String value);  }