Use List::sort instead of Collections::sort 89/69389/2
authorStephen Kitt <skitt@redhat.com>
Mon, 12 Mar 2018 16:33:26 +0000 (17:33 +0100)
committerFaseela K <faseela.k@ericsson.com>
Thu, 15 Mar 2018 05:39:40 +0000 (05:39 +0000)
Change-Id: Ia9949460dd3e09b00cabd887a70386e42370734c
Signed-off-by: Stephen Kitt <skitt@redhat.com>
idmanager/idmanager-impl/src/main/java/org/opendaylight/genius/idmanager/IdManager.java
interfacemanager/interfacemanager-impl/src/main/java/org/opendaylight/genius/interfacemanager/servicebindings/flowbased/utilities/FlowBasedServicesUtils.java
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/mdsalutil/interfaces/testutils/TestIMdsalApiManager.java

index c6a016b99f821d53d47dadbeac8db708c4af0c93..547f8d94f941b41136199da66538d0be61576233 100644 (file)
@@ -424,7 +424,7 @@ public class IdManager implements IdManagerService, IdManagerMonitor {
         List<ChildPools> childPoolsList = parentIdPool.getChildPools();
         // Sorting the child pools on last accessed time so that the pool that
         // was not accessed for a long time comes first.
-        Collections.sort(childPoolsList, comparing(ChildPools::getLastAccessTime));
+        childPoolsList.sort(comparing(ChildPools::getLastAccessTime));
         long currentTime = System.currentTimeMillis() / 1000;
         for (ChildPools childPools : childPoolsList) {
             if (childPools.getLastAccessTime() + DEFAULT_IDLE_TIME > currentTime) {
index 38720477ce3f1e98b4474aded1e1fbfb2789b58a..cd7884fe7a6a56edd0438df6143e786705410148 100644 (file)
@@ -14,6 +14,7 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -593,8 +594,7 @@ public final class FlowBasedServicesUtils {
         BoundServices lower = null;
 
         List<BoundServices> availableServiceInfos = new ArrayList<>(serviceInfos);
-        Collections.sort(availableServiceInfos, (serviceInfo1, serviceInfo2) -> serviceInfo1.getServicePriority()
-                .compareTo(serviceInfo2.getServicePriority()));
+        availableServiceInfos.sort(Comparator.comparing(BoundServices::getServicePriority));
         for (BoundServices availableServiceInfo : availableServiceInfos) {
             if (currentServiceInfo.getServicePriority() < availableServiceInfo.getServicePriority()) {
                 lower = availableServiceInfo;
index 765a9009dac01c0f9ceddd11a07873de23691ee3..38c8c8a14c95c04dfea9b6eda9f1c6ad8c471347 100644 (file)
@@ -22,7 +22,6 @@ import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.Futures;
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import org.junit.ComparisonFailure;
 import org.mockito.Mockito;
@@ -158,11 +157,10 @@ public abstract class TestIMdsalApiManager implements IMdsalApiManager {
 
     private List<FlowEntity> sortFlows(Iterable<FlowEntity> flowsToSort) {
         List<FlowEntity> sortedFlows = Lists.newArrayList(flowsToSort);
-        Collections.sort(sortedFlows,
-            (flow1, flow2) -> ComparisonChain.start()
-                .compare(flow1.getTableId(),  flow2.getTableId())
+        sortedFlows.sort((flow1, flow2) -> ComparisonChain.start()
+                .compare(flow1.getTableId(), flow2.getTableId())
                 .compare(flow1.getPriority(), flow2.getPriority())
-                .compare(flow1.getFlowId(),   flow2.getFlowId())
+                .compare(flow1.getFlowId(), flow2.getFlowId())
                 .result());
         return sortedFlows;
     }