public class Restrictions
extends java.lang.Object
Constructor and Description |
---|
Restrictions() |
Modifier and Type | Method and Description |
---|---|
static Restriction |
and(Restriction... r)
Combine one or more restrictions with AND:
new restriction = r[0] AND r[1] AND ...
|
static Restriction |
between(Expression e,
Expression low,
Expression high)
Compare if one expression falls between two other expressions:
new expression = low <= e AND e < high.
|
static Restriction |
betweenInclusive(Expression e,
Expression low,
Expression high)
Compare if one expression falls between two other expressions (inclusive):
new expression = low <= e AND e <= high.
|
private static <T> T[] |
copyNotNulls(T[] source,
T[] dest) |
private static int |
countNotNulls(java.lang.Object[] array) |
static Restriction |
eq(Expression e1,
Expression e2)
Compare if two expressions are equal: new restriction = e1 == e2.
|
private static int |
getFirstNull(java.lang.Object[] array)
Test if there is null in the array.
|
static Restriction |
gt(Expression e1,
Expression e2)
Compare if one expression is greater than another: new restriction = e1 > e2.
|
static Restriction |
gteq(Expression e1,
Expression e2)
Compare if one expression is greater than or equal
to another: new restriction = e1 >= e2.
|
static Restriction |
in(Expression e1,
Expression... e2)
Check if an expression is contained in a set of other expressions:
e1 IN (e2[0], e2[1], ...)
|
static Restriction |
like_in(Expression e1,
Expression... e2)
Check if one expression matches any expressions in an array:
(e1 LIKE e2.1) OR (e1 LIKE e2.2) OR ....
|
static Restriction |
like(Expression e1,
Expression e2)
Check if one expression matches another: e1 LIKE e2
|
static Restriction |
lt(Expression e1,
Expression e2)
Compare if one expression is less than another: new restriction = e1 < e2.
|
static Restriction |
lteq(Expression e1,
Expression e2)
Compare if one expression is less than or equal
to another: new restriction = e1 <= e2.
|
static Restriction |
neq(Expression e1,
Expression e2)
Compare if two expressions are inequal: new restriction = e1 <> e2.
|
static Restriction |
not(Restriction r)
Negate a restriction: new restriction = NOT r
|
static Restriction |
notLike_in(Expression e1,
Expression... e2)
Check if one expression doesn't matches any of the expressions in an array.
|
static Restriction |
nullSafeAnd(Restriction... r)
Combine one or more restrictions with AND ignoring null elements.
|
static Restriction |
nullSafeOr(Restriction... r)
Combine one or more restrictions with OR ignoring null elements.
|
static Restriction |
or(Restriction... r)
Combine one or more restrictions with OR: new restriction = r[0] OR r[1] ...
|
static Restriction |
rlike(Expression e,
Expression regexp)
Check if an expression matches a regular expression.
|
public static Restriction and(Restriction... r) throws InvalidDataException
r
- The restrictions to combineInvalidDataException
- If any of the elements is null or
the array doesn't contain at least one elementpublic static Restriction nullSafeAnd(Restriction... r) throws InvalidDataException
r
- The restrictions to combineInvalidDataException
public static Restriction or(Restriction... r) throws InvalidDataException
r
- The restrictions to combineInvalidDataException
- If any of the elements is null or
the array doesn't contain at least one elementpublic static Restriction nullSafeOr(Restriction... r) throws InvalidDataException
r
- The restrictions to combineInvalidDataException
public static Restriction not(Restriction r) throws InvalidDataException
r
- The restrictions to negateInvalidDataException
- If the restriction is nullpublic static Restriction eq(Expression e1, Expression e2) throws InvalidDataException
e1
- The left expressione2
- The right expressionInvalidDataException
- If both expressions are nullpublic static Restriction neq(Expression e1, Expression e2) throws InvalidDataException
e1
- The left expressione2
- The right expressionInvalidDataException
- If both expressions are nullpublic static Restriction gt(Expression e1, Expression e2) throws InvalidDataException
e1
- The left expressione2
- The right expressionInvalidDataException
- If any of the expressions are nullpublic static Restriction gteq(Expression e1, Expression e2) throws InvalidDataException
e1
- The left expressione2
- The right expressionInvalidDataException
- If any of the expressions are nullpublic static Restriction lt(Expression e1, Expression e2) throws InvalidDataException
e1
- The left expressione2
- The right expressionInvalidDataException
- If any of the expressions are nullpublic static Restriction lteq(Expression e1, Expression e2) throws InvalidDataException
e1
- The left expressione2
- The right expressionInvalidDataException
- If any of the expressions are nullpublic static Restriction between(Expression e, Expression low, Expression high) throws InvalidDataException
e
- The expression to check against the limitslow
- The expression for the low limithigh
- The expression for the high limitInvalidDataException
- If any of the expressions are nullpublic static Restriction betweenInclusive(Expression e, Expression low, Expression high) throws InvalidDataException
e
- The expression to check against the limitslow
- The expression for the low limithigh
- The expression for the high limitInvalidDataException
- If any of the expressions are nullpublic static Restriction in(Expression e1, Expression... e2) throws InvalidDataException
e1
- The expression to checke2
- The set of expression to check againstInvalidDataException
- If the set is null or emptypublic static Restriction like(Expression e1, Expression e2) throws InvalidDataException
e1
- The left expressione2
- The right expressionInvalidDataException
- If any of the expressions are nullpublic static Restriction like_in(Expression e1, Expression... e2)
e1
- The left expressione2
- The array with expression to match against, null values are allowed
and compared with IS NULL insteadInvalidDataException
- If any of the expressions are null.public static Restriction notLike_in(Expression e1, Expression... e2)
e1
- The left expression. Null is not allowede2
- The array with expressions that shouldn't match, null values
are allows and compared with NOT IS NULLInvalidDataException
- If any of the required expressions are null.public static Restriction rlike(Expression e, Expression regexp)
e
- The expression to matchregexp
- The regular expression to test againstInvalidDataException
- If any of the values are nullprivate static int getFirstNull(java.lang.Object[] array)
private static int countNotNulls(java.lang.Object[] array)
private static <T> T[] copyNotNulls(T[] source, T[] dest)