Package com.github.vlachenal.sql
Class ClausesBuilder
- java.lang.Object
-
- com.github.vlachenal.sql.ClausesBuilder
-
public class ClausesBuilder extends java.lang.ObjectSQL clauses builder.
This class should be instanciated throughSQL.- Since:
- 0.1
-
-
Constructor Summary
Constructors Constructor Description ClausesBuilder()ClausesBuilderdefault constructorClausesBuilder(java.lang.String column, ClauseMaker clause, T value)ClausesBuilderconstructor.
This constructor will try to add a first clause if value is valid.ClausesBuilder(java.lang.String column, ClauseMaker clause, T value, ValueChecker<T> checker)ClausesBuilderconstructor
This constructor will try to add a first clause if value is valid.ClausesBuilder(java.lang.String column, ClauseMaker clause, T value1, T value2)ClausesBuilderconstructor.
This constructor will try to add a first clause if value is valid.ClausesBuilder(java.lang.String column, ClauseMaker clause, T value1, T value2, ValueChecker<T> checker)ClausesBuilderconstructor
This constructor will try to add a first clause if value is valid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClausesBuilderand()AddANDto SQL queryClausesBuilderand(ClausesBuilder other)Add clauses into parenthesis with AND<T> ClausesBuilderand(java.lang.String column, ClauseMaker clause, T value)AddANDclause if value is valid.<T> ClausesBuilderand(java.lang.String column, ClauseMaker clause, T value, ValueChecker<T> checker)AddANDclause if value is valid<T> ClausesBuilderand(java.lang.String column, ClauseMaker clause, T value1, T value2)AddANDclause if value is valid.<T> ClausesBuilderand(java.lang.String column, ClauseMaker clause, T value1, T value2, ValueChecker<T> checker)AddANDclause if value is validClausesBuilderbetween()AddBETWEENclauseClausesBuilderequals()Add equals clause with=operatorClausesBuilderexists(SelectBuilder query)AddEXISTSin subquery clauseClausesBuilderfield(java.lang.String column)Add field to clauseClausesBuildergreateEquals()Add greater or equals clause with>=operatorClausesBuildergreater()Add greater clause with>operatorClausesBuilderin(SelectBuilder query)AddINsubquery clause.ClausesBuilderin(SQLQuery query)AddINsubquery clause.<T> ClausesBuilderin(java.util.Collection<T> values)AddINclause.
Due to many database engine limitation about the maximum number of prepared statement per connection,INoperator will never be treated with place holder prepared statement values.
You can format text values withSQLutility methods.ClausesBuilderisNotNull()AddIS NOT NULLclauseClausesBuilderisNull()AddIS NULLclauseClausesBuilderlesser()Add lesser clause with<operatorClausesBuilderlesserEquals()Add lesser or equals clause with<=operatorClausesBuilderlike()AddLIKEclauseClausesBuildernot(ClausesBuilder clauses)AddNOTcommandClausesBuildernotBetween()AddNOT BETWEENclauseClausesBuildernotEquals()Add not equals clause with<>operatorClausesBuildernotExists(SelectBuilder query)AddNOT EXISTSin subquery clauseClausesBuildernotIn(SelectBuilder query)AddNOT INsubquery clause.ClausesBuildernotIn(SQLQuery query)AddNOT INsubquery clause.<T> ClausesBuildernotIn(java.util.Collection<T> values)AddNOT INclause.
Due to many database engine limitation about the maximum number of prepared statement per connection,NOT INoperator will never be treated with place holder prepared statement values.
You can format text values withSQLutility methods.ClausesBuildernotLike()AddNOT LIKEclauseClausesBuilderor()AddORto SQL queryClausesBuilderor(ClausesBuilder other)Add clauses into parenthesis with OR<T> ClausesBuilderor(java.lang.String column, ClauseMaker clause, T value)AddORclause if value is valid.<T> ClausesBuilderor(java.lang.String column, ClauseMaker clause, T value, ValueChecker<T> checker)AddORclause if value is valid<T> ClausesBuilderor(java.lang.String column, ClauseMaker clause, T value1, T value2)AddORclause if value is valid.<T> ClausesBuilderor(java.lang.String column, ClauseMaker clause, T value1, T value2, ValueChecker<T> checker)AddORclause if value is valid
-
-
-
Constructor Detail
-
ClausesBuilder
public ClausesBuilder()
ClausesBuilderdefault constructor
-
ClausesBuilder
public ClausesBuilder(java.lang.String column, ClauseMaker clause, T value)ClausesBuilderconstructor.
This constructor will try to add a first clause if value is valid. Value will be validated withSQL::isValidValuefunction.- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue- the value
-
ClausesBuilder
public ClausesBuilder(java.lang.String column, ClauseMaker clause, T value, ValueChecker<T> checker)ClausesBuilderconstructor
This constructor will try to add a first clause if value is valid.- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue- the valuechecker- the value checker to use
-
ClausesBuilder
public ClausesBuilder(java.lang.String column, ClauseMaker clause, T value1, T value2)ClausesBuilderconstructor.
This constructor will try to add a first clause if value is valid. Value will be validated withSQL::isValidValuefunction.- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue1- the first valuevalue2- the second value
-
ClausesBuilder
public ClausesBuilder(java.lang.String column, ClauseMaker clause, T value1, T value2, ValueChecker<T> checker)ClausesBuilderconstructor
This constructor will try to add a first clause if value is valid.- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue1- the first valuevalue2- the second valuechecker- the value checker to use
-
-
Method Detail
-
field
public ClausesBuilder field(java.lang.String column)
Add field to clause- Parameters:
column- the column- Returns:
this
-
not
public ClausesBuilder not(ClausesBuilder clauses)
AddNOTcommand- Parameters:
clauses- the clauses to negate- Returns:
this
-
isNull
public ClausesBuilder isNull()
AddIS NULLclause- Returns:
this
-
isNotNull
public ClausesBuilder isNotNull()
AddIS NOT NULLclause- Returns:
this
-
notEquals
public ClausesBuilder notEquals()
Add not equals clause with<>operator- Returns:
this
-
equals
public ClausesBuilder equals()
Add equals clause with=operator- Returns:
this
-
notExists
public ClausesBuilder notExists(SelectBuilder query)
AddNOT EXISTSin subquery clause- Parameters:
query- the select query- Returns:
this
-
exists
public ClausesBuilder exists(SelectBuilder query)
AddEXISTSin subquery clause- Parameters:
query- the select query- Returns:
this
-
in
public <T> ClausesBuilder in(java.util.Collection<T> values)
AddINclause.
Due to many database engine limitation about the maximum number of prepared statement per connection,INoperator will never be treated with place holder prepared statement values.
You can format text values withSQLutility methods.- Type Parameters:
T- the values' type- Parameters:
values- the values- Returns:
this
-
notIn
public <T> ClausesBuilder notIn(java.util.Collection<T> values)
AddNOT INclause.
Due to many database engine limitation about the maximum number of prepared statement per connection,NOT INoperator will never be treated with place holder prepared statement values.
You can format text values withSQLutility methods.- Type Parameters:
T- the values' type- Parameters:
values- the values- Returns:
this
-
in
public ClausesBuilder in(SQLQuery query)
AddINsubquery clause.- Parameters:
query- the subquery- Returns:
this
-
notIn
public ClausesBuilder notIn(SQLQuery query)
AddNOT INsubquery clause.- Parameters:
query- the subquery- Returns:
this
-
in
public ClausesBuilder in(SelectBuilder query)
AddINsubquery clause.- Parameters:
query- the subquery- Returns:
this
-
notIn
public ClausesBuilder notIn(SelectBuilder query)
AddNOT INsubquery clause.- Parameters:
query- the subquery- Returns:
this
-
greater
public ClausesBuilder greater()
Add greater clause with>operator- Returns:
this
-
greateEquals
public ClausesBuilder greateEquals()
Add greater or equals clause with>=operator- Returns:
this
-
lesser
public ClausesBuilder lesser()
Add lesser clause with<operator- Returns:
this
-
lesserEquals
public ClausesBuilder lesserEquals()
Add lesser or equals clause with<=operator- Returns:
this
-
like
public ClausesBuilder like()
AddLIKEclause- Returns:
this
-
notLike
public ClausesBuilder notLike()
AddNOT LIKEclause- Returns:
this
-
between
public ClausesBuilder between()
AddBETWEENclause- Returns:
this
-
notBetween
public ClausesBuilder notBetween()
AddNOT BETWEENclause- Returns:
this
-
and
public ClausesBuilder and()
AddANDto SQL query- Returns:
this
-
or
public ClausesBuilder or()
AddORto SQL query- Returns:
this
-
and
public <T> ClausesBuilder and(java.lang.String column, ClauseMaker clause, T value)
AddANDclause if value is valid. Value will be validate withSQL::isValidValuefunction.- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue- the value- Returns:
this
-
and
public <T> ClausesBuilder and(java.lang.String column, ClauseMaker clause, T value, ValueChecker<T> checker)
AddANDclause if value is valid- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue- the valuechecker- the value checker to use- Returns:
this
-
and
public <T> ClausesBuilder and(java.lang.String column, ClauseMaker clause, T value1, T value2)
AddANDclause if value is valid. Value will be validate withSQL::isValidValuefunction.- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue1- the first valuevalue2- the second value- Returns:
this
-
and
public <T> ClausesBuilder and(java.lang.String column, ClauseMaker clause, T value1, T value2, ValueChecker<T> checker)
AddANDclause if value is valid- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue1- the first valuevalue2- the second valuechecker- the value checker to use- Returns:
this
-
or
public <T> ClausesBuilder or(java.lang.String column, ClauseMaker clause, T value)
AddORclause if value is valid. Value will be validate withSQL::isValidValuefunction.- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue- the value- Returns:
this
-
or
public <T> ClausesBuilder or(java.lang.String column, ClauseMaker clause, T value, ValueChecker<T> checker)
AddORclause if value is valid- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue- the valuechecker- the value checker to use- Returns:
this
-
or
public <T> ClausesBuilder or(java.lang.String column, ClauseMaker clause, T value1, T value2)
AddORclause if value is valid. Value will be validate withSQL::isValidValuefunction.- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue1- the first valuevalue2- the second value- Returns:
this
-
or
public <T> ClausesBuilder or(java.lang.String column, ClauseMaker clause, T value1, T value2, ValueChecker<T> checker)
AddORclause if value is valid- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue1- the first valuevalue2- the second valuechecker- the value checker to use- Returns:
this
-
and
public ClausesBuilder and(ClausesBuilder other)
Add clauses into parenthesis with AND- Parameters:
other- the clauses to add- Returns:
this
-
or
public ClausesBuilder or(ClausesBuilder other)
Add clauses into parenthesis with OR- Parameters:
other- the clauses to add- Returns:
this
-
-