@Test public void parseFile_ShouldIgnoreEmptyLine() throws Exception { Path testFile = getPath("profile.ffmpeg"); String option1 = " line_without_space"; String option2 = "line with space"; Files.write(testFile, Arrays.asList(option1, "", option2)); List<String> results = subject.parseFile(testFile).get().getArguments(); assertThat(results).containsExactly("line_without_space", "line with space"); }
@Override public Optional<Profile> parseFile(Path path) { log.entry(path); try { List<String> lines = Files .lines(path) .map(String::trim) .filter(this::isNotCommentLine) .collect(Collectors.toList()); return log.exit(Optional.of( Profile.builder() .arguments(lines.stream() .filter(this::isNotFieldLine) .collect(Collectors.toList())) .fields(lines.stream() .filter(this::isFieldLine) .collect(Collectors.toMap(this::extractKey, this::extractValue))) .location(path) .build())); } catch (IOException e) { log.catching(XLogger.Level.WARN, e); return log.exit(Optional.empty()); } }
ProfileParserImpl implements ProfileParser { @Override public Optional<Profile> parseFile(Path path) { log.entry(path); try { List<String> lines = Files .lines(path) .map(String::trim) .filter(this::isNotCommentLine) .collect(Collectors.toList()); return log.exit(Optional.of( Profile.builder() .arguments(lines.stream() .filter(this::isNotFieldLine) .collect(Collectors.toList())) .fields(lines.stream() .filter(this::isFieldLine) .collect(Collectors.toMap(this::extractKey, this::extractValue))) .location(path) .build())); } catch (IOException e) { log.catching(XLogger.Level.WARN, e); return log.exit(Optional.empty()); } } }
ProfileParserImpl implements ProfileParser { @Override public Optional<Profile> parseFile(Path path) { log.entry(path); try { List<String> lines = Files .lines(path) .map(String::trim) .filter(this::isNotCommentLine) .collect(Collectors.toList()); return log.exit(Optional.of( Profile.builder() .arguments(lines.stream() .filter(this::isNotFieldLine) .collect(Collectors.toList())) .fields(lines.stream() .filter(this::isFieldLine) .collect(Collectors.toMap(this::extractKey, this::extractValue))) .location(path) .build())); } catch (IOException e) { log.catching(XLogger.Level.WARN, e); return log.exit(Optional.empty()); } }  }
ProfileParserImpl implements ProfileParser { @Override public Optional<Profile> parseFile(Path path) { log.entry(path); try { List<String> lines = Files .lines(path) .map(String::trim) .filter(this::isNotCommentLine) .collect(Collectors.toList()); return log.exit(Optional.of( Profile.builder() .arguments(lines.stream() .filter(this::isNotFieldLine) .collect(Collectors.toList())) .fields(lines.stream() .filter(this::isFieldLine) .collect(Collectors.toMap(this::extractKey, this::extractValue))) .location(path) .build())); } catch (IOException e) { log.catching(XLogger.Level.WARN, e); return log.exit(Optional.empty()); } }  @Override Optional<Profile> parseFile(Path path); }
ProfileParserImpl implements ProfileParser { @Override public Optional<Profile> parseFile(Path path) { log.entry(path); try { List<String> lines = Files .lines(path) .map(String::trim) .filter(this::isNotCommentLine) .collect(Collectors.toList()); return log.exit(Optional.of( Profile.builder() .arguments(lines.stream() .filter(this::isNotFieldLine) .collect(Collectors.toList())) .fields(lines.stream() .filter(this::isFieldLine) .collect(Collectors.toMap(this::extractKey, this::extractValue))) .location(path) .build())); } catch (IOException e) { log.catching(XLogger.Level.WARN, e); return log.exit(Optional.empty()); } }  @Override Optional<Profile> parseFile(Path path); static final Pattern FORMAT_PATTERN; }