Package org.sonar.api.batch.fs.internal
Class DefaultFilePredicates
- java.lang.Object
-
- org.sonar.api.batch.fs.internal.DefaultFilePredicates
-
- All Implemented Interfaces:
FilePredicates
public class DefaultFilePredicates extends java.lang.Object implements FilePredicates
Factory ofFilePredicate
- Since:
- 4.2
-
-
Constructor Summary
Constructors Constructor Description DefaultFilePredicates(java.nio.file.Path baseDir)
Client code should useFileSystem.predicates()
to get an instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FilePredicate
all()
Returns a predicate that always evaluates to trueFilePredicate
and(java.util.Collection<FilePredicate> and)
FilePredicate
and(FilePredicate... and)
FilePredicate
and(FilePredicate first, FilePredicate second)
FilePredicate
doesNotMatchPathPattern(java.lang.String exclusionPattern)
Predicate that gets the files that do not match the given wildcard pattern.FilePredicate
doesNotMatchPathPatterns(java.lang.String[] exclusionPatterns)
Predicate that gets the files that do not match any of the given wildcard patterns.FilePredicate
hasAbsolutePath(java.lang.String s)
Predicate that find file by its absolute path.FilePredicate
hasAnyStatus()
Explicitely look for InputFile having anyInputFile.status()
FilePredicate
hasExtension(java.lang.String s)
Predicate that matches files by extension (case insensitive).FilePredicate
hasFilename(java.lang.String s)
Predicate that matches files by filename, in any directory.FilePredicate
hasLanguage(java.lang.String language)
FilePredicate
hasLanguages(java.lang.String... languages)
FilePredicate
hasLanguages(java.util.Collection<java.lang.String> languages)
FilePredicate
hasPath(java.lang.String s)
if the parameter represents an absolute path for the running environment, then returnsFilePredicates.hasAbsolutePath(String)
, elseFilePredicates.hasRelativePath(String)
FilePredicate
hasRelativePath(java.lang.String s)
non-normalized path and Windows-style path are supportedFilePredicate
hasStatus(InputFile.Status status)
Look for InputFile having a specificInputFile.status()
FilePredicate
hasType(InputFile.Type type)
FilePredicate
hasURI(java.net.URI uri)
Predicate that gets a file by itsIndexedFile.uri()
.FilePredicate
is(java.io.File ioFile)
Warning - may not be supported in SonarLintFilePredicate
matchesPathPattern(java.lang.String inclusionPattern)
Predicate that gets the files which "path" matches a wildcard pattern.FilePredicate
matchesPathPatterns(java.lang.String[] inclusionPatterns)
Predicate that gets the files matching at least one wildcard pattern.FilePredicate
none()
Returns a predicate that always evaluates to falseFilePredicate
not(FilePredicate p)
FilePredicate
or(java.util.Collection<FilePredicate> or)
FilePredicate
or(FilePredicate... or)
FilePredicate
or(FilePredicate first, FilePredicate second)
-
-
-
Constructor Detail
-
DefaultFilePredicates
public DefaultFilePredicates(java.nio.file.Path baseDir)
Client code should useFileSystem.predicates()
to get an instance
-
-
Method Detail
-
all
public FilePredicate all()
Returns a predicate that always evaluates to true- Specified by:
all
in interfaceFilePredicates
-
none
public FilePredicate none()
Returns a predicate that always evaluates to false- Specified by:
none
in interfaceFilePredicates
-
hasAbsolutePath
public FilePredicate hasAbsolutePath(java.lang.String s)
Description copied from interface:FilePredicates
Predicate that find file by its absolute path. The parameter accepts forward/back slashes as separator and non-normalized values (/path/to/../foo.txt
is same as/path/foo.txt
).Warning - may not be supported in SonarLint
- Specified by:
hasAbsolutePath
in interfaceFilePredicates
-
hasRelativePath
public FilePredicate hasRelativePath(java.lang.String s)
non-normalized path and Windows-style path are supported- Specified by:
hasRelativePath
in interfaceFilePredicates
-
hasFilename
public FilePredicate hasFilename(java.lang.String s)
Description copied from interface:FilePredicates
Predicate that matches files by filename, in any directory. For example, the parameterFoo.java
will match bothsome/path/Foo.java
andother/path/Foo.java
. The parameter must match exactly, no patterns are allowed, and it must not benull
.- Specified by:
hasFilename
in interfaceFilePredicates
-
hasExtension
public FilePredicate hasExtension(java.lang.String s)
Description copied from interface:FilePredicates
Predicate that matches files by extension (case insensitive). For example, the parameterjava
will matchsome/path/Foo.java
andother/path/Foo.JAVA
but notsome/path/Foo.js
. The parameter must not benull
.- Specified by:
hasExtension
in interfaceFilePredicates
-
hasURI
public FilePredicate hasURI(java.net.URI uri)
Description copied from interface:FilePredicates
Predicate that gets a file by itsIndexedFile.uri()
.- Specified by:
hasURI
in interfaceFilePredicates
-
matchesPathPattern
public FilePredicate matchesPathPattern(java.lang.String inclusionPattern)
Description copied from interface:FilePredicates
Predicate that gets the files which "path" matches a wildcard pattern.The path is the path part of the
IndexedFile.uri()
. Pattern is case-sensitive, except for file extension.Supported wildcards are
*
and**
, but not?
.
Examples:**/*Foo.java
matches Foo.java, src/Foo.java and src/java/SuperFoo.java**/*Foo*.java
matches src/Foo.java, src/BarFoo.java, src/FooBar.java and src/BarFooBaz.java**/*FOO.JAVA
matches FOO.java and FOO.JAVA but not Foo.java
- Specified by:
matchesPathPattern
in interfaceFilePredicates
-
matchesPathPatterns
public FilePredicate matchesPathPatterns(java.lang.String[] inclusionPatterns)
Description copied from interface:FilePredicates
Predicate that gets the files matching at least one wildcard pattern. No filter is applied when zero wildcard patterns (similar toFilePredicates.all()
.- Specified by:
matchesPathPatterns
in interfaceFilePredicates
- See Also:
FilePredicates.matchesPathPattern(String)
-
doesNotMatchPathPattern
public FilePredicate doesNotMatchPathPattern(java.lang.String exclusionPattern)
Description copied from interface:FilePredicates
Predicate that gets the files that do not match the given wildcard pattern.- Specified by:
doesNotMatchPathPattern
in interfaceFilePredicates
- See Also:
FilePredicates.matchesPathPattern(String)
-
doesNotMatchPathPatterns
public FilePredicate doesNotMatchPathPatterns(java.lang.String[] exclusionPatterns)
Description copied from interface:FilePredicates
Predicate that gets the files that do not match any of the given wildcard patterns. No filter is applied when zero wildcard patterns (similar toFilePredicates.all()
.- Specified by:
doesNotMatchPathPatterns
in interfaceFilePredicates
- See Also:
FilePredicates.matchesPathPattern(String)
-
hasPath
public FilePredicate hasPath(java.lang.String s)
Description copied from interface:FilePredicates
if the parameter represents an absolute path for the running environment, then returnsFilePredicates.hasAbsolutePath(String)
, elseFilePredicates.hasRelativePath(String)
Warning - may not be supported in SonarLint
- Specified by:
hasPath
in interfaceFilePredicates
-
is
public FilePredicate is(java.io.File ioFile)
Description copied from interface:FilePredicates
Warning - may not be supported in SonarLint- Specified by:
is
in interfaceFilePredicates
-
hasLanguage
public FilePredicate hasLanguage(java.lang.String language)
- Specified by:
hasLanguage
in interfaceFilePredicates
-
hasLanguages
public FilePredicate hasLanguages(java.util.Collection<java.lang.String> languages)
- Specified by:
hasLanguages
in interfaceFilePredicates
-
hasLanguages
public FilePredicate hasLanguages(java.lang.String... languages)
- Specified by:
hasLanguages
in interfaceFilePredicates
-
hasType
public FilePredicate hasType(InputFile.Type type)
- Specified by:
hasType
in interfaceFilePredicates
-
not
public FilePredicate not(FilePredicate p)
- Specified by:
not
in interfaceFilePredicates
-
or
public FilePredicate or(java.util.Collection<FilePredicate> or)
- Specified by:
or
in interfaceFilePredicates
-
or
public FilePredicate or(FilePredicate... or)
- Specified by:
or
in interfaceFilePredicates
-
or
public FilePredicate or(FilePredicate first, FilePredicate second)
- Specified by:
or
in interfaceFilePredicates
-
and
public FilePredicate and(java.util.Collection<FilePredicate> and)
- Specified by:
and
in interfaceFilePredicates
-
and
public FilePredicate and(FilePredicate... and)
- Specified by:
and
in interfaceFilePredicates
-
and
public FilePredicate and(FilePredicate first, FilePredicate second)
- Specified by:
and
in interfaceFilePredicates
-
hasStatus
public FilePredicate hasStatus(InputFile.Status status)
Description copied from interface:FilePredicates
Look for InputFile having a specificInputFile.status()
- Specified by:
hasStatus
in interfaceFilePredicates
-
hasAnyStatus
public FilePredicate hasAnyStatus()
Description copied from interface:FilePredicates
Explicitely look for InputFile having anyInputFile.status()
- Specified by:
hasAnyStatus
in interfaceFilePredicates
-
-