Class PredicateUtil
- java.lang.Object
-
- net.sourceforge.pmd.internal.util.PredicateUtil
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Predicate<T>
always()
A predicate that always returns true.static Predicate<String>
buildRegexFilterIncludeOverExclude(@NonNull Collection<Pattern> includeRegexes, @NonNull Collection<Pattern> excludeRegexes)
Builds a string filter using a set of include and exclude regular expressions.static Predicate<String>
getFileExtensionFilter(String... extensions)
Returns a case-insensitive predicate for files with the given extensions.static <T> Predicate<T>
never()
A predicate that always returns false.static Predicate<String>
toNormalizedFileFilter(Predicate<? super String> filter)
Returns a predicate that tests if the name of a file matches the given string filter.
-
-
-
Method Detail
-
never
public static <T> Predicate<T> never()
A predicate that always returns false.
-
always
public static <T> Predicate<T> always()
A predicate that always returns true.
-
getFileExtensionFilter
public static Predicate<String> getFileExtensionFilter(String... extensions)
Returns a case-insensitive predicate for files with the given extensions.- Throws:
NullPointerException
- If the extensions array is null
-
toNormalizedFileFilter
public static Predicate<String> toNormalizedFileFilter(Predicate<? super String> filter)
Returns a predicate that tests if the name of a file matches the given string filter. The returned predicate normalizes backslashes ('\'
) to'/'
to be more easily cross-platform.- Parameters:
filter
- A predicate on the file name- Returns:
- A predicate on files
-
buildRegexFilterIncludeOverExclude
public static Predicate<String> buildRegexFilterIncludeOverExclude(@NonNull Collection<Pattern> includeRegexes, @NonNull Collection<Pattern> excludeRegexes)
Builds a string filter using a set of include and exclude regular expressions. A string S matches the predicate if either- 1. no exclude regex matches S, or
- 2. some include regex matches S
- Parameters:
includeRegexes
- Regular expressions overriding the excludes.excludeRegexes
- Regular expressions filtering strings out.- Returns:
- A predicate for strings.
-
-