[PATCH] More idiomatic Java string concat

Wald Commits scm-commit at wald.intevation.org
Tue Aug 5 16:34:08 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1407249244 -7200
# Node ID 86c1ff462fb5cc70d8e02e2a79265917422f2bb1
# Parent  9ecd6267323be18c67621bbd43fc4682905a873a
More idiomatic Java string concat.

diff -r 9ecd6267323b -r 86c1ff462fb5 gwt-client/src/main/java/org/dive4elements/river/client/shared/model/DefaultData.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/DefaultData.java	Thu Jul 31 18:14:22 2014 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/shared/model/DefaultData.java	Tue Aug 05 16:34:04 2014 +0200
@@ -128,16 +128,17 @@
      * @return colon separated string.
      */
     public String getStringValue() {
-        String data = "";
+        StringBuilder sb = new StringBuilder();
         boolean first = true;
         for (int i = 0; i < items.length; i++) {
             if (!first) {
-                data += ";";
+                sb.append(';');
+            } else {
+                first = false;
             }
-            data += items[i].getStringValue();
-            first = false;
+            sb.append(items[i].getStringValue());
         }
-        return data;
+        return sb.toString();
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :


More information about the Dive4Elements-commits mailing list