Make some improvements
[lispflowmapping.git] / mappingservice / implementation / src / main / java / org / opendaylight / lispflowmapping / implementation / util / MappingMergeUtil.java
index c03cc8c0721e287a9908805c41fbd50fe5059a48..75a59edfa98bf7a72a8c8f64822b50ed74872762 100644 (file)
@@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory;
  *
  */
 public final class MappingMergeUtil {
-    protected static final Logger LOG = LoggerFactory.getLogger(MappingMergeUtil.class);
+    private static final Logger LOG = LoggerFactory.getLogger(MappingMergeUtil.class);
 
     // Utility class, should not be instantiated
     private MappingMergeUtil() {
@@ -98,9 +98,7 @@ public final class MappingMergeUtil {
             Rloc newRloc = newLocator.getRloc();
             if (locatorMap.containsKey(newRloc)) {
                 // overlapping locator
-                if (locatorMap.get(newRloc).equals(newLocator)) {
-                    continue;
-                } else {
+                if (!locatorMap.get(newRloc).equals(newLocator)) {
                     LocatorRecord mergedLocator = mergeLocators(locatorMap.get(newRloc), newLocator);
                     newLocatorList.add(mergedLocator);
                 }
@@ -111,7 +109,7 @@ public final class MappingMergeUtil {
         }
 
         // Build new merged and sorted locator set if need be
-        if (newLocatorList.size() != 0) {
+        if (!newLocatorList.isEmpty()) {
             List<LocatorRecord> mergedLocators = new ArrayList<LocatorRecord>();
 
             int mlocIt = 0;
@@ -161,7 +159,7 @@ public final class MappingMergeUtil {
         return mrb.build();
     }
 
-    public static MappingData mergeXtrIdMappings(List<Object> mappingDataList, List<XtrId> expiredMappings,
+    public static MappingData mergeXtrIdMappings(List<Object> mappingDataList, List<MappingData> expiredMappingDataList,
             Set<IpAddressBinary> sourceRlocs) {
         MappingRecordBuilder mrb = null;
         XtrId xtrId = null;
@@ -173,7 +171,7 @@ public final class MappingMergeUtil {
 
             // Skip expired mappings and add them to a list to be returned to the caller
             if (timestampIsExpired(mappingData.getTimestamp())) {
-                expiredMappings.add(mappingData.getXtrId());
+                expiredMappingDataList.add(mappingData);
                 continue;
             }
 
@@ -222,7 +220,7 @@ public final class MappingMergeUtil {
         return timestampIsExpired(timestamp.getTime());
     }
 
-    public static boolean timestampIsExpired(Long timestamp) {
+    private static boolean timestampIsExpired(Long timestamp) {
         Preconditions.checkNotNull(timestamp, "timestamp should not be null!");
         if ((System.currentTimeMillis() - timestamp) > ConfigIni.getInstance().getRegistrationValiditySb()) {
             return true;