Package io.debezium.function
Class Predicates
- java.lang.Object
-
- io.debezium.function.Predicates
-
public class Predicates extends Object
Utilities for constructing various predicates.- Author:
- Randall Hauch
-
-
Field Summary
Fields Modifier and Type Field Description private static PatternLITERAL_SEPARATOR_PATTERN
-
Constructor Summary
Constructors Modifier Constructor Description privatePredicates()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Predicate<String>excludes(String regexPatterns)Generate a predicate function that for any supplied string returnstrueif none of the regular expressions in the supplied comma-separated list matches the predicate parameter.static <T> Predicate<T>excludes(String regexPatterns, Function<T,String> conversion)Generate a predicate function that for any supplied parameter returnstrueif none of the regular expressions in the supplied comma-separated list matches the predicate parameter.static Predicate<String>excludesLiterals(String literals)Generate a predicate function that for any supplied string returnstrueif none of the literals in the supplied comma-separated list case insensitively matches the predicate parameter.static <T> Predicate<T>excludesLiterals(String literals, Function<T,String> conversion)Generate a predicate function that for any supplied string returnstrueif none of the literals in the supplied comma-separated list case insensitively matches the predicate parameter.static <T> Predicate<T>excludesLiteralsOrPatterns(String patterns, Predicate<String> isLiteral, Function<T,String> conversion)Generate a predicate function that for any supplied string returnstrueif none of the regular expressions or literals in the supplied comma-separated list matches the predicate parameter.static Predicate<String>excludesUuids(String uuidPatterns)Generate a predicate function that for any supplied string returnstrueif none of the regular expressions or literals in the supplied comma-separated list matches the predicate parameter.static <T> Predicate<T>filter(Predicate<T> allowed, Predicate<T> disallowed)Create a predicate function that allows only those values are allowed or not disallowed by the supplied predicates.protected static <T> Predicate<T>includedInLiterals(Collection<String> literals, Function<T,String> conversion)protected static <T,U>
BiPredicate<T,U>includedInPatterns(Collection<Pattern> patterns, BiFunction<T,U,String> conversion)protected static <T> Predicate<T>includedInPatterns(Collection<Pattern> patterns, Function<T,String> conversion)static Predicate<String>includes(String regexPatterns)Generate a predicate function that for any supplied string returnstrueif any of the regular expressions in the supplied comma-separated list matches the predicate parameter.static <T,U>
BiPredicate<T,U>includes(String regexPatterns, BiFunction<T,U,String> conversion)static <T> Predicate<T>includes(String regexPatterns, Function<T,String> conversion)Generate a predicate function that for any supplied parameter returnstrueif any of the regular expressions in the supplied comma-separated list matches the predicate parameter in a case-insensitive manner.static Predicate<String>includesLiterals(String literals)Generate a predicate function that for any supplied string returnstrueif any of the literals in the supplied comma-separated list case insensitively matches the predicate parameter.static <T> Predicate<T>includesLiterals(String literals, Function<T,String> conversion)Generate a predicate function that for any supplied string returnstrueif any of the literals in the supplied comma-separated list case insensitively matches the predicate parameter.static <T> Predicate<T>includesLiteralsOrPatterns(String literalsOrPatterns, Predicate<String> isLiteral, Function<T,String> conversion)Generate a predicate function that for any supplied string returnstrueif any of the regular expressions or literals in the supplied comma-separated list matches the predicate parameter.static Predicate<String>includesUuids(String uuidPatterns)Generate a predicate function that for any supplied UUID strings returnstrueif any of the comma-separated UUID literals or regular expressions matches the predicate parameter.static Function<String,Optional<Pattern>>matchedBy(String regexPatterns)Generate a predicate function that for any supplied string returns aPatternrepresenting the first regular expression in the supplied comma-separated list that matches the predicate parameter in a case-insensitive manner.protected static <T,U>
BiFunction<T,U,Optional<Pattern>>matchedByPattern(Collection<Pattern> patterns, BiFunction<T,U,String> conversion)protected static <T> Function<T,Optional<Pattern>>matchedByPattern(Collection<Pattern> patterns, Function<T,String> conversion)static <R> Predicate<R>not(Predicate<R> predicate)static <T> Predicate<T>notNull()
-
-
-
Field Detail
-
LITERAL_SEPARATOR_PATTERN
private static final Pattern LITERAL_SEPARATOR_PATTERN
-
-
Method Detail
-
includesUuids
public static Predicate<String> includesUuids(String uuidPatterns)
Generate a predicate function that for any supplied UUID strings returnstrueif any of the comma-separated UUID literals or regular expressions matches the predicate parameter. This supplied strings can be a mixture of regular expressions and UUID literals, and the most efficient method will be used for each.- Parameters:
uuidPatterns- the comma-separated UUID literals or regular expression patterns; may not be null- Returns:
- the predicate function that performs the matching
- Throws:
PatternSyntaxException- if the string includes an invalid regular expression
-
excludesUuids
public static Predicate<String> excludesUuids(String uuidPatterns)
Generate a predicate function that for any supplied string returnstrueif none of the regular expressions or literals in the supplied comma-separated list matches the predicate parameter. This supplied strings can be a mixture of regular expressions and UUID literals, and the most efficient method will be used for each.- Parameters:
uuidPatterns- the comma-separated regular expression pattern (or literal) strings; may not be null- Returns:
- the predicate function that performs the matching
- Throws:
PatternSyntaxException- if the string includes an invalid regular expression
-
includesLiteralsOrPatterns
public static <T> Predicate<T> includesLiteralsOrPatterns(String literalsOrPatterns, Predicate<String> isLiteral, Function<T,String> conversion)
Generate a predicate function that for any supplied string returnstrueif any of the regular expressions or literals in the supplied comma-separated list matches the predicate parameter. This supplied strings can be a mixture of regular expressions and literals, and the most efficient method will be used for each.- Parameters:
literalsOrPatterns- the comma-separated regular expression pattern (or literal) strings; may not be nullisLiteral- function that determines if a given pattern is a literal string; may not be nullconversion- the function that converts each predicate-supplied value to a string that can be matched against the regular expressions; may not be null- Returns:
- the predicate function that performs the matching
- Throws:
PatternSyntaxException- if the string includes an invalid regular expression
-
excludesLiteralsOrPatterns
public static <T> Predicate<T> excludesLiteralsOrPatterns(String patterns, Predicate<String> isLiteral, Function<T,String> conversion)
Generate a predicate function that for any supplied string returnstrueif none of the regular expressions or literals in the supplied comma-separated list matches the predicate parameter. This supplied strings can be a mixture of regular expressions and literals, and the most efficient method will be used for each.- Parameters:
patterns- the comma-separated regular expression pattern (or literal) strings; may not be nullisLiteral- function that determines if a given pattern is a literal string; may not be nullconversion- the function that converts each predicate-supplied value to a string that can be matched against the regular expressions; may not be null- Returns:
- the predicate function that performs the matching
- Throws:
PatternSyntaxException- if the string includes an invalid regular expression
-
includesLiterals
public static Predicate<String> includesLiterals(String literals)
Generate a predicate function that for any supplied string returnstrueif any of the literals in the supplied comma-separated list case insensitively matches the predicate parameter.- Parameters:
literals- the comma-separated literal strings; may not be null- Returns:
- the predicate function that performs the matching
-
excludesLiterals
public static Predicate<String> excludesLiterals(String literals)
Generate a predicate function that for any supplied string returnstrueif none of the literals in the supplied comma-separated list case insensitively matches the predicate parameter.- Parameters:
literals- the comma-separated literal strings; may not be null- Returns:
- the predicate function that performs the matching
-
includesLiterals
public static <T> Predicate<T> includesLiterals(String literals, Function<T,String> conversion)
Generate a predicate function that for any supplied string returnstrueif any of the literals in the supplied comma-separated list case insensitively matches the predicate parameter.- Parameters:
literals- the comma-separated literal strings; may not be nullconversion- the function that converts each predicate-supplied value to a string that can be matched against the regular expressions; may not be null- Returns:
- the predicate function that performs the matching
-
excludesLiterals
public static <T> Predicate<T> excludesLiterals(String literals, Function<T,String> conversion)
Generate a predicate function that for any supplied string returnstrueif none of the literals in the supplied comma-separated list case insensitively matches the predicate parameter.- Parameters:
literals- the comma-separated literal strings; may not be nullconversion- the function that converts each predicate-supplied value to a string that can be matched against the regular expressions; may not be null- Returns:
- the predicate function that performs the matching
-
includes
public static Predicate<String> includes(String regexPatterns)
Generate a predicate function that for any supplied string returnstrueif any of the regular expressions in the supplied comma-separated list matches the predicate parameter.- Parameters:
regexPatterns- the comma-separated regular expression pattern (or literal) strings; may not be null- Returns:
- the predicate function that performs the matching
- Throws:
PatternSyntaxException- if the string includes an invalid regular expression
-
excludes
public static Predicate<String> excludes(String regexPatterns)
Generate a predicate function that for any supplied string returnstrueif none of the regular expressions in the supplied comma-separated list matches the predicate parameter.- Parameters:
regexPatterns- the comma-separated regular expression pattern (or literal) strings; may not be null- Returns:
- the predicate function that performs the matching
- Throws:
PatternSyntaxException- if the string includes an invalid regular expression
-
includes
public static <T> Predicate<T> includes(String regexPatterns, Function<T,String> conversion)
Generate a predicate function that for any supplied parameter returnstrueif any of the regular expressions in the supplied comma-separated list matches the predicate parameter in a case-insensitive manner.- Parameters:
regexPatterns- the comma-separated regular expression pattern (or literal) strings; may not be nullconversion- the function that converts each predicate-supplied value to a string that can be matched against the regular expressions; may not be null- Returns:
- the predicate function that performs the matching
- Throws:
PatternSyntaxException- if the string includes an invalid regular expression
-
includes
public static <T,U> BiPredicate<T,U> includes(String regexPatterns, BiFunction<T,U,String> conversion)
-
includedInPatterns
protected static <T> Predicate<T> includedInPatterns(Collection<Pattern> patterns, Function<T,String> conversion)
-
includedInPatterns
protected static <T,U> BiPredicate<T,U> includedInPatterns(Collection<Pattern> patterns, BiFunction<T,U,String> conversion)
-
matchedBy
public static Function<String,Optional<Pattern>> matchedBy(String regexPatterns)
Generate a predicate function that for any supplied string returns aPatternrepresenting the first regular expression in the supplied comma-separated list that matches the predicate parameter in a case-insensitive manner.- Parameters:
regexPatterns- the comma-separated regular expression pattern (or literal) strings; may not be null- Returns:
- the function that performs the matching
- Throws:
PatternSyntaxException- if the string includes an invalid regular expression
-
matchedByPattern
protected static <T> Function<T,Optional<Pattern>> matchedByPattern(Collection<Pattern> patterns, Function<T,String> conversion)
-
matchedByPattern
protected static <T,U> BiFunction<T,U,Optional<Pattern>> matchedByPattern(Collection<Pattern> patterns, BiFunction<T,U,String> conversion)
-
includedInLiterals
protected static <T> Predicate<T> includedInLiterals(Collection<String> literals, Function<T,String> conversion)
-
excludes
public static <T> Predicate<T> excludes(String regexPatterns, Function<T,String> conversion)
Generate a predicate function that for any supplied parameter returnstrueif none of the regular expressions in the supplied comma-separated list matches the predicate parameter.- Parameters:
regexPatterns- the comma-separated regular expression pattern (or literal) strings; may not be nullconversion- the function that converts each predicate-supplied value to a string that can be matched against the regular expressions; may not be null- Returns:
- the predicate function that performs the matching
- Throws:
PatternSyntaxException- if the string includes an invalid regular expression
-
filter
public static <T> Predicate<T> filter(Predicate<T> allowed, Predicate<T> disallowed)
Create a predicate function that allows only those values are allowed or not disallowed by the supplied predicates.- Parameters:
allowed- the predicate that defines the allowed values; may be nulldisallowed- the predicate that defines the disallowed values; may be null- Returns:
- the predicate function; never null
-
notNull
public static <T> Predicate<T> notNull()
-
-