X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=inline;f=mappingservice%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Flispflowmapping%2Fimplementation%2Futil%2FMappingMergeUtil.java;h=84c6d5ec4c8acac3f62b89a6c1fd8dd8141b5409;hb=25d3db985fc9d59d8a25131495b3befca9a33821;hp=a62ff90d7567a31e9fdfcc6c29973e2052bf2970;hpb=bfed8ea9683a3a11cacfbcdfa79c5b05c885525e;p=lispflowmapping.git diff --git a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/MappingMergeUtil.java b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/MappingMergeUtil.java index a62ff90d7..84c6d5ec4 100644 --- a/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/MappingMergeUtil.java +++ b/mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/MappingMergeUtil.java @@ -7,9 +7,9 @@ */ package org.opendaylight.lispflowmapping.implementation.util; +import static java.util.Objects.requireNonNull; import static org.opendaylight.yangtools.yang.common.UintConversions.fromJava; -import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; @@ -88,10 +88,10 @@ public final class MappingMergeUtil { // We assume locators are unique and sorted and don't show up several times (with different or identical // p/w/mp/mw), so we create a LinkedHashMap (which preserves order) of the locators from the existing merged // record, keyed by the Rloc - Map locatorMap = new LinkedHashMap(); + Map locatorMap = new LinkedHashMap<>(); // All locators to be added to the merge set are first stored in this list - List newLocatorList = new ArrayList(); + List newLocatorList = new ArrayList<>(); for (LocatorRecord locator : locators) { locatorMap.put(locator.getRloc(), locator); @@ -112,7 +112,7 @@ public final class MappingMergeUtil { // Build new merged and sorted locator set if need be if (!newLocatorList.isEmpty()) { - List mergedLocators = new ArrayList(); + List mergedLocators = new ArrayList<>(); int mlocIt = 0; int locIt = 0; @@ -167,8 +167,8 @@ public final class MappingMergeUtil { XtrId xtrId = null; Long timestamp = Long.MAX_VALUE; - for (int i = 0; i < mappingDataList.size(); i++) { - MappingData mappingData = (MappingData) mappingDataList.get(i); + for (Object element : mappingDataList) { + MappingData mappingData = (MappingData) element; MappingRecord record = mappingData.getRecord(); // Skip expired mappings and add them to a list to be returned to the caller @@ -210,7 +210,7 @@ public final class MappingMergeUtil { * non-null arguments */ public static boolean mappingIsExpired(MappingData mappingData) { - Preconditions.checkNotNull(mappingData, "mapping should not be null!"); + requireNonNull(mappingData, "mapping should not be null!"); if (mappingData.getTimestamp() != null) { return timestampIsExpired(mappingData.getTimestamp()); } @@ -218,13 +218,13 @@ public final class MappingMergeUtil { } public static boolean timestampIsExpired(Date timestamp) { - Preconditions.checkNotNull(timestamp, "timestamp should not be null!"); + requireNonNull(timestamp, "timestamp should not be null!"); return timestampIsExpired(timestamp.getTime()); } private static boolean timestampIsExpired(Long timestamp) { - Preconditions.checkNotNull(timestamp, "timestamp should not be null!"); - if ((System.currentTimeMillis() - timestamp) > ConfigIni.getInstance().getRegistrationValiditySb()) { + requireNonNull(timestamp, "timestamp should not be null!"); + if (System.currentTimeMillis() - timestamp > ConfigIni.getInstance().getRegistrationValiditySb()) { return true; } return false; @@ -291,13 +291,13 @@ public final class MappingMergeUtil { // We assume locators are unique and don't show up several times (with different or identical p/w/mp/mw), // so we create a HashMap of the locators from the SB mapping record, keyed by the Rloc - Map sbLocatorMap = new HashMap(); + Map sbLocatorMap = new HashMap<>(); for (LocatorRecord locator : sbLocators) { sbLocatorMap.put(locator.getRloc(), locator); } // Gradually building final list of common locators, in order that they appear in NB Mapping - List commonLocators = new ArrayList(); + List commonLocators = new ArrayList<>(); for (LocatorRecord nbLocator : nbMapping.getLocatorRecord()) { Rloc nbRloc = nbLocator.getRloc();