Package com.github.eikecochu.sqlbuilder
Class Conditionable<T extends Conditionable<T>>
- java.lang.Object
-
- com.github.eikecochu.sqlbuilder.QueryPartImpl<T>
-
- com.github.eikecochu.sqlbuilder.Conditionable<T>
-
- Type Parameters:
T- The type which allows setting conditions
- All Implemented Interfaces:
QueryPart,QueryPartLinked<T>,QueryPartSQL<T>
public abstract class Conditionable<T extends Conditionable<T>> extends QueryPartImpl<T>
Abstract base class for condition like statements, generic to allow multiple origins, for example from WHERE, JOIN etc.
-
-
Constructor Summary
Constructors Modifier Constructor Description Conditionable()Creates a new empty conditionableprotectedConditionable(QueryPartLinked<?> parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tand()Connect the previous and next condition with the AND operatorConditionPart<T>col(java.lang.String name)Use a column as constraintTcol(java.lang.String name, CompareOperator operator, ConditionValueType type, java.lang.Object... values)Use a column as constraint and set the comparative elementTcol(java.lang.String name, java.lang.Object value)Compare a column to a valueTcol(java.lang.String name, java.lang.Object... values)Compare a column to multiple valuesTcol(java.lang.String name, java.lang.String operator, ConditionValueType type, java.lang.Object... values)Use a column as constraint and set the comparative elementTcolsEq(java.lang.String name1, java.lang.String name2)Compare a column to another columnTgroup(Condition group)Include a subgroup in the conditionNestedCondition<T>groupStart()Start a nested condition groupTor()Connect the previous and next condition with the OR operatorjava.lang.Stringstring(QueryOptions options)Transforms this statement into an SQL stringTvalues(ValueHolder values)Set the comparing valuesTvalues(ValueHolder values, java.lang.String columnPrefix)Set the comparing values with prefix-
Methods inherited from class com.github.eikecochu.sqlbuilder.QueryPartImpl
parent, sql
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.eikecochu.sqlbuilder.QueryPartLinked
ext, parent
-
-
-
-
Constructor Detail
-
Conditionable
public Conditionable()
Creates a new empty conditionable
-
Conditionable
protected Conditionable(QueryPartLinked<?> parent)
-
-
Method Detail
-
values
public T values(ValueHolder values)
Set the comparing values- Parameters:
values- The comparing values- Returns:
- This instance
-
values
public T values(ValueHolder values, java.lang.String columnPrefix)
Set the comparing values with prefix- Parameters:
values- The comparing valuescolumnPrefix- The column prefix for each constraint- Returns:
- This instance
-
col
public T col(java.lang.String name, CompareOperator operator, ConditionValueType type, java.lang.Object... values)
Use a column as constraint and set the comparative element- Parameters:
name- The column nameoperator- The comarator operatortype- The type of the valuevalues- The value to compare to- Returns:
- This instance
-
col
public T col(java.lang.String name, java.lang.String operator, ConditionValueType type, java.lang.Object... values)
Use a column as constraint and set the comparative element- Parameters:
name- The column nameoperator- The comarator operator as stringtype- The type of the valuevalues- The value to compare to- Returns:
- This instance
-
col
public ConditionPart<T> col(java.lang.String name)
Use a column as constraint- Parameters:
name- The column name- Returns:
- The value instance to set the compare value
-
col
public T col(java.lang.String name, java.lang.Object value)
Compare a column to a value- Parameters:
name- The column namevalue- The comparing value- Returns:
- This instance
-
colsEq
public T colsEq(java.lang.String name1, java.lang.String name2)
Compare a column to another column- Parameters:
name1- The first column namename2- The second column name- Returns:
- This instance
-
col
public T col(java.lang.String name, java.lang.Object... values)
Compare a column to multiple values- Parameters:
name- The column namevalues- The comparing values- Returns:
- This instance
-
group
public T group(Condition group)
Include a subgroup in the condition- Parameters:
group- The subgroup- Returns:
- This instance
-
groupStart
public NestedCondition<T> groupStart()
Start a nested condition group- Returns:
- The new nested condition group
-
and
public T and()
Connect the previous and next condition with the AND operator- Returns:
- This instance
-
or
public T or()
Connect the previous and next condition with the OR operator- Returns:
- This instance
-
string
public java.lang.String string(QueryOptions options)
Description copied from interface:QueryPartTransforms this statement into an SQL string- Parameters:
options- The QueryOptions to apply for transformation- Returns:
- The created SQL string
-
-