@Test public void hasNotCompanionFile_ShouldReturnTrue_IfExtensionNotProvided() throws Exception { Path testFile = createFile(getPath("foo", "bar.ext")); assertThat(subject.hasNotCompanionFile(testFile)).isTrue(); }
boolean hasNotCompanionFile(Path path) { if (skipExtension.isPresent()) { Path sibling = path.resolveSibling(path.getFileName() + skipExtension.get()); boolean companionFileExists = Files.exists(sibling); boolean markDirFileExists = skipDirectory.map(dir -> { Path siblingInDir = searchDir.get().getParent().relativize(sibling); Path toChck = dir.resolve(siblingInDir); return Files.exists(toChck); }).orElse(false); if (companionFileExists || markDirFileExists) log.debug("Ignoring: {}", path); return !(companionFileExists || markDirFileExists); } else { return true; } }
FileScannerImpl implements FileScanner { boolean hasNotCompanionFile(Path path) { if (skipExtension.isPresent()) { Path sibling = path.resolveSibling(path.getFileName() + skipExtension.get()); boolean companionFileExists = Files.exists(sibling); boolean markDirFileExists = skipDirectory.map(dir -> { Path siblingInDir = searchDir.get().getParent().relativize(sibling); Path toChck = dir.resolve(siblingInDir); return Files.exists(toChck); }).orElse(false); if (companionFileExists || markDirFileExists) log.debug("Ignoring: {}", path); return !(companionFileExists || markDirFileExists); } else { return true; } } }
FileScannerImpl implements FileScanner { boolean hasNotCompanionFile(Path path) { if (skipExtension.isPresent()) { Path sibling = path.resolveSibling(path.getFileName() + skipExtension.get()); boolean companionFileExists = Files.exists(sibling); boolean markDirFileExists = skipDirectory.map(dir -> { Path siblingInDir = searchDir.get().getParent().relativize(sibling); Path toChck = dir.resolve(siblingInDir); return Files.exists(toChck); }).orElse(false); if (companionFileExists || markDirFileExists) log.debug("Ignoring: {}", path); return !(companionFileExists || markDirFileExists); } else { return true; } }  }
FileScannerImpl implements FileScanner { boolean hasNotCompanionFile(Path path) { if (skipExtension.isPresent()) { Path sibling = path.resolveSibling(path.getFileName() + skipExtension.get()); boolean companionFileExists = Files.exists(sibling); boolean markDirFileExists = skipDirectory.map(dir -> { Path siblingInDir = searchDir.get().getParent().relativize(sibling); Path toChck = dir.resolve(siblingInDir); return Files.exists(toChck); }).orElse(false); if (companionFileExists || markDirFileExists) log.debug("Ignoring: {}", path); return !(companionFileExists || markDirFileExists); } else { return true; } }  @Override FileScanner searchIn(Path dir); @Override FileScanner withRecursion(boolean recursive); @Override FileScanner withDepth(Integer value); @Override FileScanner withDirectories(boolean dirs); @Override FileScanner withFileExtensions(List<String> allowedExtensions); @Override FileScanner whileSkippingExtraFilesWith(String skipping); @Override FileScanner whileSkippingExtraFilesIn(Path dir); @Override Optional<List<Path>> scan(); @Override Stream<Path> stream(); @Override Stream<Path> streamAndIgnoreErrors(); }
FileScannerImpl implements FileScanner { boolean hasNotCompanionFile(Path path) { if (skipExtension.isPresent()) { Path sibling = path.resolveSibling(path.getFileName() + skipExtension.get()); boolean companionFileExists = Files.exists(sibling); boolean markDirFileExists = skipDirectory.map(dir -> { Path siblingInDir = searchDir.get().getParent().relativize(sibling); Path toChck = dir.resolve(siblingInDir); return Files.exists(toChck); }).orElse(false); if (companionFileExists || markDirFileExists) log.debug("Ignoring: {}", path); return !(companionFileExists || markDirFileExists); } else { return true; } }  @Override FileScanner searchIn(Path dir); @Override FileScanner withRecursion(boolean recursive); @Override FileScanner withDepth(Integer value); @Override FileScanner withDirectories(boolean dirs); @Override FileScanner withFileExtensions(List<String> allowedExtensions); @Override FileScanner whileSkippingExtraFilesWith(String skipping); @Override FileScanner whileSkippingExtraFilesIn(Path dir); @Override Optional<List<Path>> scan(); @Override Stream<Path> stream(); @Override Stream<Path> streamAndIgnoreErrors();  }