java.lang.Object
com.pervasive.datarush.functions.Predicates
Provides implementations of common boolean and logical functions.
These functions can also be combined to construct more complex predicates.
Most predicate functions follow three-valued logic (true, false, null)
except where otherwise noted.
- See Also:
-
ScalarValuedFunctionDeriveFieldsFilterRows
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ScalarValuedFunctionand(ScalarValuedFunction... ps) Builds a record predicate which is a logical and of the specified predicates.static ScalarValuedFunctionand(List<ScalarValuedFunction> ps) Builds a record predicate which is a logical and of the specified predicates.static ScalarValuedFunctioneq(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests the equality of the specified expressions.static ScalarValuedFunctioneq(String field, ScalarValued value) Builds a record predicate which tests the equality of the specified field with a known value.static ScalarValuedFunctionBuilds a record predicate which tests the equality of the specified fields.static List<ScalarValuedFunction>Extracts the predicate clauses from an AND or OR predicate.static ScalarValuedFunctiongt(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests whether a specified expression is strictly greater than another.static ScalarValuedFunctiongt(String leftField, ScalarValued rightValue) Builds a record predicate which tests whether a field is strictly greater than a known value.static ScalarValuedFunctionBuilds a record predicate which tests whether a field is strictly greater than another field.static ScalarValuedFunctiongte(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests whether a specified expression is greater than or equal to another.static ScalarValuedFunctiongte(String leftField, ScalarValued rightValue) Builds a record predicate which tests whether a field is greater than or equal to a known value.static ScalarValuedFunctionBuilds a record predicate which tests whether a field is greater than or equal to another field.static booleanTests whether the specified function is an AND predicate.static booleanTests whether the specified function is an OR predicate.static ScalarValuedFunctionBuilds a record predicate which tests whether the specified predicate is false.static ScalarValuedFunctionisNull(ScalarValuedFunction expr) Builds a record predicate which tests whether the specified expression evaluates tonull.static ScalarValuedFunctionBuilds a record predicate which tests whether a record field is null-valued.static ScalarValuedFunctionBuilds a record predicate which tests whether the specified predicate is true.static ScalarValuedFunctionlike(ScalarValuedFunction expr, String pattern) Builds a record predicate which tests whether the value of an expression matches a specified SQL LIKE pattern.static ScalarValuedFunctionBuilds a record predicate which tests whether the value of a field matches a specified SQL LIKE pattern.static StringlikeToRegex(String likePattern) Converts a SQL LIKE pattern into an equivalent regular expression.static ScalarValuedFunctionlt(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests whether a specified expression is strictly less than another.static ScalarValuedFunctionlt(String leftField, ScalarValued rightValue) Builds a record predicate which tests whether a field is strictly less than a known value.static ScalarValuedFunctionBuilds a record predicate which tests whether a field is strictly less than another field.static ScalarValuedFunctionlte(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests whether a specified expression is less than or equal to another.static ScalarValuedFunctionlte(String leftField, ScalarValued rightValue) Builds a record predicate which tests whether a field is less than or equal to a known value.static ScalarValuedFunctionBuilds a record predicate which tests whether a field is less than or equal to another field.static ScalarValuedFunctionmatches(ScalarValuedFunction expr, String pattern) Builds a record predicate which tests whether the value of an expression matches a specified regular expression.static ScalarValuedFunctionBuilds a record predicate which tests whether the value of a field matches a specified regular expression.static ScalarValuedFunctionneq(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests the inequality of the specified expressions.static ScalarValuedFunctionneq(String field, ScalarValued value) Builds a record predicate which tests the inequality of the specified field with a known value.static ScalarValuedFunctionBuilds a record predicate which tests the inequality of the specified fields.static ScalarValuedFunctionBuilds a record predicate which is a logical negation of specified predicate.static ScalarValuedFunctionBuilds a record predicate which tests whether the specified predicate is not false.static ScalarValuedFunctionnotNull(ScalarValuedFunction expr) Builds a record predicate which tests whether the specified expression does not evaluate tonull.static ScalarValuedFunctionBuilds a record predicate which tests whether a record field is not null-valued.static ScalarValuedFunctionBuilds a record predicate which tests whether the specified predicate is not true.static ScalarValuedFunctionor(ScalarValuedFunction... ps) Builds a record predicate which is a logical or of the specified predicates.static ScalarValuedFunctionor(List<ScalarValuedFunction> ps) Builds a record predicate which is a logical or of the specified predicates.
-
Constructor Details
-
Predicates
public Predicates()
-
-
Method Details
-
isConjunction
Tests whether the specified function is an AND predicate.- Parameters:
f- the function to test- Returns:
trueif the function is an AND;falseotherwise- See Also:
-
isDisjunction
Tests whether the specified function is an OR predicate.- Parameters:
f- the function to test- Returns:
trueif the function is an OR;falseotherwise- See Also:
-
getPredicateClauses
Extracts the predicate clauses from an AND or OR predicate.- Parameters:
p- the predicate to break into constituent clauses- Returns:
- the subexpressions defining the clauses of the predicate
- Throws:
IllegalArgumentException- if the predicate is not an AND or an OR- See Also:
-
and
Builds a record predicate which is a logical and of the specified predicates. The resulting predicate evaluates to:trueif all subpredicates evaluate totrue.falseif any subpredicate evaluates tofalse.nullotherwise
This version of
andis provided for use in a fluent style with other static methods producingRecordPredicateobjects, as illustrated by the following code fragment:
and(eq("field1", "field2"),gt("field1","field3"))- Parameters:
ps- the predicates to be combined- Returns:
- a new predicate evaluating to an and of the predicates under three-valued logic
-
and
Builds a record predicate which is a logical and of the specified predicates. The resulting predicate evaluates to:trueif all subpredicates evaluate totrue.falseif any subpredicate evaluates tofalse.nullotherwise
- Parameters:
ps- the predicates to be combined- Returns:
- a new predicate evaluating to an and of the predicates under three-valued logic
-
or
Builds a record predicate which is a logical or of the specified predicates. The resulting predicate evaluates totrueif any subpredicate evaluates totrue.falseif all subpredicates evaluate tofalse.nullotherwise
This version of
oris provided for use in a fluent style with other static methods producingRecordPredicateobjects, as illustrated by the following code fragment:
or(eq("field1", "field2"),gt("field1","field3"))- Parameters:
ps- the predicates to be combined- Returns:
- a new predicate evaluating to an or of the predicates under three-valued logic
-
or
Builds a record predicate which is a logical or of the specified predicates. The resulting predicate evaluates totrueif any subpredicate evaluates totrue.falseif all subpredicates evaluate tofalse.nullotherwise
- Parameters:
ps- the predicates to be combined- Returns:
- a new predicate evaluating to an or of the predicates under three-valued logic
-
not
Builds a record predicate which is a logical negation of specified predicate. The resulting predicate evaluates totrueif the given predicate evaluates tofalse.falseif the given predicate evaluates totrue.nullotherwise
- Parameters:
p- the predicates to be negated- Returns:
- a new predicate evaluating to a negation of the predicate under three-valued logic
-
isTrue
Builds a record predicate which tests whether the specified predicate is true. The resulting predicate evaluates totrueif the given predicate evaluates totrue.falseotherwise
- Parameters:
p- the predicate to be tested- Returns:
- a new predicate evaluating to a check of the truth of the predicate
-
notTrue
Builds a record predicate which tests whether the specified predicate is not true. The resulting predicate evaluates tofalseif the given predicate evaluates totrue.trueotherwise
- Parameters:
p- the predicate to be tested- Returns:
- a new predicate evaluating to a check of the non-truth of the predicate
-
isFalse
Builds a record predicate which tests whether the specified predicate is false. The resulting predicate evaluates totrueif the given predicate evaluates tofalse.falseotherwise
- Parameters:
p- the predicate to be tested- Returns:
- a new predicate evaluating to a check of the falsity of the predicate
-
notFalse
Builds a record predicate which tests whether the specified predicate is not false. The resulting predicate evaluates tofalseif the given predicate evaluates tofalse.trueotherwise
- Parameters:
p- the predicate to be tested- Returns:
- a new predicate evaluating to a check of the non-falsity of the predicate
-
eq
Builds a record predicate which tests the equality of the specified fields. The fields must be of compatible types for comparison. If either field is null-valued, the predicate evaluates tonull.- Parameters:
leftField- the first record field value in the comparisonrightField- the second record field value in the comparison- Returns:
- a function evaluating the predicate
-
eq
Builds a record predicate which tests the equality of the specified field with a known value. The field and value must be of compatible types for comparison. If either value evaluates tonull, so does the predicate.- Parameters:
field- the record field value in the comparisonvalue- the known value in the comparison- Returns:
- a function evaluating the predicate
-
eq
public static ScalarValuedFunction eq(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests the equality of the specified expressions. The expressions must evaluate to compatible types for comparison. If either expression evaluates tonull, so does the predicate.- Parameters:
leftExpr- the expression producing the left value in the comparisonrightExpr- the expression producing the right value in the comparison- Returns:
- a function evaluating the predicate
-
neq
Builds a record predicate which tests the inequality of the specified fields. The fields must be of compatible types for comparison. If either field is null-valued, the predicate evaluates tonull.- Parameters:
leftField- the first record field value in the comparisonrightField- the second record field value in the comparison- Returns:
- a function evaluating the predicate
-
neq
Builds a record predicate which tests the inequality of the specified field with a known value. The field and value must be of compatible types for comparison. If either value evaluates tonull, so does the predicate.- Parameters:
field- the record field value in the comparisonvalue- the known value in the comparison- Returns:
- a function evaluating the predicate
-
neq
public static ScalarValuedFunction neq(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests the inequality of the specified expressions. The expressions must evaluate to compatible types for comparison. If either expression evaluates tonull, so does the predicate.- Parameters:
leftExpr- the expression producing the left value in the comparisonrightExpr- the expression producing the right value in the comparison- Returns:
- a function evaluating the predicate
-
lt
Builds a record predicate which tests whether a field is strictly less than another field. The fields must be of compatible types for comparison. If either field is null-valued, the predicate evaluates tonull.- Parameters:
leftField- the record field value on the left side of the comparisonrightField- the record field value on the right side of the comparison- Returns:
- a function evaluating the predicate
-
lt
Builds a record predicate which tests whether a field is strictly less than a known value. The field and value must be of compatible types for comparison. If either value evaluates tonull, so does the predicate.- Parameters:
leftField- the record field value on the left side of the comparisonrightValue- the known value on the right side of the comparison- Returns:
- a function evaluating the predicate
-
lt
public static ScalarValuedFunction lt(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests whether a specified expression is strictly less than another. The expressions must evaluate to compatible types for comparison. If either expression evaluates tonull, so does the predicate.- Parameters:
leftExpr- the expression producing the left value in the comparisonrightExpr- the expression producing the right value in the comparison- Returns:
- a function evaluating the predicate
-
gt
Builds a record predicate which tests whether a field is strictly greater than another field. The fields must be of compatible types for comparison. If either field is null-valued, the predicate evaluates tonull.- Parameters:
leftField- the record field value on the left side of the comparisonrightField- the record field value on the right side of the comparison- Returns:
- a function evaluating the predicate
-
gt
Builds a record predicate which tests whether a field is strictly greater than a known value. The field and value must be of compatible types for comparison. If either value evaluates tonull, so does the predicate.- Parameters:
leftField- the record field value on the left side of the comparisonrightValue- the known value on the right side of the comparison- Returns:
- a function evaluating the predicate
-
gt
public static ScalarValuedFunction gt(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests whether a specified expression is strictly greater than another. The expressions must evaluate to compatible types for comparison. If either expression evaluates tonull, so does the predicate.- Parameters:
leftExpr- the expression producing the left value in the comparisonrightExpr- the expression producing the right value in the comparison- Returns:
- a function evaluating the predicate
-
lte
Builds a record predicate which tests whether a field is less than or equal to another field. The fields must be of compatible types for comparison. If either field is null-valued, the predicate evaluates tonull.- Parameters:
leftField- the record field value on the left side of the comparisonrightField- the record field value on the right side of the comparison- Returns:
- a function evaluating the predicate
-
lte
Builds a record predicate which tests whether a field is less than or equal to a known value. The field and value must be of compatible types for comparison. If either value evaluates tonull, so does the predicate.- Parameters:
leftField- the record field value on the left side of the comparisonrightValue- the known value on the right side of the comparison- Returns:
- a function evaluating the predicate
-
lte
public static ScalarValuedFunction lte(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests whether a specified expression is less than or equal to another. The expressions must evaluate to compatible types for comparison. If either expression evaluates tonull, so does the predicate.- Parameters:
leftExpr- the expression producing the left value in the comparisonrightExpr- the expression producing the right value in the comparison- Returns:
- a function evaluating the predicate
-
gte
Builds a record predicate which tests whether a field is greater than or equal to another field. The fields must be of compatible types for comparison. If either field is null-valued, the predicate evaluates tonull.- Parameters:
leftField- the record field value on the left side of the comparisonrightField- the record field value on the right side of the comparison- Returns:
- a function evaluating the predicate
-
gte
Builds a record predicate which tests whether a field is greater than or equal to a known value. The field and value must be of compatible types for comparison. If either value evaluates tonull, so does the predicate.- Parameters:
leftField- the record field value on the left side of the comparisonrightValue- the known value on the right side of the comparison- Returns:
- a function evaluating the predicate
-
gte
public static ScalarValuedFunction gte(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr) Builds a record predicate which tests whether a specified expression is greater than or equal to another. The expressions must evaluate to compatible types for comparison. If either expression evaluates tonull, so does the predicate.- Parameters:
leftExpr- the expression producing the left value in the comparisonrightExpr- the expression producing the right value in the comparison- Returns:
- a function evaluating the predicate
-
isNull
Builds a record predicate which tests whether a record field is null-valued. This predicate never yieldsnull.- Parameters:
field- the record field value to test- Returns:
- a function evaluating the predicate
-
isNull
Builds a record predicate which tests whether the specified expression evaluates tonull. This predicate never yieldsnull.- Parameters:
expr- the expression to test- Returns:
- a function evaluating the predicate
-
notNull
Builds a record predicate which tests whether a record field is not null-valued. This predicate never yieldsnull.- Parameters:
field- the record field value to test- Returns:
- a function evaluating the predicate
-
notNull
Builds a record predicate which tests whether the specified expression does not evaluate tonull. This predicate never yieldsnull.- Parameters:
expr- the expression to test- Returns:
- a function evaluating the predicate
-
like
Builds a record predicate which tests whether the value of a field matches a specified SQL LIKE pattern. The field must contain a string value. If the field evaluates tonull, so does the predicate.- Parameters:
field- the record field against which to matchpattern- the string pattern to match- Returns:
- a function evaluating the predicate
-
like
Builds a record predicate which tests whether the value of an expression matches a specified SQL LIKE pattern. The expression must evaluate to a string value. If the expression evaluates tonull, so does the predicate.- Parameters:
expr- the expression to evaluate for the match operationpattern- the string pattern to match- Returns:
- a function evaluating the predicate
-
likeToRegex
Converts a SQL LIKE pattern into an equivalent regular expression. Essentially the following transformation is made:%is converted to.*_is converted to.- character ranges are preserved as is, excepting that negated
ranges convert the initial
!to a^
- Parameters:
likePattern- the pattern match for the LIKE operation- Returns:
- an equivalent regular expression
-
matches
Builds a record predicate which tests whether the value of a field matches a specified regular expression. The field must contain a string value. If the field evaluates tonull, so does the predicate.- Parameters:
field- the record field against which to matchpattern- the string pattern to match- Returns:
- a function evaluating the predicate
-
matches
Builds a record predicate which tests whether the value of an expression matches a specified regular expression. The expression must evaluate to a string value. If the expression evaluates tonull, so does the predicate.- Parameters:
expr- the expression to evaluate for the match operationpattern- the string pattern to match- Returns:
- a function evaluating the predicate
-