Simplify code using Java 8 features
authorStephen Kitt <skitt@redhat.com>
Mon, 23 Jul 2018 15:31:33 +0000 (17:31 +0200)
committerStephen Kitt <skitt@redhat.com>
Wed, 25 Jul 2018 12:03:20 +0000 (14:03 +0200)
* List::sort
* lambda expressions
* Comparator::comparing...
* Collection::removeIf
* method references
* Map::computeIfAbsent
* Map::merge

Change-Id: I1793591c071c7ce5465939afe8b4846b769b5953
Signed-off-by: Stephen Kitt <skitt@redhat.com>
src/main/java/org/opendaylight/controller/blueprint/BlueprintBundleTracker.java
src/main/java/org/opendaylight/controller/blueprint/ext/ActionProviderBean.java

index 4d7780147caab1dbdf68cf37131dbc9dbc7f2981..d3db3277425bcd0d5c22dca72352e9a055baa904 100644 (file)
@@ -308,7 +308,7 @@ public class BlueprintBundleTracker implements BundleActivator, BundleTrackerCus
         }
 
         if (!bundlesToDestroy.isEmpty()) {
-            Collections.sort(bundlesToDestroy, (b1, b2) -> (int) (b2.getLastModified() - b1.getLastModified()));
+            bundlesToDestroy.sort((b1, b2) -> (int) (b2.getLastModified() - b1.getLastModified()));
 
             LOG.debug("Selected bundles {} for destroy (no services in use)", bundlesToDestroy);
         } else {
index 70054f86a94549aadde13eb35106146ac459b0e8..af943f91dec4c763e3a4dd132c235cbfa69d4c72 100644 (file)
@@ -129,10 +129,9 @@ public class ActionProviderBean {
         }
 
         final Set<DOMRpcIdentifier> rpcs = ImmutableSet.copyOf(Collections2.transform(paths, DOMRpcIdentifier::create));
-        reg = domRpcProvider.registerRpcImplementation((rpc, input) -> {
-            return FluentFutures.immediateFailedFluentFuture(new DOMRpcImplementationNotAvailableException(
-                "Action %s has no instance matching %s", rpc, input));
-        }, rpcs);
+        reg = domRpcProvider.registerRpcImplementation(
+            (rpc, input) -> FluentFutures.immediateFailedFluentFuture(new DOMRpcImplementationNotAvailableException(
+                "Action %s has no instance matching %s", rpc, input)), rpcs);
         LOG.debug("Registered provider for {}", interfaceName);
     }