Simplify code using Java 8 features
[controller.git] / opendaylight / md-sal / mdsal-trace / dom-impl / src / main / java / org / opendaylight / controller / md / sal / trace / closetracker / impl / CloseTrackedRegistry.java
index 78a09f1..7f99824 100644 (file)
@@ -13,6 +13,7 @@ import static java.util.Collections.emptyList;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -32,8 +33,8 @@ public class CloseTrackedRegistry<T extends CloseTracked<T>> {
     private final Object anchor;
     private final String createDescription;
 
-    private final Set<CloseTracked<T>> tracked = new ConcurrentSkipListSet<>(
-        (o1, o2) -> Integer.compare(System.identityHashCode(o1), System.identityHashCode(o2)));
+    private final Set<CloseTracked<T>> tracked =
+        new ConcurrentSkipListSet<>(Comparator.comparingInt(System::identityHashCode));
 
     private final boolean isDebugContextEnabled;
 
@@ -101,16 +102,13 @@ public class CloseTrackedRegistry<T extends CloseTracked<T>> {
         }
 
         Set<CloseTrackedRegistryReportEntry<T>> report = new HashSet<>();
-        map.forEach((stackTraceElements, number) -> {
-            copyOfTracked.stream().filter(closeTracked -> {
-                StackTraceElement[] closeTrackedStackTraceArray = closeTracked.getAllocationContextStackTrace();
-                List<StackTraceElement> closeTrackedStackTraceElements =
-                        closeTrackedStackTraceArray != null ? asList(closeTrackedStackTraceArray) : emptyList();
-                return closeTrackedStackTraceElements.equals(stackTraceElements);
-            }).findAny().ifPresent(exampleCloseTracked -> {
-                report.add(new CloseTrackedRegistryReportEntry<>(exampleCloseTracked, number, stackTraceElements));
-            });
-        });
+        map.forEach((stackTraceElements, number) -> copyOfTracked.stream().filter(closeTracked -> {
+            StackTraceElement[] closeTrackedStackTraceArray = closeTracked.getAllocationContextStackTrace();
+            List<StackTraceElement> closeTrackedStackTraceElements =
+                closeTrackedStackTraceArray != null ? asList(closeTrackedStackTraceArray) : emptyList();
+            return closeTrackedStackTraceElements.equals(stackTraceElements);
+        }).findAny().ifPresent(exampleCloseTracked -> report.add(
+            new CloseTrackedRegistryReportEntry<>(exampleCloseTracked, number, stackTraceElements))));
         return report;
     }
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.