myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject [myfaces-tobago] branch master updated: clean up:
Date Wed, 23 May 2018 08:30:59 GMT
This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d4cf29  clean up:
0d4cf29 is described below

commit 0d4cf297acb648a304dff82788a4d9dfd3127a5d
Author: Udo Schnurpfeil <lofwyr@apache.org>
AuthorDate: Fri May 18 12:55:39 2018 +0200

    clean up:
    
    * replace array initialization in List.toArray with 0 length,
      because the "size" way was only recommended til Java 6.
    * Simplify String building.
---
 .../main/java/org/apache/myfaces/tobago/context/Markup.java  |  2 +-
 .../myfaces/tobago/event/ResetInputActionListener.java       |  2 +-
 .../org/apache/myfaces/tobago/event/TreeExpansionEvent.java  |  8 ++------
 .../tobago/internal/component/AbstractUITabGroup.java        |  2 +-
 .../tobago/internal/renderkit/renderer/FileRenderer.java     |  2 +-
 .../tobago/internal/renderkit/renderer/SheetRenderer.java    |  2 +-
 .../renderkit/renderer/TobagoClientBehaviorRenderer.java     |  6 ++----
 .../org/apache/myfaces/tobago/internal/util/StringUtils.java |  4 ++--
 .../apache/myfaces/tobago/renderkit/css/BootstrapClass.java  |  2 +-
 .../org/apache/myfaces/tobago/renderkit/css/TobagoClass.java |  8 ++------
 .../myfaces/tobago/internal/util/JsonUtilsUnitTest.java      |  4 ++--
 .../myfaces/tobago/renderkit/css/TobagoClassUnitTest.java    |  2 +-
 .../apache/myfaces/tobago/example/demo/CantorInterval.java   | 12 +++---------
 .../myfaces/tobago/example/demo/TreeSelectController.java    |  3 ++-
 .../myfaces/tobago/example/demo/info/ActivityList.java       | 10 +++-------
 .../myfaces/tobago/renderkit/css/BootstrapClassUnitTest.java |  2 +-
 16 files changed, 26 insertions(+), 45 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
index efd612e..bc6924c 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/context/Markup.java
@@ -307,7 +307,7 @@ public final class Markup implements Serializable, Iterable<String>
{
       for (final Object object : (Iterable) value) {
         list.add(object.toString());
       }
-      return valueOf(list.toArray(new String[list.size()]));
+      return valueOf(list.toArray(new String[0]));
     }
     return valueOf(value.toString());
   }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java
index 3c30a59..3d8b37b 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ResetInputActionListener.java
@@ -39,7 +39,7 @@ public class ResetInputActionListener extends AbstractResetInputActionListener
i
   }
 
   public ResetInputActionListener(final Collection<String> clientIds) {
-     this.clientIds = clientIds.toArray(new String[clientIds.size()]);
+     this.clientIds = clientIds.toArray(new String[0]);
   }
 
   @Override
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/event/TreeExpansionEvent.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/event/TreeExpansionEvent.java
index 183015c..5c7089a 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/event/TreeExpansionEvent.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/event/TreeExpansionEvent.java
@@ -45,7 +45,7 @@ public class TreeExpansionEvent extends FacesEvent {
   public void processListener(final FacesListener facesListener) {
     if (facesListener instanceof TreeExpansionListener) {
       if (oldExpanded && !newExpanded) {
-   //todo     ((TreeExpansionListener) facesListener).treeCollapsed(this);
+        //todo ((TreeExpansionListener) facesListener).treeCollapsed(this);
         ((TreeExpansionListener) facesListener).treeExpanded(this);
       } else if (!oldExpanded && newExpanded) {
         ((TreeExpansionListener) facesListener).treeExpanded(this);
@@ -65,10 +65,6 @@ public class TreeExpansionEvent extends FacesEvent {
 
   @Override
   public String toString() {
-    return new StringBuilder()
-        .append(super.toString())
-        .append("expanded=")
-        .append(newExpanded)
-        .toString();
+    return super.toString() + "expanded=" + newExpanded;
   }
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java
index ef5b0b4..896effd 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java
@@ -92,7 +92,7 @@ public abstract class AbstractUITabGroup extends AbstractUIPanelBase
         LOG.error("Invalid component in UITabGroup: " + kid);
       }
     }
-    return tabs.toArray(new AbstractUITab[tabs.size()]);
+    return tabs.toArray(new AbstractUITab[0]);
   }
 
   public AbstractUITab getActiveTab() {
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
index 509898e..77867f6 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/FileRenderer.java
@@ -88,7 +88,7 @@ public class FileRenderer extends MessageLayoutRendererBase implements Component
                   PartUtils.getSubmittedFileName(part), part.getSize(), part.getContentType());
               parts.add(new HttpPartWrapper(part));
             }
-            file.setSubmittedValue(parts.toArray(new Part[parts.size()]));
+            file.setSubmittedValue(parts.toArray(new Part[0]));
           }
         } else {
           final Part part = httpServletRequest.getPart(file.getClientId(facesContext));
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
index 5afde82..d76b794 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java
@@ -334,7 +334,7 @@ public class SheetRenderer extends RendererBase {
       }
 
       encodeHiddenInput(writer,
-          JsonUtils.encode(encodedRendered.toArray(new String[encodedRendered.size()]), false),
+          JsonUtils.encode(encodedRendered.toArray(new String[0]), false),
           sheetId + SUFFIX_COLUMN_RENDERED);
     }
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
index e5d68e6..0626f14 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TobagoClientBehaviorRenderer.java
@@ -81,8 +81,7 @@ public class TobagoClientBehaviorRenderer extends javax.faces.render.ClientBehav
       final Collection<String> render = ajaxBehavior.getRender();
       final String clientId = uiComponent.getClientId(facesContext);
 
