public final class JkPathMatcher
extends java.lang.Object
implements java.nio.file.PathMatcher
PathMatcher
s, each associated with a label for human-readable identification.
Description:
PathMatcher
is used to determine whether a Path
matches a specific pattern.JkPathMatcher.of()
: Matches all entries (accepts any path).JkPathMatcher.of(boolean positive, FileSystem fileSystem, Iterable<String> globPatterns)
:
Matches entries based on one or more glob patterns, with optional inclusion or exclusion behavior
(driven by the positive
parameter).JkPathMatcher.of(boolean positive, String... globPattern)
: A convenient overload of the method above,
using the default file system.
// Example: Creating a PathMatcher that accepts paths matching "*.java"
JkPathMatcher matcher = JkPathMatcher.of(true, "*.java");
// Example: Checking if a specific path matches
boolean isMatched = matcher.matches(Paths.get("src/main/MyClass.java")); // Returns true
See individual method documentation for specific behavior and usage details.
Modifier and Type | Field and Description |
---|---|
static JkPathMatcher |
ACCEPT_ALL |
Modifier and Type | Method and Description |
---|---|
JkPathMatcher |
and(boolean positive,
java.nio.file.FileSystem fileSystem,
java.lang.String... patterns) |
JkPathMatcher |
and(boolean positive,
java.lang.String... patterns) |
JkPathMatcher |
and(java.nio.file.PathMatcher other) |
boolean |
matches(java.nio.file.Path path) |
JkPathMatcher |
negate() |
static JkPathMatcher |
of()
A matcher accepting all entries.
|
static JkPathMatcher |
of(boolean positive,
java.nio.file.FileSystem fileSystem,
java.lang.Iterable<java.lang.String> globPatterns)
A matcher accepting/refusing if path matches at least one of the specified glob patterns within specified file system.
|
static JkPathMatcher |
of(boolean positive,
java.nio.file.FileSystem fileSystem,
java.lang.String... globPattern) |
static JkPathMatcher |
of(boolean positive,
java.lang.String... globPattern) |
static JkPathMatcher |
of(java.nio.file.PathMatcher matcher)
Creates an instance from a
PathMatcher instance. |
static JkPathMatcher |
of(java.lang.String... globPatterns)
Shorthand for
of(true, patterns) . |
static JkPathMatcher |
ofNoDirectory(java.nio.file.LinkOption... linkOptions)
A matcher filtering out directories.
|
JkPathMatcher |
or(java.nio.file.PathMatcher other) |
java.util.function.Predicate<java.nio.file.Path> |
toPredicate()
Returns this matcher as a
Predicate |
java.lang.String |
toString() |
public static final JkPathMatcher ACCEPT_ALL
public static JkPathMatcher of(java.nio.file.PathMatcher matcher)
PathMatcher
instance.public static JkPathMatcher of()
public static JkPathMatcher ofNoDirectory(java.nio.file.LinkOption... linkOptions)
public static JkPathMatcher of(boolean positive, java.nio.file.FileSystem fileSystem, java.lang.String... globPattern)
of(boolean, FileSystem, Iterable)
public static JkPathMatcher of(java.lang.String... globPatterns)
of(true, patterns)
.public static JkPathMatcher of(boolean positive, java.lang.String... globPattern)
of(boolean, FileSystem, Iterable)
public static JkPathMatcher of(boolean positive, java.nio.file.FileSystem fileSystem, java.lang.Iterable<java.lang.String> globPatterns)
positive
- If true
matcher will accept files matching at least one of the specified patterns.
If false
matcher will accept files matching none of the specified pattern.public java.lang.String toString()
toString
in class java.lang.Object
public java.util.function.Predicate<java.nio.file.Path> toPredicate()
Predicate
public boolean matches(java.nio.file.Path path)
matches
in interface java.nio.file.PathMatcher
public JkPathMatcher and(java.nio.file.PathMatcher other)
public JkPathMatcher or(java.nio.file.PathMatcher other)
public JkPathMatcher and(boolean positive, java.nio.file.FileSystem fileSystem, java.lang.String... patterns)
public JkPathMatcher and(boolean positive, java.lang.String... patterns)
public JkPathMatcher negate()