public class CaseStatement extends BaseCaseStatement<CaseStatement>
"CASE WHEN <cond1> THEN <result1> [ WHEN
<cond2> THEN <result2> WHEN ... ] [ELSE <resultN>]
END"
EMPTY
ALL_SYMBOL, NULL_VALUE, QUESTION_MARK
Constructor and Description |
---|
CaseStatement() |
Modifier and Type | Method and Description |
---|---|
CaseStatement |
addWhen(Condition test,
Object result)
Adds a "WHEN" clause to the "CASE" statement.
|
protected void |
appendCustomIfNotNull(AppendableExt app,
SqlObject obj)
Appends the given custom clause to the given AppendableExt, handling
null and enclosing parens. |
protected void |
appendNestedClauses(AppendableExt app,
SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses)
Appends the given nested clauses to the given AppendableExt, handling
empty nested clauses and enclosing parens.
|
protected static boolean |
areEmpty(SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses)
Determines if any of the given clauses are non-empty.
|
protected void |
closeParen(AppendableExt app)
Appends a close parenthesis to the given AppendableExt if disableParens is
true , otherwise does nothing. |
boolean |
hasParens()
Returns
true iff the output of this instance would include
surrounding parentheses, false otherwise. |
protected static boolean |
hasParens(SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses)
Determines if any of the given clauses are non-empty.
|
boolean |
isDisableParens()
Returns whether or not wrapping parentheses are disabled for this clause
(for clauses which utilize wrapping parentheses).
|
protected void |
openParen(AppendableExt app)
Appends an open parenthesis to the given AppendableExt if disableParens is
true , otherwise does nothing. |
addCustomWhen, addElse, addElseNull, appendTo, collectSchemaObjects, getThisType, isEmpty, validate, validate
setDisableParens
collectSchemaObjects, doValidate, toString
toString, toString
public CaseStatement addWhen(Condition test, Object result)
Result Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
test
- the condition to test for this "WHEN" clauseresult
- the result to output if this "WHEN" clause is selectedpublic boolean isDisableParens()
false
.public boolean hasParens()
true
iff the output of this instance would include
surrounding parentheses, false
otherwise.
Default implementation returns !isEmpty() && !isDisableParens()
.
protected static boolean areEmpty(SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses)
false
if at least one clause is non-empty, true
otherwiseprotected static boolean hasParens(SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses)
false
if at least one clause is non-empty, true
otherwiseprotected void openParen(AppendableExt app) throws IOException
true
, otherwise does nothing.IOException
protected void closeParen(AppendableExt app) throws IOException
true
, otherwise does nothing.IOException
protected void appendCustomIfNotNull(AppendableExt app, SqlObject obj) throws IOException
null
and enclosing parens.IOException
protected void appendNestedClauses(AppendableExt app, SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses) throws IOException
IOException
Copyright © 2006–2021 OpenHMS. All rights reserved.