-      executeIds
-          = ComponentUtils.evaluateClientIds(facesContext, uiComponent, execute.toArray(new
String[execute.size()]));
+      executeIds = ComponentUtils.evaluateClientIds(facesContext, uiComponent, execute.toArray(new
String[0]));
       if (executeIds != null) {
         executeIds = executeIds + " " + clientId;
       } else {
@@ -94,8 +93,7 @@ public class TobagoClientBehaviorRenderer extends javax.faces.render.ClientBehav
         target = command.getTarget();
         omit = command.isOmit() || StringUtils.isNotBlank(RenderUtils.generateUrl(facesContext,
command));
       }
-      renderIds =
-          ComponentUtils.evaluateClientIds(facesContext, uiComponent, render.toArray(new
String[render.size()]));
+      renderIds = ComponentUtils.evaluateClientIds(facesContext, uiComponent, render.toArray(new
String[0]));
       actionId = clientId;
     } else if (behavior instanceof EventBehavior) { // <tc:event>
       final EventBehavior eventBehavior = (EventBehavior) behavior;
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/StringUtils.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/StringUtils.java
index 26620bb..a677b1b 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/StringUtils.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/StringUtils.java
@@ -227,7 +227,7 @@ public final class StringUtils {
     if (match) {
       list.add(string.substring(start, i));
     }
-    return list.toArray(new String[list.size()]);
+    return list.toArray(new String[0]);
   }
 
   /**
@@ -307,7 +307,7 @@ public final class StringUtils {
     if (match) {
       list.add(string.substring(start, i));
     }
-    return list.toArray(new String[list.size()]);
+    return list.toArray(new String[0]);
   }
 
   /**
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
index e2015f2..ead4342 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
@@ -670,7 +670,7 @@ public enum BootstrapClass implements CssItem {
       generateOffset(result, attributes.get(Attributes.offsetMedium.name()), OFFSET_MEDIUM);
       generateOffset(result, attributes.get(Attributes.offsetLarge.name()), OFFSET_LARGE);
       generateOffset(result, attributes.get(Attributes.offsetExtraLarge.name()), OFFSET_EXTRA_LARGE);
-      return result.toArray(new BootstrapClass[result.size()]);
+      return result.toArray(new BootstrapClass[0]);
     }
 
     private void generate(
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
index 7e8144a..35e280c 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/TobagoClass.java
@@ -266,7 +266,7 @@ public enum TobagoClass implements CssItem {
       for (final String markupString : markup) {
         markups.add(new MarkupClass(this, markupString));
       }
-      return markups.toArray(new CssItem[markups.size()]);
+      return markups.toArray(new CssItem[0]);
     } else {
       return null;
     }
@@ -285,11 +285,7 @@ public enum TobagoClass implements CssItem {
     @Override
     public String getName() {
       // These values are statistically tested length of the html class attribute
-      final StringBuilder builder = new StringBuilder(80);
-      builder.append(rendererClass.getName());
-      builder.append("-markup-");
-      builder.append(markup);
-      return builder.toString();
+      return rendererClass.getName() + "-markup-" + markup;
     }
   }
 }
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/util/JsonUtilsUnitTest.java
b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/util/JsonUtilsUnitTest.java
index ca52114..49bc9f7 100644
--- a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/util/JsonUtilsUnitTest.java
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/util/JsonUtilsUnitTest.java
@@ -172,8 +172,8 @@ public class JsonUtilsUnitTest extends AbstractTobagoTestBase {
 
     Assert.assertEquals(expectedA, JsonUtils.encode(a));
     Assert.assertEquals(expectedAb, JsonUtils.encode(ab));
-    Assert.assertEquals(null, JsonUtils.encode(Markup.NULL));
-    Assert.assertEquals(null, JsonUtils.encode((Markup) null));
+    Assert.assertNull(JsonUtils.encode(Markup.NULL));
+    Assert.assertNull(JsonUtils.encode((Markup) null));
 
   }
 
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/css/TobagoClassUnitTest.java
b/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/css/TobagoClassUnitTest.java
index c22067f..97d01cc 100644
--- a/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/css/TobagoClassUnitTest.java
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/renderkit/css/TobagoClassUnitTest.java
@@ -82,7 +82,7 @@ public class TobagoClassUnitTest {
 
     final List<CssItem> missing =
         CssClassUtils.compareCss("src/main/resources/scss/_tobago.scss",
-        toCheck.toArray(new CssItem[toCheck.size()]));
+        toCheck.toArray(new CssItem[0]));
 
     Assert.assertTrue("These classes are missing in _tobago.scss: " + missing, missing.isEmpty());
   }
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/CantorInterval.java
b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/CantorInterval.java
index 07453a2..49aeb6b 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/CantorInterval.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/CantorInterval.java
@@ -26,8 +26,8 @@ import java.math.BigInteger;
 import java.util.Enumeration;
 
 /**
- * Builds a tree with the iterations of the <a href="http://en.wikipedia.org/wiki/Cantor_set">Cantor
set</a>.
- * The tree is infinitive, so it will be created on the fly.
+ * Builds a tree with the iterations of the <a href="http://en.wikipedia.org/wiki/Cantor_set">Cantor
set</a>. The tree
+ * is infinitive, so it will be created on the fly.
  */
 public class CantorInterval extends DefaultMutableTreeNode {
 
@@ -78,13 +78,7 @@ public class CantorInterval extends DefaultMutableTreeNode {
   }
 
   public String getLabel() {
-    final StringBuilder builder = new StringBuilder();
-    builder.append("[");
-    builder.append(begin);
-    builder.append(", ");
-    builder.append(end);
-    builder.append("]");
-    return builder.toString();
+    return "[" + begin + ", " + end + "]";
   }
 
   public String toString() {
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeSelectController.java
b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeSelectController.java
index f54f8d4..dca962c 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeSelectController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeSelectController.java
@@ -70,7 +70,8 @@ public class TreeSelectController implements Serializable {
   private void buildSelectedNodesString(final StringBuilder stringBuilder, final DefaultMutableTreeNode
node) {
     final Node userObject = (Node) node.getUserObject();
     if (userObject.isSelected()) {
-      stringBuilder.append(", " + userObject.getName());
+      stringBuilder.append(", ");
+      stringBuilder.append(userObject.getName());
     }
     for (int i = 0; i < node.getChildCount(); i++) {
       final DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i);
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/info/ActivityList.java
b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/info/ActivityList.java
index 0560200..dfe28b2 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/info/ActivityList.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/info/ActivityList.java
@@ -26,7 +26,6 @@ import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Named;
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
@@ -42,20 +41,17 @@ public class ActivityList implements Serializable {
   private Map<String, Activity> data = new ConcurrentHashMap<>();
 
   public void add(final Activity activity) {
-    LOG.info("Adding session id: " + activity.getSessionId());
+    LOG.info("Adding session id: '{}'", activity.getSessionId());
     data.put(activity.getSessionId(), activity);
   }
 
   public void remove(final String sessionId) {
-    LOG.info("Removing session id: " + sessionId);
+    LOG.info("Removing session id: '{}'", sessionId);
     data.remove(sessionId);
   }
 
   public List<Activity> getValues() {
-    final Collection<Activity> values = data.values();
-    final ArrayList<Activity> result = new ArrayList<>();
-    result.addAll(values);
-    return result;
+    return new ArrayList<>(data.values());
   }
 
   public void executeJsfRequest(final String sessionId) {
diff --git a/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClassUnitTest.java
b/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClassUnitTest.java
index 3aac862..4224806 100644
--- a/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClassUnitTest.java
+++ b/tobago-theme/tobago-theme-standard/src/test/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClassUnitTest.java
@@ -81,7 +81,7 @@ public class BootstrapClassUnitTest {
 
     final List<CssItem> missing = CssClassUtils.compareCss(
         "src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/css/bootstrap.css",
-        toCheck.toArray(new BootstrapClass[toCheck.size()]));
+        toCheck.toArray(new BootstrapClass[0]));
 
     Assert.assertTrue("These classes are missing in bootstrap.css: " + missing, missing.isEmpty());
   }

-- 
To stop receiving notification emails like this one, please contact
lofwyr@apache.org.

Mime
View raw message