aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/com/iciql/bytecode/CaseWhen.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2016-04-05 12:27:55 -0400
committerJames Moger <james.moger@gitblit.com>2016-04-05 12:27:55 -0400
commitbb87e621eefd97872aa1a619d38c166b2f07db84 (patch)
treed7199be13f0015e218ae2ded4ebd8af11b955845 /src/main/java/com/iciql/bytecode/CaseWhen.java
parent98bb5dc01796728de5b18f84e19766276d12d1db (diff)
downloadiciql-bb87e621eefd97872aa1a619d38c166b2f07db84.tar.gz
iciql-bb87e621eefd97872aa1a619d38c166b2f07db84.zip
Reformat project with default IntelliJ settings
Diffstat (limited to 'src/main/java/com/iciql/bytecode/CaseWhen.java')
-rw-r--r--src/main/java/com/iciql/bytecode/CaseWhen.java64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/main/java/com/iciql/bytecode/CaseWhen.java b/src/main/java/com/iciql/bytecode/CaseWhen.java
index 2a1d69e..bdf7fc5 100644
--- a/src/main/java/com/iciql/bytecode/CaseWhen.java
+++ b/src/main/java/com/iciql/bytecode/CaseWhen.java
@@ -26,37 +26,37 @@ import com.iciql.Token;
*/
public class CaseWhen implements Token {
- private final Token condition, ifTrue, ifFalse;
-
- private CaseWhen(Token condition, Token ifTrue, Token ifFalse) {
- this.condition = condition;
- this.ifTrue = ifTrue;
- this.ifFalse = ifFalse;
- }
-
- static Token get(Token condition, Token ifTrue, Token ifFalse) {
- if ("0".equals(ifTrue.toString()) && "1".equals(ifFalse.toString())) {
- return Not.get(condition);
- } else if ("1".equals(ifTrue.toString()) && "0".equals(ifFalse.toString())) {
- return condition;
- } else if ("0".equals(ifTrue.toString())) {
- return And.get(Not.get(condition), ifFalse);
- }
- return new CaseWhen(condition, ifTrue, ifFalse);
- }
-
- public String toString() {
- return "CASEWHEN(" + condition + ", " + ifTrue + ", " + ifFalse + ")";
- }
-
- public <T> void appendSQL(SQLStatement stat, Query<T> query) {
- stat.appendSQL("CASEWHEN ");
- condition.appendSQL(stat, query);
- stat.appendSQL(" THEN ");
- ifTrue.appendSQL(stat, query);
- stat.appendSQL(" ELSE ");
- ifFalse.appendSQL(stat, query);
- stat.appendSQL(" END");
- }
+ private final Token condition, ifTrue, ifFalse;
+
+ private CaseWhen(Token condition, Token ifTrue, Token ifFalse) {
+ this.condition = condition;
+ this.ifTrue = ifTrue;
+ this.ifFalse = ifFalse;
+ }
+
+ static Token get(Token condition, Token ifTrue, Token ifFalse) {
+ if ("0".equals(ifTrue.toString()) && "1".equals(ifFalse.toString())) {
+ return Not.get(condition);
+ } else if ("1".equals(ifTrue.toString()) && "0".equals(ifFalse.toString())) {
+ return condition;
+ } else if ("0".equals(ifTrue.toString())) {
+ return And.get(Not.get(condition), ifFalse);
+ }
+ return new CaseWhen(condition, ifTrue, ifFalse);
+ }
+
+ public String toString() {
+ return "CASEWHEN(" + condition + ", " + ifTrue + ", " + ifFalse + ")";
+ }
+
+ public <T> void appendSQL(SQLStatement stat, Query<T> query) {
+ stat.appendSQL("CASEWHEN ");
+ condition.appendSQL(stat, query);
+ stat.appendSQL(" THEN ");
+ ifTrue.appendSQL(stat, query);
+ stat.appendSQL(" ELSE ");
+ ifFalse.appendSQL(stat, query);
+ stat.appendSQL(" END");
+ }
}