cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject cayenne git commit: CAY-2485 Compact Slf4j Logger
Date Mon, 14 Jan 2019 10:35:42 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 6bb83bbee -> 26769e966


CAY-2485 Compact Slf4j Logger


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/26769e96
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/26769e96
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/26769e96

Branch: refs/heads/master
Commit: 26769e966c48382775042813294fa839acd911e4
Parents: 6bb83bb
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Mon Jan 14 13:35:35 2019 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Mon Jan 14 13:35:35 2019 +0300

----------------------------------------------------------------------
 .../log/CompactSlf4jJdbcEventLogger.java        | 25 +++++++-------------
 1 file changed, 8 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/26769e96/cayenne-server/src/main/java/org/apache/cayenne/log/CompactSlf4jJdbcEventLogger.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/log/CompactSlf4jJdbcEventLogger.java
b/cayenne-server/src/main/java/org/apache/cayenne/log/CompactSlf4jJdbcEventLogger.java
index b6ea8b3..c74cd7a 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/log/CompactSlf4jJdbcEventLogger.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/log/CompactSlf4jJdbcEventLogger.java
@@ -37,10 +37,10 @@ import java.util.stream.Collectors;
  */
 public class CompactSlf4jJdbcEventLogger extends Slf4jJdbcEventLogger {
 
-    private static final String UNION = "UNION";
+    private static final String UNION  = "UNION";
     private static final String SELECT = "SELECT";
-    private static final String FROM = "FROM";
-    private static final String SPACE = " ";
+    private static final String FROM   = "FROM";
+    private static final char   SPACE  = ' ';
 
     public CompactSlf4jJdbcEventLogger(@Inject RuntimeProperties runtimeProperties) {
         super(runtimeProperties);
@@ -63,21 +63,12 @@ public class CompactSlf4jJdbcEventLogger extends Slf4jJdbcEventLogger
{
     }
 
     protected String processUnionSql(String sql) {
-
-        String modified = Pattern.compile(UNION.toLowerCase(), Pattern.CASE_INSENSITIVE).matcher(sql).replaceAll(UNION);
+        String modified = Pattern.compile(UNION.toLowerCase(), Pattern.CASE_INSENSITIVE)
+                .matcher(sql).replaceAll(UNION);
         String[] queries = modified.split(UNION);
-        List<String> formattedQueries = Arrays.stream(queries).map(this::trimSqlSelectColumns).collect(Collectors.toList());
-        StringBuilder buffer = new StringBuilder();
-        boolean used =  false;
-        for (String q: formattedQueries) {
-            if(!used){
-                used = true;
-            } else {
-                buffer.append(SPACE).append(UNION);
-            }
-            buffer.append(q);
-        }
-        return buffer.toString();
+        return Arrays.stream(queries)
+                .map(this::trimSqlSelectColumns)
+                .collect(Collectors.joining(SPACE + UNION));
     }
 
     protected String trimSqlSelectColumns(String sql) {


Mime
View raw message