Package com.github.vlachenal.sql
Class SQL
- java.lang.Object
-
- com.github.vlachenal.sql.SQL
-
public final class SQL extends java.lang.ObjectSQL request builder entry point and utility methods- Since:
- 0.1
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ClausesBuilderclauses()Initialize a new clauses builderstatic <T> ClausesBuilderclauses(java.lang.String column, ClauseMaker clause, T value)Initialize a new clauses builder and add the first clause if vaue is validstatic <T> ClausesBuilderclauses(java.lang.String column, ClauseMaker clause, T value, ValueChecker<T> checker)Initialize a new clauses builder and add the first clause if vaue is validstatic <T> ClausesBuilderclauses(java.lang.String column, ClauseMaker clause, T value1, T value2)Initialize a new clauses builder and add the first clause if vaue is validstatic <T> ClausesBuilderclauses(java.lang.String column, ClauseMaker clause, T value1, T value2, ValueChecker<T> checker)Initialize a new clauses builder and add the first clause if vaue is validstatic DeleteBuilderdelete(java.lang.String table)Initialize a new delete builderstatic java.lang.StringformatText(java.lang.Object value)Format value for text column adding quote before and after value.
Objectwill be cast intoStringwithtoString()method.static java.util.List<java.lang.String>formatText(java.util.Collection<?> values)Format values for text column adding quote before and after value.
Objectwill be cast intoStringwithtoString()method.static <T> booleanisValidValue(T value)Check if value is null or empty (forStringandCollection).
This is the valueValueCheckerwhich is used ot check value validity.static SelectBuilderselect()Initialize a new select builderstatic <T> java.lang.StringtoSQLList(java.util.Collection<T> values)Format value collection for SQL query (i.e for IN clause)static UpdateBuilderupdate(java.lang.String table)Initialize a new update builder
-
-
-
Method Detail
-
select
public static SelectBuilder select()
Initialize a new select builder- Returns:
- the new
SelectBuilder
-
update
public static UpdateBuilder update(java.lang.String table)
Initialize a new update builder- Parameters:
table- the table to update- Returns:
- the new
UpdateBuilder
-
delete
public static DeleteBuilder delete(java.lang.String table)
Initialize a new delete builder- Parameters:
table- the table to delete- Returns:
- the new
DeleteBuilder
-
clauses
public static ClausesBuilder clauses()
Initialize a new clauses builder- Returns:
- the new
ClausesBuilder
-
clauses
public static <T> ClausesBuilder clauses(java.lang.String column, ClauseMaker clause, T value)
Initialize a new clauses builder and add the first clause if vaue is valid- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue- the value- Returns:
- the new
ClausesBuilder
-
clauses
public static <T> ClausesBuilder clauses(java.lang.String column, ClauseMaker clause, T value, ValueChecker<T> checker)
Initialize a new clauses builder and add the first clause if vaue is valid- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue- the valuechecker- the value checker to use- Returns:
- the new
ClausesBuilder
-
clauses
public static <T> ClausesBuilder clauses(java.lang.String column, ClauseMaker clause, T value1, T value2)
Initialize a new clauses builder and add the first clause if vaue is valid- Type Parameters:
T- the value type- Parameters:
column- the columnclause- the clause makervalue1- the first valuevalue2- the second value- Returns:
- the new
ClausesBuilder
-
clauses
public static <T> ClausesBuilder clauses(java.lang.String column, ClauseMaker clause, T value1, T value2, ValueChecker<T> checker)
Initialize a new clauses builder and add the first clause if vaue 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:
- the new
ClausesBuilder
-
formatText
public static java.lang.String formatText(java.lang.Object value)
Format value for text column adding quote before and after value.
Objectwill be cast intoStringwithtoString()method.- Parameters:
value- the value- Returns:
- the formatter value
-
formatText
public static java.util.List<java.lang.String> formatText(java.util.Collection<?> values)
Format values for text column adding quote before and after value.
Objectwill be cast intoStringwithtoString()method.- Parameters:
values- the values- Returns:
- the formatter values
-
toSQLList
public static <T> java.lang.String toSQLList(java.util.Collection<T> values)
Format value collection for SQL query (i.e for IN clause)- Type Parameters:
T- the collection type- Parameters:
values- the values- Returns:
- the SQL list
-
isValidValue
public static <T> boolean isValidValue(T value)
Check if value is null or empty (forStringandCollection).
This is the valueValueCheckerwhich is used ot check value validity.- Type Parameters:
T- the value type- Parameters:
value- the value- Returns:
trueis value is not null,falseotherwise
-
-