From 0721d404d1fa1709e48389fb1c9f99170a8ec6ec Mon Sep 17 00:00:00 2001 From: Alvari Date: Wed, 5 Feb 2025 09:45:11 +1300 Subject: [PATCH] modified a loop to use string builder when concatenating a string within a loop to boost performance. I also added missing override annotations to comply with codestyle conventions --- .../main/java/io/xream/sqli/builder/QB.java | 46 +++++++++++++++++++ .../java/io/xream/sqli/util/ParserUtil.java | 8 ++-- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/sqli-builder/src/main/java/io/xream/sqli/builder/QB.java b/sqli-builder/src/main/java/io/xream/sqli/builder/QB.java index 93a95a5..b1eabbf 100644 --- a/sqli-builder/src/main/java/io/xream/sqli/builder/QB.java +++ b/sqli-builder/src/main/java/io/xream/sqli/builder/QB.java @@ -142,63 +142,78 @@ protected Q get() { return this.q; } + @Override public Q build() { this.q.setAbort(isAbort); return this.q; } + @Override public QB eq(String property, Object value) { return (QB) super.eq(property, value); } + @Override public QB gt(String property, Object value) { return (QB) super.gt(property, value); } + @Override public QB gte(String property, Object value) { return (QB) super.gte(property, value); } + @Override public QB lt(String property, Object value) { return (QB) super.lt(property, value); } + @Override public QB lte(String property, Object value) { return (QB) super.lte(property, value); } + @Override public QB ne(String property, Object value) { return (QB) super.ne(property, value); } + @Override public QB like(String property, String value) { return (QB) super.like(property, value); } + @Override public QB likeLeft(String property, String value) { return (QB) super.likeLeft(property, value); } + @Override public QB notLike(String property, String value) { return (QB) super.notLike(property, value); } + @Override public QB in(String property, List list) { return (QB) super.in(property, list); } + @Override public QB inRequired(String property, List list) { return (QB) super.inRequired(property, list); } + @Override public QB nin(String property, List list) { return (QB) super.nin(property, list); } + @Override public QB nonNull(String property) { return (QB) super.nonNull(property); } + @Override public QB isNull(String property) { return (QB) super.isNull(property); } @@ -207,26 +222,32 @@ public QB x(String sqlSegment) { return (QB) super.x(sqlSegment); } + @Override public QB x(String sqlSegment, Object... values) { return (QB) super.x(sqlSegment, values); } + @Override public QB and(SubCond sub) { return (QB) super.and(sub); } + @Override public QB or(SubCond sub) { return (QB) super.or(sub); } + @Override public QB bool(Bool cond, Then then) { return (QB) super.bool(cond, then); } + @Override public QB any(Any any) { return (QB)super.any(any); } + @Override public QB or() { return (QB) super.or(); } @@ -451,6 +472,7 @@ public X distinct(String... objs) { return this; } + public X groupBy(String property) { get().setGroupBy(property); return this; @@ -504,95 +526,118 @@ public X reduce(ReduceType type, String property, Bb havingBb) { } + @Override public X eq(String property, Object value) { return (X) super.eq(property, value); } + @Override public X gt(String property, Object value) { return (X) super.gt(property, value); } + @Override public X gte(String property, Object value) { return (X) super.gte(property, value); } + @Override public X lt(String property, Object value) { return (X) super.lt(property, value); } + @Override public X lte(String property, Object value) { return (X) super.lte(property, value); } + @Override public X ne(String property, Object value) { return (X) super.ne(property, value); } + @Override public X like(String property, String value) { return (X) super.like(property, value); } + @Override public X likeLeft(String property, String value) { return (X) super.likeLeft(property, value); } + @Override public X notLike(String property, String value) { return (X) super.notLike(property, value); } + @Override public X in(String property, List list) { return (X) super.in(property, list); } + @Override public X inRequired(String property, List list) { return (X) super.inRequired(property, list); } + @Override public X nin(String property, List list) { return (X) super.nin(property, list); } + @Override public X nonNull(String property) { return (X) super.nonNull(property); } + @Override public X isNull(String property) { return (X) super.isNull(property); } + @Override public X x(String sqlSegment) { return (X) super.x(sqlSegment); } + @Override public X x(String sqlSegment, Object... values) { return (X) super.x(sqlSegment, values); } + @Override public X and(SubCond sub) { return (X) super.and(sub); } + @Override public X or(SubCond sub) { return (X) super.or(sub); } + @Override public X bool(Bool cond, Then then) { return (X) super.bool(cond, then); } + @Override public X any(Any any) { return (X) super.any(any); } + @Override public X or() { return (X) super.or(); } + @Override public void clear() { super.clear(); } + @Override public X paged(Pageable pageable) { super.paged(pageable); @@ -600,6 +645,7 @@ public X paged(Pageable pageable) { return this; } + @Override public X last(String lastSqlSegment) { super.last(lastSqlSegment); return this; diff --git a/sqli-builder/src/main/java/io/xream/sqli/util/ParserUtil.java b/sqli-builder/src/main/java/io/xream/sqli/util/ParserUtil.java index 98ac4ad..c9b3d04 100644 --- a/sqli-builder/src/main/java/io/xream/sqli/util/ParserUtil.java +++ b/sqli-builder/src/main/java/io/xream/sqli/util/ParserUtil.java @@ -457,17 +457,17 @@ public static String getMapper(String property) { } - String str = ""; + StringBuilder str = new StringBuilder(); int size = list.size(); for (int i = 0; i < size; i++) { String s = list.get(i); - str += s; + str.append(s); if (i < size - 1) { - str += "_"; + str.append("_"); } } - return str; + return str.toString(); } } catch (Exception e) {