use of org.jooq.CaseValueStep 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;
}
Aggregations