use of org.jooq.CaseConditionStep in project jOOQ by jOOQ.
the class ParserImpl method parseFieldCaseIf.
private static final Field<?> parseFieldCaseIf(ParserContext ctx) {
if (parseKeywordIf(ctx, "CASE")) {
if (parseKeywordIf(ctx, "WHEN")) {
CaseConditionStep step = null;
Field result;
do {
Condition condition = parseCondition(ctx);
parseKeyword(ctx, "THEN");
Field value = parseField(ctx);
step = step == null ? when(condition, value) : step.when(condition, value);
} while (parseKeywordIf(ctx, "WHEN"));
if (parseKeywordIf(ctx, "ELSE"))
result = step.otherwise(parseField(ctx));
else
result = step;
parseKeyword(ctx, "END");
return result;
} else {
CaseValueStep init = choose(parseField(ctx));
CaseWhenStep step = null;
Field result;
parseKeyword(ctx, "WHEN");
do {
Field when = parseField(ctx);
parseKeyword(ctx, "THEN");
Field then = parseField(ctx);
step = step == null ? init.when(when, then) : step.when(when, then);
} while (parseKeywordIf(ctx, "WHEN"));
if (parseKeywordIf(ctx, "ELSE"))
result = step.otherwise(parseField(ctx));
else
result = step;
parseKeyword(ctx, "END");
return result;
}
}
return null;
}
use of org.jooq.CaseConditionStep in project jOOQ by jOOQ.
the class DefaultParseContext method parseFieldCaseIf.
private final Field<?> parseFieldCaseIf() {
if (parseKeywordIf("CASE")) {
if (parseKeywordIf("WHEN")) {
CaseConditionStep step = null;
Field result;
do {
Condition condition = parseCondition();
parseKeyword("THEN");
Field value = parseField();
step = step == null ? when(condition, value) : step.when(condition, value);
} while (parseKeywordIf("WHEN"));
if (parseKeywordIf("ELSE"))
result = step.otherwise(parseField());
else
result = step;
parseKeyword("END");
return result;
} else {
CaseValueStep init = choose(parseField());
CaseWhenStep step = null;
Field result;
parseKeyword("WHEN");
do {
Field when = parseField();
parseKeyword("THEN");
Field then = parseField();
step = step == null ? init.when(when, then) : step.when(when, then);
} while (parseKeywordIf("WHEN"));
if (parseKeywordIf("ELSE"))
result = step.otherwise(parseField());
else
result = step;
parseKeyword("END");
return result;
}
}
return null;
}
Aggregations