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 FilePredicateall()Returns a predicate that always evaluates to trueFilePredicateand(java.util.Collection<FilePredicate> and)FilePredicateand(FilePredicate... and)FilePredicateand(FilePredicate first, FilePredicate second)FilePredicatedoesNotMatchPathPattern(java.lang.String exclusionPattern)Predicate that gets the files that do not match the given wildcard pattern.FilePredicatedoesNotMatchPathPatterns(java.lang.String[] exclusionPatterns)Predicate that gets the files that do not match any of the given wildcard patterns.FilePredicatehasAbsolutePath(java.lang.String s)Predicate that find file by its absolute path.FilePredicatehasAnyStatus()Explicitely look for InputFile having anyInputFile.status()FilePredicatehasExtension(java.lang.String s)Predicate that matches files by extension (case insensitive).FilePredicatehasFilename(java.lang.String s)Predicate that matches files by filename, in any directory.FilePredicatehasLanguage(java.lang.String language)FilePredicatehasLanguages(java.lang.String... languages)FilePredicatehasLanguages(java.util.Collection<java.lang.String> languages)FilePredicatehasPath(java.lang.String s)if the parameter represents an absolute path for the running environment, then returnsFilePredicates.hasAbsolutePath(String), elseFilePredicates.hasRelativePath(String)FilePredicatehasRelativePath(java.lang.String s)non-normalized path and Windows-style path are supportedFilePredicatehasStatus(InputFile.Status status)Look for InputFile having a specificInputFile.status()FilePredicatehasType(InputFile.Type type)FilePredicatehasURI(java.net.URI uri)Predicate that gets a file by itsIndexedFile.uri().FilePredicateis(java.io.File ioFile)Warning - may not be supported in SonarLintFilePredicatematchesPathPattern(java.lang.String inclusionPattern)Predicate that gets the files which "path" matches a wildcard pattern.FilePredicatematchesPathPatterns(java.lang.String[] inclusionPatterns)Predicate that gets the files matching at least one wildcard pattern.FilePredicatenone()Returns a predicate that always evaluates to falseFilePredicatenot(FilePredicate p)FilePredicateor(java.util.Collection<FilePredicate> or)FilePredicateor(FilePredicate... or)FilePredicateor(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:
allin interfaceFilePredicates
-
none
public FilePredicate none()
Returns a predicate that always evaluates to false- Specified by:
nonein interfaceFilePredicates
-
hasAbsolutePath
public FilePredicate hasAbsolutePath(java.lang.String s)
Description copied from interface:FilePredicatesPredicate that find file by its absolute path. The parameter accepts forward/back slashes as separator and non-normalized values (/path/to/../foo.txtis same as/path/foo.txt).Warning - may not be supported in SonarLint
- Specified by:
hasAbsolutePathin interfaceFilePredicates
-
hasRelativePath
public FilePredicate hasRelativePath(java.lang.String s)
non-normalized path and Windows-style path are supported- Specified by:
hasRelativePathin interfaceFilePredicates
-
hasFilename
public FilePredicate hasFilename(java.lang.String s)
Description copied from interface:FilePredicatesPredicate that matches files by filename, in any directory. For example, the parameterFoo.javawill match bothsome/path/Foo.javaandother/path/Foo.java. The parameter must match exactly, no patterns are allowed, and it must not benull.- Specified by:
hasFilenamein interfaceFilePredicates
-
hasExtension
public FilePredicate hasExtension(java.lang.String s)
Description copied from interface:FilePredicatesPredicate that matches files by extension (case insensitive). For example, the parameterjavawill matchsome/path/Foo.javaandother/path/Foo.JAVAbut notsome/path/Foo.js. The parameter must not benull.- Specified by:
hasExtensionin interfaceFilePredicates
-
hasURI
public FilePredicate hasURI(java.net.URI uri)
Description copied from interface:FilePredicatesPredicate that gets a file by itsIndexedFile.uri().- Specified by:
hasURIin interfaceFilePredicates
-
matchesPathPattern
public FilePredicate matchesPathPattern(java.lang.String inclusionPattern)
Description copied from interface:FilePredicatesPredicate 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.javamatches Foo.java, src/Foo.java and src/java/SuperFoo.java**/*Foo*.javamatches src/Foo.java, src/BarFoo.java, src/FooBar.java and src/BarFooBaz.java**/*FOO.JAVAmatches FOO.java and FOO.JAVA but not Foo.java
- Specified by:
matchesPathPatternin interfaceFilePredicates
-
matchesPathPatterns
public FilePredicate matchesPathPatterns(java.lang.String[] inclusionPatterns)
Description copied from interface:FilePredicatesPredicate that gets the files matching at least one wildcard pattern. No filter is applied when zero wildcard patterns (similar toFilePredicates.all().- Specified by:
matchesPathPatternsin interfaceFilePredicates- See Also:
FilePredicates.matchesPathPattern(String)
-
doesNotMatchPathPattern
public FilePredicate doesNotMatchPathPattern(java.lang.String exclusionPattern)
Description copied from interface:FilePredicatesPredicate that gets the files that do not match the given wildcard pattern.- Specified by:
doesNotMatchPathPatternin interfaceFilePredicates- See Also:
FilePredicates.matchesPathPattern(String)
-
doesNotMatchPathPatterns
public FilePredicate doesNotMatchPathPatterns(java.lang.String[] exclusionPatterns)
Description copied from interface:FilePredicatesPredicate 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:
doesNotMatchPathPatternsin interfaceFilePredicates- See Also:
FilePredicates.matchesPathPattern(String)
-
hasPath
public FilePredicate hasPath(java.lang.String s)
Description copied from interface:FilePredicatesif 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:
hasPathin interfaceFilePredicates
-
is
public FilePredicate is(java.io.File ioFile)
Description copied from interface:FilePredicatesWarning - may not be supported in SonarLint- Specified by:
isin interfaceFilePredicates
-
hasLanguage
public FilePredicate hasLanguage(java.lang.String language)
- Specified by:
hasLanguagein interfaceFilePredicates
-
hasLanguages
public FilePredicate hasLanguages(java.util.Collection<java.lang.String> languages)
- Specified by:
hasLanguagesin interfaceFilePredicates
-
hasLanguages
public FilePredicate hasLanguages(java.lang.String... languages)
- Specified by:
hasLanguagesin interfaceFilePredicates
-
hasType
public FilePredicate hasType(InputFile.Type type)
- Specified by:
hasTypein interfaceFilePredicates
-
not
public FilePredicate not(FilePredicate p)
- Specified by:
notin interfaceFilePredicates
-
or
public FilePredicate or(java.util.Collection<FilePredicate> or)
- Specified by:
orin interfaceFilePredicates
-
or
public FilePredicate or(FilePredicate... or)
- Specified by:
orin interfaceFilePredicates
-
or
public FilePredicate or(FilePredicate first, FilePredicate second)
- Specified by:
orin interfaceFilePredicates
-
and
public FilePredicate and(java.util.Collection<FilePredicate> and)
- Specified by:
andin interfaceFilePredicates
-
and
public FilePredicate and(FilePredicate... and)
- Specified by:
andin interfaceFilePredicates
-
and
public FilePredicate and(FilePredicate first, FilePredicate second)
- Specified by:
andin interfaceFilePredicates
-
hasStatus
public FilePredicate hasStatus(InputFile.Status status)
Description copied from interface:FilePredicatesLook for InputFile having a specificInputFile.status()- Specified by:
hasStatusin interfaceFilePredicates
-
hasAnyStatus
public FilePredicate hasAnyStatus()
Description copied from interface:FilePredicatesExplicitely look for InputFile having anyInputFile.status()- Specified by:
hasAnyStatusin interfaceFilePredicates
-
-