|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectca.krasnay.sqlbuilder.Predicates
public final class Predicates
Collection of commonly used predicates, implemented by static methods.
Most predicates accept a SQL expression and one or more values to which the SQL is compared. Predicates do not escape this expression. As such, do not accept arbitrary expressions from users or other sources, as it may be a source of SQL injection vulnerabilities. The normal use-case is that these expressions are hard-coded in your application. Values, on the other hand, are substituted as proper prepared statement parameters so they are safe from SQL injection.
| Constructor Summary | |
|---|---|
Predicates()
|
|
| Method Summary | |
|---|---|
static Predicate |
all()
Returns a predicate that does not constrain the result set. |
static Predicate |
allBitsSet(String expr,
long bits)
Adds a clause that checks whether ALL set bits in a bitmask are present in a numeric expression. |
static Predicate |
and(List<Predicate> predicates)
Joins a series of predicates with AND. |
static Predicate |
and(Predicate... predicates)
Joins a series of predicates with AND. |
static Predicate |
anyBitsSet(String expr,
long bits)
Adds a clause that checks whether ANY set bits in a bitmask are present in a numeric expression. |
static Predicate |
eq(String expr,
Object value)
Adds an equals clause to a creator. |
static ExistsPredicate |
exists(String table)
Adds an EXISTS clause to a creator. |
static Predicate |
in(String expr,
List<?> values)
Adds an IN clause to a creator. |
static Predicate |
in(String expr,
Object... values)
Adds an IN clause to a creator. |
static Predicate |
is(String sql)
Returns a predicate that takes no parameters. |
static Predicate |
neq(String expr,
Object value)
Adds a not equals clause to a creator. |
static Predicate |
not(Predicate childPredicate)
Inverts the sense of the given child predicate. |
static Predicate |
or(List<Predicate> predicates)
Joins a series of predicates with OR. |
static Predicate |
or(Predicate... predicates)
Joins a series of predicates with OR. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Predicates()
| Method Detail |
|---|
public static Predicate all()
public static Predicate allBitsSet(String expr,
long bits)
expr - SQL numeric expression to check.bits - Integer containing the bits for which to check.public static Predicate and(Predicate... predicates)
public static Predicate and(List<Predicate> predicates)
public static Predicate anyBitsSet(String expr,
long bits)
expr - SQL numeric expression to check.bits - Integer containing the bits for which to check.
public static Predicate eq(String expr,
Object value)
expr - SQL expression to be compared for equality.value - Value to which the SQL expression is compared.
public static Predicate in(String expr,
List<?> values)
expr - SQL expression to be tested for inclusion.values - Values for the IN clause.
public static Predicate in(String expr,
Object... values)
expr - SQL expression to be tested for inclusion.values - Values for the IN clause.public static Predicate is(String sql)
sql - SQL text of the expressionpublic static ExistsPredicate exists(String table)
new SelectCreator()
.column("name")
.from("Emp e")
.where(exists("SickDay sd").where("sd.emp_id = e.id").and(eq("sd.dow", "Monday")));
table - Table that forms the basis of the sub-select.
public static Predicate neq(String expr,
Object value)
expr - SQL expression to be compared for equality.value - Value to which the SQL expression is compared.public static Predicate not(Predicate childPredicate)
childPredicate - Predicate whose sense is to be inverted.public static Predicate or(Predicate... predicates)
public static Predicate or(List<Predicate> predicates)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||