[view] extracted lambda to method
authorAsier Lostalé <asier.lostale@openbravo.com>
Tue, 07 Aug 2018 08:48:24 +0200
changeset 35075 2388b7bdd44a
parent 35074 9e0c546f3a14
child 35076 d77908083eb4
[view] extracted lambda to method
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java
--- a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java	Tue Aug 07 08:44:29 2018 +0200
+++ b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/StandardWindowComponent.java	Tue Aug 07 08:48:24 2018 +0200
@@ -233,25 +233,25 @@
     Map<String, List<GCTab>> gcsByTab = qGCTab.stream() //
         .collect(groupingBy(gcTab -> gcTab.getTab().getId()));
 
-    return window
-        .getADTabList()
-        .stream()
-        .map(
-            tb -> {
-              Stream<GCTab> candidates = gcsByTab.containsKey(tb.getId()) ? gcsByTab
-                  .get(tb.getId()).stream() : Stream.empty();
-
-              Optional<GCTab> selectedGC = candidates //
-                  .sorted((o1, o2) -> {
-                    if (o2.getSeqno().compareTo(o1.getSeqno()) != 0) {
-                      return o2.getSeqno().compareTo(o1.getSeqno());
-                    } else {
-                      return o2.getId().compareTo(o1.getId());
-                    }
-                  }) //
-                  .findFirst();
-              return new SimpleEntry<>(tb.getId(), selectedGC);
-            }) //
+    return window.getADTabList().stream() //
+        .map(tab -> getTabConfig(tab, gcsByTab)) //
         .collect(toMap(SimpleEntry::getKey, SimpleEntry::getValue));
   }
+
+  private static SimpleEntry<String, Optional<GCTab>> getTabConfig(Tab tab,
+      Map<String, List<GCTab>> gcsByTab) {
+    Stream<GCTab> candidates = gcsByTab.containsKey(tab.getId()) ? gcsByTab.get(tab.getId())
+        .stream() : Stream.empty();
+
+    Optional<GCTab> selectedGC = candidates //
+        .sorted((o1, o2) -> {
+          if (o2.getSeqno().compareTo(o1.getSeqno()) != 0) {
+            return o2.getSeqno().compareTo(o1.getSeqno());
+          } else {
+            return o2.getId().compareTo(o1.getId());
+          }
+        }) //
+        .findFirst();
+    return new SimpleEntry<>(tab.getId(), selectedGC);
+  }
 }