public class HelmIgnorePathMatcher extends Object implements PathMatcher, Predicate<Path>
PathMatcher
and a Predicate<Path>
that matches paths using the syntax of
a .helmignore
file.
This class passes all
of the unit tests present in the Helm project's
package concerned with .helmignore
files. It may
permit richer syntax, but there are no guarantees made regarding
the behavior of this class in such cases.
This class is safe for concurrent use by multiple threads.
Constructor and Description |
---|
HelmIgnorePathMatcher()
Creates a new
HelmIgnorePathMatcher . |
HelmIgnorePathMatcher(Collection<? extends String> stringPatterns)
Creates a new
HelmIgnorePathMatcher . |
HelmIgnorePathMatcher(Path helmIgnoreFile)
Creates a new
HelmIgnorePathMatcher . |
HelmIgnorePathMatcher(Reader reader)
Creates a new
HelmIgnorePathMatcher . |
Modifier and Type | Method and Description |
---|---|
void |
addPattern(String stringPattern)
Calls the
addPatterns(Collection) method with a
singleton
Set consisting of the supplied stringPattern . |
void |
addPatterns(Collection<? extends String> stringPatterns)
Adds all of the valid
.helmignore patterns present in the supplied Collection of such patterns. |
boolean |
matches(Path path)
Returns
true if the supplied Path is neither
null , the empty path ("" ) nor the "current
directory" path (". " or "./ "), and if at least
one of the patterns added via the addPatterns(Collection) method logically matches it. |
boolean |
test(Path path)
Calls the
matches(Path) method with the supplied Path and returns its results. |
public HelmIgnorePathMatcher()
HelmIgnorePathMatcher
.public HelmIgnorePathMatcher(Collection<? extends String> stringPatterns)
HelmIgnorePathMatcher
.stringPatterns
- a Collection
of valid .helmignore
patterns; may be null
PatternSyntaxException
- if any of the patterns is
invalidpublic HelmIgnorePathMatcher(Reader reader) throws IOException
HelmIgnorePathMatcher
.reader
- a Reader
expected to provide access to a
logical collection of lines of text, each line of which is a valid .helmignore
pattern (or blank line, or comment); may be
null
; never closedIOException
- if an error related to the supplied reader
is encounteredPatternSyntaxException
- if any of the patterns is
invalidpublic HelmIgnorePathMatcher(Path helmIgnoreFile) throws IOException
HelmIgnorePathMatcher
.helmIgnoreFile
- a Path
expected to provide access
to a logical collection of lines of text, each line of which is a
valid .helmignore
pattern (or blank line, or comment); may be
null
; never closedIOException
- if an error related to the supplied helmIgnoreFile
is encounteredPatternSyntaxException
- if any of the patterns is
invalidHelmIgnorePathMatcher(Reader)
public final void addPattern(String stringPattern)
addPatterns(Collection)
method with a
singleton
Set
consisting of the supplied stringPattern
.stringPattern
- a valid .helmignore
pattern; may be null
or empty or prefixed with a #
character,
in which case no action will be takenaddPatterns(Collection)
,
matches(Path)
public void addPatterns(Collection<? extends String> stringPatterns)
.helmignore
patterns present in the supplied Collection
of such patterns.
Overrides must not call addPattern(String)
.
stringPatterns
- a Collection
of valid .helmignore
patterns; may be null
in which case no
action will be takenmatches(Path)
public final boolean test(Path path)
matches(Path)
method with the supplied Path
and returns its results.test
in interface Predicate<Path>
path
- a Path
to test; may be null
true
if the supplied path
matches; false
otherwisematches(Path)
public boolean matches(Path path)
true
if the supplied Path
is neither
null
, the empty path (""
) nor the "current
directory" path (".
" or "./
"), and if at least
one of the patterns added via the addPatterns(Collection)
method logically matches it.matches
in interface PathMatcher
path
- the Path
to match; may be null
in
which case false
will be returnedtrue
if at least one of the patterns added via
the addPatterns(Collection)
method logically matches the
supplied Path
; false
otherwiseCopyright © 2017–2018, microBean. All rights reserved.