Skip to content

Commit

Permalink
[#6053] KeywordImpl should cache the AS_IS, UPPER, LOWER renderings
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaseder committed Apr 8, 2017
1 parent 9dc857d commit f331291
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions jOOQ/src/main/java/org/jooq/impl/KeywordImpl.java
Expand Up @@ -37,6 +37,7 @@
import org.jooq.Clause; import org.jooq.Clause;
import org.jooq.Context; import org.jooq.Context;
import org.jooq.Keyword; import org.jooq.Keyword;
import org.jooq.conf.RenderKeywordStyle;


/** /**
* A default {@link Keyword} implementation. * A default {@link Keyword} implementation.
Expand All @@ -50,15 +51,26 @@ public class KeywordImpl extends AbstractQueryPart implements Keyword {
*/ */
private static final long serialVersionUID = 9137269798087732005L; private static final long serialVersionUID = 9137269798087732005L;


private final String keyword; private final String asIs;
private final String upper;
private final String lower;


KeywordImpl(String keyword) { KeywordImpl(String keyword) {
this.keyword = keyword; this.asIs = keyword;
this.upper = keyword.toUpperCase();
this.lower = keyword.toLowerCase();
} }


@Override @Override
public final void accept(Context<?> ctx) { public final void accept(Context<?> ctx) {
ctx.keyword(keyword); RenderKeywordStyle style = ctx.settings().getRenderKeywordStyle();

if (RenderKeywordStyle.AS_IS == style)
ctx.sql(asIs, true);
else if (RenderKeywordStyle.UPPER == style)
ctx.sql(upper, true);
else
ctx.sql(lower, true);
} }


@Override @Override
Expand Down

0 comments on commit f331291

Please sign in to comment.