Class MatchExtensions
Maybe imposes a file-extension condition, optionally on top of an existing matcher.
The extensions are always checked in a case-insensitive manner.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Determines if it possible to match a file in a subdirectory.protected CheckedPredicate
<Path, IOException> createMatcherFile
(Path directory, Optional<InputContextParameters> inputContext) Create a predicate to be used for matching against path.A set of file-extensions (without the period), one of which must match the end of a path.A secondary matcher, which is required additionally match (as well as the extension).boolean
When true, any extensions available in the input-context are prioritized ahead ofextensions
.void
setExtensions
(StringSet extensions) A set of file-extensions (without the period), one of which must match the end of a path.void
setMatcher
(FilePathMatcher matcher) A secondary matcher, which is required additionally match (as well as the extension).void
setPrioritizeInputContext
(boolean prioritizeInputContext) When true, any extensions available in the input-context are prioritized ahead ofextensions
.Methods inherited from class org.anchoranalysis.io.input.bean.path.matcher.FilePathMatcher
matchingFiles, matchingFiles
Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
MatchExtensions
Create for specific extensions.- Parameters:
extension
- an extension.
-
MatchExtensions
public MatchExtensions()
-
-
Method Details
-
createMatcherFile
protected CheckedPredicate<Path,IOException> createMatcherFile(Path directory, Optional<InputContextParameters> inputContext) throws InputReadFailedException Description copied from class:FilePathMatcher
Create a predicate to be used for matching against path.- Specified by:
createMatcherFile
in classFilePathMatcher
- Parameters:
directory
- the directory being searched. Only paths in this directory (or its subdirectories) will ever be passed to the predicate.inputContext
- the input-context.- Returns:
- a predicate that can be used to accept or reject a path (contained in
directory
. - Throws:
InputReadFailedException
- if the testing of the predicate fails.
-
canMatchSubdirectories
protected boolean canMatchSubdirectories()Description copied from class:FilePathMatcher
Determines if it possible to match a file in a subdirectory.If it impossible to match a subdirectory, this allows us to disable any recursive search, as it is pointless effort.
- Specified by:
canMatchSubdirectories
in classFilePathMatcher
- Returns:
- true if its possible for the predicate returned by
createMatcherFile
to match a file in a subdirectory, false otherwise.
-
getMatcher
A secondary matcher, which is required additionally match (as well as the extension). -
setMatcher
A secondary matcher, which is required additionally match (as well as the extension). -
getExtensions
A set of file-extensions (without the period), one of which must match the end of a path.If an empty set is passed then, no check occurs, and no extension is checked.
-
setExtensions
A set of file-extensions (without the period), one of which must match the end of a path.If an empty set is passed then, no check occurs, and no extension is checked.
-
isPrioritizeInputContext
public boolean isPrioritizeInputContext()When true, any extensions available in the input-context are prioritized ahead ofextensions
. -
setPrioritizeInputContext
public void setPrioritizeInputContext(boolean prioritizeInputContext) When true, any extensions available in the input-context are prioritized ahead ofextensions
.
-