@Test public void pathFilter() { Predicate<Path> predicate = new PathFilter.Builder() .include("/foo/bar/*") .include("moo/mar/*") .exclude("/foo/baz/*") .exclude("moo/maz/*") .build().asPathPredicate(); assertTrue(predicate.test(Paths.get("/foo/bar/file"))); assertTrue(predicate.test(Paths.get("foo/bar/file"))); assertFalse(predicate.test(Paths.get("/foo/baz/file"))); assertFalse(predicate.test(Paths.get("foo/baz/file"))); assertTrue(predicate.test(Paths.get("/moo/mar/file"))); assertTrue(predicate.test(Paths.get("moo/mar/file"))); assertFalse(predicate.test(Paths.get("/moo/marz/file"))); assertFalse(predicate.test(Paths.get("moo/maz/file"))); }
PathFilter(List<String> includePatterns, List<String> excludePatterns) { this.includePatterns = includePatterns; this.excludePatterns = excludePatterns; if (ObjectHelper.isEmpty(excludePatterns) && ObjectHelper.isEmpty(includePatterns)) { this.stringPredicate = path -> true; } else { this.stringPredicate = path -> { path = sanitize(path); for (String part : excludePatterns) { if (matcher.match(part, path)) { return false; } } for (String part : includePatterns) { if (matcher.match(part, path)) { return true; } } return ObjectHelper.isEmpty(includePatterns); }; } ; }
PathFilter { PathFilter(List<String> includePatterns, List<String> excludePatterns) { this.includePatterns = includePatterns; this.excludePatterns = excludePatterns; if (ObjectHelper.isEmpty(excludePatterns) && ObjectHelper.isEmpty(includePatterns)) { this.stringPredicate = path -> true; } else { this.stringPredicate = path -> { path = sanitize(path); for (String part : excludePatterns) { if (matcher.match(part, path)) { return false; } } for (String part : includePatterns) { if (matcher.match(part, path)) { return true; } } return ObjectHelper.isEmpty(includePatterns); }; } ; } }
PathFilter { PathFilter(List<String> includePatterns, List<String> excludePatterns) { this.includePatterns = includePatterns; this.excludePatterns = excludePatterns; if (ObjectHelper.isEmpty(excludePatterns) && ObjectHelper.isEmpty(includePatterns)) { this.stringPredicate = path -> true; } else { this.stringPredicate = path -> { path = sanitize(path); for (String part : excludePatterns) { if (matcher.match(part, path)) { return false; } } for (String part : includePatterns) { if (matcher.match(part, path)) { return true; } } return ObjectHelper.isEmpty(includePatterns); }; } ; } PathFilter(List<String> includePatterns, List<String> excludePatterns); }
PathFilter { PathFilter(List<String> includePatterns, List<String> excludePatterns) { this.includePatterns = includePatterns; this.excludePatterns = excludePatterns; if (ObjectHelper.isEmpty(excludePatterns) && ObjectHelper.isEmpty(includePatterns)) { this.stringPredicate = path -> true; } else { this.stringPredicate = path -> { path = sanitize(path); for (String part : excludePatterns) { if (matcher.match(part, path)) { return false; } } for (String part : includePatterns) { if (matcher.match(part, path)) { return true; } } return ObjectHelper.isEmpty(includePatterns); }; } ; } PathFilter(List<String> includePatterns, List<String> excludePatterns); Predicate<String> asStringPredicate(); Predicate<DotName> asDotNamePredicate(); Predicate<Path> asPathPredicate(); String[] scanClassNames(Path rootPath, Stream<Path> pathStream, Predicate<Path> isRegularFile); }
PathFilter { PathFilter(List<String> includePatterns, List<String> excludePatterns) { this.includePatterns = includePatterns; this.excludePatterns = excludePatterns; if (ObjectHelper.isEmpty(excludePatterns) && ObjectHelper.isEmpty(includePatterns)) { this.stringPredicate = path -> true; } else { this.stringPredicate = path -> { path = sanitize(path); for (String part : excludePatterns) { if (matcher.match(part, path)) { return false; } } for (String part : includePatterns) { if (matcher.match(part, path)) { return true; } } return ObjectHelper.isEmpty(includePatterns); }; } ; } PathFilter(List<String> includePatterns, List<String> excludePatterns); Predicate<String> asStringPredicate(); Predicate<DotName> asDotNamePredicate(); Predicate<Path> asPathPredicate(); String[] scanClassNames(Path rootPath, Stream<Path> pathStream, Predicate<Path> isRegularFile);  }