Package io.debezium.function
Class Predicates
java.lang.Object
io.debezium.function.Predicates
Utilities for constructing various predicates.
- Author:
- Randall Hauch
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGenerate 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>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.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.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>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) 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>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.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.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.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) matchedByPattern(Collection<Pattern> patterns, Function<T, String> conversion) static <R> Predicate<R>static <T> Predicate<T>notNull()
-
Field Details
-
LITERAL_SEPARATOR_PATTERN
-
-
Constructor Details
-
Predicates
private Predicates()
-
-
Method Details
-
includesUuids
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
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
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
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
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
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
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
-
includes
-
excludes
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
-
excludes
-
includes
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
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
-
matchedByPattern
protected static <T,U> BiFunction<T,U, matchedByPatternOptional<Pattern>> (Collection<Pattern> patterns, BiFunction<T, U, String> conversion) -
includedInLiterals
protected static <T> Predicate<T> includedInLiterals(Collection<String> literals, Function<T, String> conversion) -
excludes
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
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
-
not
-
notNull
-