Class BaseWhereAdapter<T>
- java.lang.Object
-
- org.linuxforhealth.fhir.database.utils.query.BaseWhereAdapter<T>
-
- Direct Known Subclasses:
WhereAdapter,WhereFragment
public abstract class BaseWhereAdapter<T> extends java.lang.ObjectA piece of a where clause which isn't attached to aSelectstatement allowing getThis() bit to be reused where the statement/whereClause isn't yet established.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseWhereAdapter()For building standalone predicates like filtersprotectedBaseWhereAdapter(PredicateParser pp)Adopts an existing predicate parser
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Tacos(ColumnRef arg)Add ACOS(arg) to the expressionTacos(ExpNode arg)Add ACOS(arg) to the expressionTadd()Add + to the expressionTand()Add an AND to the list of expression tokensTand(java.lang.String element)Add AND {element} to the expression where {element} is typically a simple column nameTand(java.lang.String tableAlias, java.lang.String columnName)Add AND {tableAlias}.{columnName} to the expressionTand(ColumnRef ref)Add AND {ref} to the expressionTand(ExpNode predicate)Add AND {predicate} to the expressionTbind(java.lang.Double param)Add a bind marker and Double value to the expression.Tbind(java.lang.Integer param)Add a bind marker and Integer value to the expression.Tbind(java.lang.Long param)Add a bind marker and Long value to the expression.Tbind(java.lang.String param)Add a bind marker and its string value to the expression.Tbind(java.math.BigDecimal value)Add a bind marker and BigDecimal value to the expression.Tbind(java.time.Instant param)Add a bind marker and Instant value to the expression.Tcoalesce(ColumnRef... columnRefs)Add a COALESCE(c1, c2, ...) function.Tcol(java.lang.String expression)Add a column expression or referenceTcol(java.lang.String tableAlias, java.lang.String expression)Add the qualified name {tableAlias}.{expression} to the expressionTcos(ColumnRef arg)Add COS(arg) to the expressionTcos(ExpNode arg)Add COS(arg) to the expressionTdiv()Add / to the expressionTeq()Add an equals '=' node to the expressionTeq(int literalValue)Add '= {literalValue}' to the expressionTeq(long literalValue)Add '= {literalValue}' to the expressionTeq(java.lang.String columnExpression)Add '= {columnExpression}' to the expressionTeq(java.lang.String tableAlias, java.lang.String columnExpression)Add '= {tableAlias}.{columnExpression}' to the expressionTeq(ColumnRef ref)Add '= {ref}' to the expressionTeq(LiteralString str)Add '= {str}' to the expressionTeq(BindMarkerNode bindMarker)Add a bind marker and value to the expressionTescape()Add ESCAPE to the expressionTescape(java.lang.String str)Add ESCAPE {str} to the expressionTescape(java.lang.String tableAlias, java.lang.String columnExpression)Add ESCAPE {tableAlias}.{columnExpression} to the expressionTescape(ColumnRef ref)Add ESCAPE {ref} to the expressionTescape(BindMarkerNode bindMarker)Add ESCAPE ? to the expressionTexists(Select correlatedSubSelect)Add an exists clause using the given correlated sub-select statementTfilter(ExpNode filter)Add the expression directly without any other operatorExpNodegetExpression()Get the expression that has been builtprotected PredicateParsergetPredicateParser()Getter for the predicate parserprotected abstract TgetThis()Returns the sub-class type-specific instance of the class.Tgt()Add > to the expressionTgt(int literalValue)Add > {literalValue} to the expressionTgt(long literalValue)Add > {literalValue} to the expressionTgt(java.lang.String literalValue)Add > {literalValue} to the expressionTgt(ColumnRef ref)Add > {ref} to the expressionTgt(BindMarkerNode bindMarker)Add a bind marker and its value to the expressionTgte()Add >= to the expressionTgte(int literalValue)Add >= {literalValue} to the expressionTgte(long literalValue)Add >= {literalValue} to the expressionTgte(java.lang.String literalValue)Add >= {literalValue} to the expressionTgte(ColumnRef ref)Add >= {ref} to the expressionTgte(BindMarkerNode bindMarker)Add >= {bindMarker} to the expressionTin(java.lang.Long[] inList)Add IN (?, ?, ...) for a list of Long valuesTin(java.lang.String[] inList)Add IN (?, ?, ...) for a list of String valuesTin(java.util.List<java.lang.String> inList)Thanks to type erasure we can only have one type of list here.TinLiteral(java.lang.Long[] inList)Add IN (123, 124, ...) for a literal list of Long valuesTinLiteralLong(java.util.List<java.lang.Long> inList)Add IN (123, 124, ...) for a literal list of Long valuesTisNotNull()Add an IS NOT NULL operator to the expressionTisNull()Add an IS NULL operator to the expressionTleftParen()Add a left paren(to the expressionTlike()Add LIKE to the expressionTlike(java.lang.String str)Add LIKE {str} to the expressionTlike(java.lang.String tableAlias, java.lang.String columnExpression)Add LIKE {tableAlias}.{columnExpression} to the expressionTlike(ColumnRef ref)Add LIKE {ref} to the expressionTlike(BindMarkerNode bindMarker)Add LIKE ? to the expressionTliteral(double value)Add a literal double value to the expressionTliteral(long value)Add a literal long value to the expressionTliteral(java.lang.String value)Add a literal String value to the expressionTlt()Add < to the expressionTlt(int literalValue)Add < {literalValue} to the expressionTlt(long literalValue)Add < {literalValue} to the expressionTlt(java.lang.String literalValue)Add < {literalValue} to the expressionTlt(ColumnRef ref)Add < {ref} to the expressionTlt(BindMarkerNode bindMarker)Add < {bindMarker} to the expressionTlte()Add <= to the expressionTlte(int literalValue)Add <= {literalValue} to the expressionTlte(long literalValue)Add <= {literalValue} to the expressionTlte(java.lang.String literalValue)Add <= {literalValue} to the expressionTlte(ColumnRef ref)Add <= ref to the expressionTlte(BindMarkerNode bindMarker)Add <= {bindMarker} to the expressionTmult()Add * to the expressionTneq()Add != to the expressionTneq(int literalValue)Add != {literalValue} to the expressionTneq(long literalValue)Add != {literalValue} to the expressionTneq(java.lang.String literalValue)Add != {literalValue} to the expressionTneq(ColumnRef ref)Add != {ref} to the expressionTneq(LiteralString str)Add != {str} to the expressionTneq(BindMarkerNode bindMarker)Add a bind marker and its value to the expressionTnot(ExpNode expr)Add NOT to the expressionTnotExists(Select correlatedSubSelect)Add a NOT EXISTS clause using the given correlated sub-select statementToperator(Operator op)Add the operator op to the expressionTor()Add OR to the expressionTor(java.lang.String element)Add OR {element} to the expression where element is typically a column nameTor(java.lang.String tableAlias, java.lang.String columnName)Add OR {tableAlias}.{columnName} to the expressionTor(ColumnRef ref)Add OR {ref} to the expressionTor(ExpNode predicate)Add OR {predicate} to the expressionTradians(ColumnRef arg)Add RADIANS(arg) to the expressionTradians(ExpNode arg)Add RADIANS(arg) to the expressionTrightParen()Add a right paren)to the expressionTsin(ColumnRef arg)Add SIN(arg) to the expressionTsin(ExpNode arg)Add SIN(arg) to the expressionTsub()Add - to the expressionTwhere(java.lang.String columnName)To simplify code, support multiple where clauses, treating each as an ANDTwhere(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:
-
-