Class BaseWhereAdapter<T>
- java.lang.Object
-
- com.ibm.fhir.database.utils.query.BaseWhereAdapter<T>
-
- Direct Known Subclasses:
WhereAdapter
,WhereFragment
public abstract class BaseWhereAdapter<T> extends java.lang.Object
A piece of a where clause which isn't attached to aSelect
statement allowing getThis() bit to be reused where the statement/whereClause isn't yet established.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseWhereAdapter()
For building standalone predicates like filtersprotected
BaseWhereAdapter(PredicateParser pp)
Adopts an existing predicate parser
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
acos(ColumnRef arg)
Add ACOS(arg) to the expressionT
acos(ExpNode arg)
Add ACOS(arg) to the expressionT
add()
Add + to the expressionT
and()
Add an AND to the list of expression tokensT
and(ColumnRef ref)
Add AND {ref} to the expressionT
and(ExpNode predicate)
Add AND {predicate} to the expressionT
and(java.lang.String element)
Add AND {element} to the expression where {element} is typically a simple column nameT
and(java.lang.String tableAlias, java.lang.String columnName)
Add AND {tableAlias}.{columnName} to the expressionT
bind(java.lang.Double param)
Add a bind marker and Double value to the expression.T
bind(java.lang.Integer param)
Add a bind marker and Integer value to the expression.T
bind(java.lang.Long param)
Add a bind marker and Long value to the expression.T
bind(java.lang.String param)
Add a bind marker and its string value to the expression.T
bind(java.math.BigDecimal value)
Add a bind marker and BigDecimal value to the expression.T
bind(java.time.Instant param)
Add a bind marker and Instant value to the expression.T
coalesce(ColumnRef... columnRefs)
Add a COALESCE(c1, c2, ...) function.T
col(java.lang.String expression)
Add a column expression or referenceT
col(java.lang.String tableAlias, java.lang.String expression)
Add the qualified name {tableAlias}.{expression} to the expressionT
cos(ColumnRef arg)
Add COS(arg) to the expressionT
cos(ExpNode arg)
Add COS(arg) to the expressionT
div()
Add / to the expressionT
eq()
Add an equals '=' node to the expressionT
eq(int literalValue)
Add '= {literalValue}' to the expressionT
eq(long literalValue)
Add '= {literalValue}' to the expressionT
eq(ColumnRef ref)
Add '= {ref}' to the expressionT
eq(LiteralString str)
Add '= {str}' to the expressionT
eq(BindMarkerNode bindMarker)
Add a bind marker and value to the expressionT
eq(java.lang.String columnExpression)
Add '= {columnExpression}' to the expressionT
eq(java.lang.String tableAlias, java.lang.String columnExpression)
Add '= {tableAlias}.{columnExpression}' to the expressionT
escape()
Add ESCAPE to the expressionT
escape(ColumnRef ref)
Add ESCAPE {ref} to the expressionT
escape(BindMarkerNode bindMarker)
Add ESCAPE ? to the expressionT
escape(java.lang.String str)
Add ESCAPE {str} to the expressionT
escape(java.lang.String tableAlias, java.lang.String columnExpression)
Add ESCAPE {tableAlias}.{columnExpression} to the expressionT
exists(Select correlatedSubSelect)
Add an exists clause using the given correlated sub-select statementT
filter(ExpNode filter)
Add the expression directly without any other operatorExpNode
getExpression()
Get the expression that has been builtprotected PredicateParser
getPredicateParser()
Getter for the predicate parserprotected abstract T
getThis()
Returns the sub-class type-specific instance of the class.T
gt()
Add > to the expressionT
gt(int literalValue)
Add > {literalValue} to the expressionT
gt(long literalValue)
Add > {literalValue} to the expressionT
gt(ColumnRef ref)
Add > {ref} to the expressionT
gt(BindMarkerNode bindMarker)
Add a bind marker and its value to the expressionT
gt(java.lang.String literalValue)
Add > {literalValue} to the expressionT
gte()
Add >= to the expressionT
gte(int literalValue)
Add >= {literalValue} to the expressionT
gte(long literalValue)
Add >= {literalValue} to the expressionT
gte(ColumnRef ref)
Add >= {ref} to the expressionT
gte(BindMarkerNode bindMarker)
Add >= {bindMarker} to the expressionT
gte(java.lang.String literalValue)
Add >= {literalValue} to the expressionT
in(java.lang.Long[] inList)
Add IN (?, ?, ...) for a list of Long valuesT
in(java.lang.String[] inList)
Add IN (?, ?, ...) for a list of String valuesT
in(java.util.List<java.lang.String> inList)
Thanks to type erasure we can only have one type of list here.T
inLiteral(java.lang.Long[] inList)
Add IN (123, 124, ...) for a literal list of Long valuesT
inLiteralLong(java.util.List<java.lang.Long> inList)
Add IN (123, 124, ...) for a literal list of Long valuesT
isNotNull()
Add an IS NOT NULL operator to the expressionT
isNull()
Add an IS NULL operator to the expressionT
leftParen()
Add a left paren(
to the expressionT
like()
Add LIKE to the expressionT
like(ColumnRef ref)
Add LIKE {ref} to the expressionT
like(BindMarkerNode bindMarker)
Add LIKE ? to the expressionT
like(java.lang.String str)
Add LIKE {str} to the expressionT
like(java.lang.String tableAlias, java.lang.String columnExpression)
Add LIKE {tableAlias}.{columnExpression} to the expressionT
literal(double value)
Add a literal double value to the expressionT
literal(long value)
Add a literal long value to the expressionT
literal(java.lang.String value)
Add a literal String value to the expressionT
lt()
Add < to the expressionT
lt(int literalValue)
Add < {literalValue} to the expressionT
lt(long literalValue)
Add < {literalValue} to the expressionT
lt(ColumnRef ref)
Add < {ref} to the expressionT
lt(BindMarkerNode bindMarker)
Add < {bindMarker} to the expressionT
lt(java.lang.String literalValue)
Add < {literalValue} to the expressionT
lte()
Add <= to the expressionT
lte(int literalValue)
Add <= {literalValue} to the expressionT
lte(long literalValue)
Add <= {literalValue} to the expressionT
lte(ColumnRef ref)
Add <= ref to the expressionT
lte(BindMarkerNode bindMarker)
Add <= {bindMarker} to the expressionT
lte(java.lang.String literalValue)
Add <= {literalValue} to the expressionT
mult()
Add * to the expressionT
neq()
Add != to the expressionT
neq(int literalValue)
Add != {literalValue} to the expressionT
neq(long literalValue)
Add != {literalValue} to the expressionT
neq(ColumnRef ref)
Add != {ref} to the expressionT
neq(LiteralString str)
Add != {str} to the expressionT
neq(BindMarkerNode bindMarker)
Add a bind marker and its value to the expressionT
neq(java.lang.String literalValue)
Add != {literalValue} to the expressionT
not(ExpNode expr)
Add NOT to the expressionT
notExists(Select correlatedSubSelect)
Add a NOT EXISTS clause using the given correlated sub-select statementT
operator(Operator op)
Add the operator op to the expressionT
or()
Add OR to the expressionT
or(ColumnRef ref)
Add OR {ref} to the expressionT
or(ExpNode predicate)
Add OR {predicate} to the expressionT
or(java.lang.String element)
Add OR {element} to the expression where element is typically a column nameT
or(java.lang.String tableAlias, java.lang.String columnName)
Add OR {tableAlias}.{columnName} to the expressionT
radians(ColumnRef arg)
Add RADIANS(arg) to the expressionT
radians(ExpNode arg)
Add RADIANS(arg) to the expressionT
rightParen()
Add a right paren)
to the expressionT
sin(ColumnRef arg)
Add SIN(arg) to the expressionT
sin(ExpNode arg)
Add SIN(arg) to the expressionT
sub()
Add - to the expressionT
where(java.lang.String columnName)
To simplify code, support multiple where clauses, treating each as an ANDT
where(java.lang.String tableAlias, java.lang.String columnName)
To simplify code, support multiple where clauses, treating each as an AND
-
-
-
Constructor Detail
-
BaseWhereAdapter
protected BaseWhereAdapter()
For building standalone predicates like filters
-
BaseWhereAdapter
protected BaseWhereAdapter(PredicateParser pp)
Adopts an existing predicate parser- Parameters:
pp
-
-
-
Method Detail
-
getThis
protected abstract T getThis()
Returns the sub-class type-specific instance of the class. Used as the return value in fluent methods.- Returns:
-
getPredicateParser
protected PredicateParser getPredicateParser()
Getter for the predicate parser- Returns:
-
getExpression
public ExpNode getExpression()
Get the expression that has been built- Returns:
-
literal
public T literal(java.lang.String value)
Add a literal String value to the expression- Parameters:
value
-- Returns:
-
literal
public T literal(long value)
Add a literal long value to the expression- Parameters:
value
-- Returns:
-
literal
public T literal(double value)
Add a literal double value to the expression- Parameters:
value
-- Returns:
-
eq
public T eq()
Add an equals '=' node to the expression- Returns:
-
eq
public T eq(long literalValue)
Add '= {literalValue}' to the expression- Parameters:
literalValue
-- Returns:
-
eq
public T eq(int literalValue)
Add '= {literalValue}' to the expression- Parameters:
literalValue
-- Returns:
-
eq
public T eq(java.lang.String columnExpression)
Add '= {columnExpression}' to the expression- Parameters:
literalValue
-- Returns:
-
eq
public T eq(LiteralString str)
Add '= {str}' to the expression- Parameters:
str
-- Returns:
-
eq
public T eq(java.lang.String tableAlias, java.lang.String columnExpression)
Add '= {tableAlias}.{columnExpression}' to the expression- Parameters:
literalValue
-- Returns:
-
eq
public T eq(BindMarkerNode bindMarker)
Add a bind marker and value to the expression- Parameters:
bindMarker
-- Returns:
-
where
public T where(java.lang.String columnName)
To simplify code, support multiple where clauses, treating each as an AND- Parameters:
columnName
-- Returns:
-
where
public T where(java.lang.String tableAlias, java.lang.String columnName)
To simplify code, support multiple where clauses, treating each as an AND- Parameters:
tableAlias
-columnName
-- Returns:
-
and
public T and()
Add an AND to the list of expression tokens- Returns:
-
and
public T and(ExpNode predicate)
Add AND {predicate} to the expression- Parameters:
predicate
-- Returns:
-
and
public T and(java.lang.String element)
Add AND {element} to the expression where {element} is typically a simple column name
-
and
public T and(java.lang.String tableAlias, java.lang.String columnName)
Add AND {tableAlias}.{columnName} to the expression- Parameters:
tableAlias
-columnName
-- Returns:
-
and
public T and(ColumnRef ref)
Add AND {ref} to the expression- Parameters:
ref
- the column reference- Returns:
-
or
public T or()
Add OR to the expression- Returns:
-
or
public T or(ExpNode predicate)
Add OR {predicate} to the expression- Parameters:
predicate
-- Returns:
-
or
public T or(java.lang.String element)
Add OR {element} to the expression where element is typically a column name- Parameters:
element
-- Returns:
-
or
public T or(java.lang.String tableAlias, java.lang.String columnName)
Add OR {tableAlias}.{columnName} to the expression- Parameters:
tableAlias
-columnName
-- Returns:
-
or
public T or(ColumnRef ref)
Add OR {ref} to the expression- Parameters:
ref
- the column reference- Returns:
-
neq
public T neq()
Add != to the expression- Returns:
-
neq
public T neq(ColumnRef ref)
Add != {ref} to the expression- Parameters:
ref
- the column reference- Returns:
-
neq
public T neq(long literalValue)
Add != {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
neq
public T neq(int literalValue)
Add != {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
neq
public T neq(java.lang.String literalValue)
Add != {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
neq
public T neq(LiteralString str)
Add != {str} to the expression- Parameters:
str
- a literal string value- Returns:
-
neq
public T neq(BindMarkerNode bindMarker)
Add a bind marker and its value to the expression- Parameters:
bindMarker
-- Returns:
-
gt
public T gt()
Add > to the expression- Returns:
-
gt
public T gt(ColumnRef ref)
Add > {ref} to the expression- Parameters:
ref
- the column reference- Returns:
-
gt
public T gt(long literalValue)
Add > {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
gt
public T gt(int literalValue)
Add > {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
gt
public T gt(java.lang.String literalValue)
Add > {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
gt
public T gt(BindMarkerNode bindMarker)
Add a bind marker and its value to the expression- Parameters:
bindMarker
-- Returns:
-
gte
public T gte()
Add >= to the expression- Returns:
-
gte
public T gte(ColumnRef ref)
Add >= {ref} to the expression- Parameters:
ref
- the column reference- Returns:
-
gte
public T gte(long literalValue)
Add >= {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
gte
public T gte(int literalValue)
Add >= {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
gte
public T gte(java.lang.String literalValue)
Add >= {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
gte
public T gte(BindMarkerNode bindMarker)
Add >= {bindMarker} to the expression- Parameters:
bindMarker
-- Returns:
-
lt
public T lt()
Add < to the expression- Returns:
-
lt
public T lt(ColumnRef ref)
Add < {ref} to the expression- Parameters:
ref
- the column reference- Returns:
-
lt
public T lt(long literalValue)
Add < {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
lt
public T lt(int literalValue)
Add < {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
lt
public T lt(java.lang.String literalValue)
Add < {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
lt
public T lt(BindMarkerNode bindMarker)
Add < {bindMarker} to the expression- Parameters:
bindMarker
-- Returns:
-
lte
public T lte()
Add <= to the expression- Returns:
-
lte
public T lte(long literalValue)
Add <= {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
lte
public T lte(int literalValue)
Add <= {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
lte
public T lte(java.lang.String literalValue)
Add <= {literalValue} to the expression- Parameters:
literalValue
-- Returns:
-
lte
public T lte(BindMarkerNode bindMarker)
Add <= {bindMarker} to the expression- Parameters:
bindMarker
-- Returns:
-
col
public T col(java.lang.String expression)
Add a column expression or reference- Parameters:
expression
-- Returns:
-
col
public T col(java.lang.String tableAlias, java.lang.String expression)
Add the qualified name {tableAlias}.{expression} to the expression- Parameters:
tableAlias
-expression
-- Returns:
-
exists
public T exists(Select correlatedSubSelect)
Add an exists clause using the given correlated sub-select statement- Parameters:
correlatedSubSelect
-- Returns:
-
notExists
public T notExists(Select correlatedSubSelect)
Add a NOT EXISTS clause using the given correlated sub-select statement- Parameters:
correlatedSubSelect
-- Returns:
-
mult
public T mult()
Add * to the expression- Returns:
-
add
public T add()
Add + to the expression- Returns:
-
sub
public T sub()
Add - to the expression- Returns:
-
div
public T div()
Add / to the expression- Returns:
-
coalesce
public T coalesce(ColumnRef... columnRefs)
Add a COALESCE(c1, c2, ...) function. These should actually be column expressions, but for now we only need to model them as table.col values- Parameters:
columnRefs
-- Returns:
-
radians
public T radians(ExpNode arg)
Add RADIANS(arg) to the expression- Parameters:
arg
-- Returns:
-
radians
public T radians(ColumnRef arg)
Add RADIANS(arg) to the expression- Parameters:
arg
-- Returns:
-
isNotNull
public T isNotNull()
Add an IS NOT NULL operator to the expression- Returns:
-
isNull
public T isNull()
Add an IS NULL operator to the expression- Returns:
-
leftParen
public T leftParen()
Add a left paren(
to the expression
-
rightParen
public T rightParen()
Add a right paren)
to the expression
-
in
public T in(java.lang.String[] inList)
Add IN (?, ?, ...) for a list of String values- Parameters:
inList
-- Returns:
-
in
public T in(java.util.List<java.lang.String> inList)
Thanks to type erasure we can only have one type of list here. No overloading. String is the most likely type of field, so we go with that. Uses bind-markers, not literals.- Parameters:
inList
-- Returns:
-
in
public T in(java.lang.Long[] inList)
Add IN (?, ?, ...) for a list of Long values- Parameters:
inList
-- Returns:
-
inLiteral
public T inLiteral(java.lang.Long[] inList)
Add IN (123, 124, ...) for a literal list of Long values- Parameters:
inList
-- Returns:
-
inLiteralLong
public T inLiteralLong(java.util.List<java.lang.Long> inList)
Add IN (123, 124, ...) for a literal list of Long values- Parameters:
inList
-- Returns:
-
like
public T like()
Add LIKE to the expression- Returns:
-
like
public T like(java.lang.String str)
Add LIKE {str} to the expression- Parameters:
str
-- Returns:
-
like
public T like(java.lang.String tableAlias, java.lang.String columnExpression)
Add LIKE {tableAlias}.{columnExpression} to the expression- Parameters:
tableAlias
-columnExpression
-- Returns:
-
like
public T like(BindMarkerNode bindMarker)
Add LIKE ? to the expression- Parameters:
bindMarker
-- Returns:
-
escape
public T escape()
Add ESCAPE to the expression- Returns:
-
escape
public T escape(ColumnRef ref)
Add ESCAPE {ref} to the expression- Parameters:
ref
-- Returns:
-
escape
public T escape(java.lang.String str)
Add ESCAPE {str} to the expression- Parameters:
str
-- Returns:
-
escape
public T escape(java.lang.String tableAlias, java.lang.String columnExpression)
Add ESCAPE {tableAlias}.{columnExpression} to the expression- Parameters:
tableAlias
-columnExpression
-- Returns:
-
escape
public T escape(BindMarkerNode bindMarker)
Add ESCAPE ? to the expression- Parameters:
bindMarker
-- Returns:
-
filter
public T filter(ExpNode filter)
Add the expression directly without any other operator- Parameters:
filter
-- Returns:
-
bind
public T bind(java.lang.String param)
Add a bind marker and its string value to the expression. Handles null.- Parameters:
param
-- Returns:
-
bind
public T bind(java.lang.Long param)
Add a bind marker and Long value to the expression. Handles null.- Parameters:
param
-- Returns:
-
bind
public T bind(java.lang.Integer param)
Add a bind marker and Integer value to the expression. Handles null.- Parameters:
param
-- Returns:
-
bind
public T bind(java.lang.Double param)
Add a bind marker and Double value to the expression. Handles null.- Parameters:
param
-- Returns:
-
bind
public T bind(java.time.Instant param)
Add a bind marker and Instant value to the expression. Handles null.- Parameters:
param
-- Returns:
-
bind
public T bind(java.math.BigDecimal value)
Add a bind marker and BigDecimal value to the expression. Handles null.- Parameters:
param
-- Returns:
-
-