Make some improvements 60/63960/2
authorDavid Suarez <david.suarez.fuentes@gmail.com>
Wed, 4 Oct 2017 20:21:05 +0000 (22:21 +0200)
committerDavid Suarez <david.suarez.fuentes@gmail.com>
Fri, 6 Oct 2017 16:23:08 +0000 (18:23 +0200)
- Declare some variable finals
- Final for utility classes
- Reduce access level to variables and methods
- Simplification of boolean expressions

Change-Id: I76892a88dd8f04c4909eb5e99bf9c35d65cecc39
Signed-off-by: David Suarez <david.suarez.fuentes@gmail.com>
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/MappingService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapResolver.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapServer.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/mdsal/AbstractDataListener.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/timebucket/containers/TimeBucket.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/timebucket/implementation/TimeBucketMappingTimeoutService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelper.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/LoggingUtil.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/MappingMergeUtil.java

index 25f802bfc5140877cf39a9e819579c2e153b5cbf..874a8150b45f39a5497ded9de6c8106aa96520b3 100644 (file)
@@ -62,12 +62,12 @@ import org.slf4j.LoggerFactory;
 
 public class LispMappingService implements IFlowMapping, IMapRequestResultHandler,
         IMapNotifyHandler, OdlLispProtoListener, AutoCloseable, ClusterSingletonService {
-    public static final String LISPFLOWMAPPING_ENTITY_NAME = "lispflowmapping";
-    public static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER = ServiceGroupIdentifier.create(
+    private static final String LISPFLOWMAPPING_ENTITY_NAME = "lispflowmapping";
+    private static final ServiceGroupIdentifier SERVICE_GROUP_IDENTIFIER = ServiceGroupIdentifier.create(
             LISPFLOWMAPPING_ENTITY_NAME);
 
 
-    protected static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
+    private static final Logger LOG = LoggerFactory.getLogger(LispMappingService.class);
     private final ClusterSingletonServiceProvider clusterSingletonService;
 
     private volatile boolean smr = ConfigIni.getInstance().smrIsSet();
@@ -276,7 +276,7 @@ public class LispMappingService implements IFlowMapping, IMapRequestResultHandle
         tlsMapRequest.set(new MutablePair<MapRequest, TransportAddress>(mapRequest, transportAddress));
     }
 
-    public void destroy() {
+    private void destroy() {
         LOG.info("LISP (RFC6830) Mapping Service is destroyed!");
         mapResolver = null;
         mapServer = null;
index 97c6c8e0b14e8b6d4e06c280cefb15a9fc6e431e..4bcbcd4e0d2b34f997c8af6b74ea4f32d3850bda 100644 (file)
@@ -81,7 +81,7 @@ import org.slf4j.LoggerFactory;
  *
  */
 public class MappingService implements OdlMappingserviceService, IMappingService, AutoCloseable {
-    protected static final Logger LOG = LoggerFactory.getLogger(MappingService.class);
+    private static final Logger LOG = LoggerFactory.getLogger(MappingService.class);
     private static final String NOT_FOUND_TAG = "data-missing";
     private static final String DATA_EXISTS_TAG = "data-exists";
 
index cddc86abad66b84bcc97b5b7a2cf3c2ee2583a17..98cea8f77e28e5bb3824690fa5a90cac61d17ba4 100644 (file)
@@ -54,7 +54,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class MapResolver implements IMapResolverAsync {
-    protected static final Logger LOG = LoggerFactory.getLogger(MapResolver.class);
+    private static final Logger LOG = LoggerFactory.getLogger(MapResolver.class);
 
     private IMappingService mapService;
     private boolean subscriptionService;
index 2eaf4a3fe41b21aac1f5036c4c056ebd8a193062..924c1c4347f2a974fbd6371783fc654166fc0bb4 100644 (file)
@@ -82,7 +82,7 @@ import org.slf4j.LoggerFactory;
 
 public class MapServer implements IMapServerAsync, OdlMappingserviceListener, ISmrNotificationListener {
 
-    protected static final Logger LOG = LoggerFactory.getLogger(MapServer.class);
+    private static final Logger LOG = LoggerFactory.getLogger(MapServer.class);
     private static final byte[] ALL_ZEROES_XTR_ID = new byte[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0};
     private IMappingService mapService;
     private boolean subscriptionService;
index 13704a5133cfd1b7c9db6a635903df2d6676d1b6..09d9b590815666ca84b3938e7de119128cc02246 100644 (file)
@@ -25,7 +25,7 @@ public abstract class AbstractDataListener<T extends DataObject> implements Clus
     private ListenerRegistration<ClusteredDataTreeChangeListener<T>> configRegistration;
     private ListenerRegistration<ClusteredDataTreeChangeListener<T>> operRegistration;
 
-    public void registerDataChangeListener() {
+    void registerDataChangeListener() {
         final DataTreeIdentifier<T> configDataTreeIdentifier = new DataTreeIdentifier<>(
                 LogicalDatastoreType.CONFIGURATION, path);
         final DataTreeIdentifier<T> operDataTreeIdentifier = new DataTreeIdentifier<>(
@@ -40,7 +40,7 @@ public abstract class AbstractDataListener<T extends DataObject> implements Clus
         operRegistration.close();
     }
 
-    public void setBroker(DataBroker broker) {
+    void setBroker(DataBroker broker) {
         this.broker = broker;
     }
 
index 3a08687aa53e814efb7d92ee2d446a18a7d41b93..761da43b21a65739f7887aaa7c242a7cbfdfa08b 100644 (file)
@@ -22,9 +22,9 @@ import org.slf4j.LoggerFactory;
 public class TimeBucket {
     private static final Logger LOG = LoggerFactory.getLogger(TimeBucket.class);
 
-    private ConcurrentHashMap<Eid, MappingData> bucketElements;
+    private final ConcurrentHashMap<Eid, MappingData> bucketElements;
 
-    private MappingSystem mappingSystem;
+    private final MappingSystem mappingSystem;
 
     public TimeBucket(MappingSystem mappingSystem) {
         bucketElements = new ConcurrentHashMap<>();
index b9b1b2961402112dc12ffa07413ae62c8925819c..fbd9e4638fd150b688456f5149e859085979c189 100644 (file)
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
 public class TimeBucketMappingTimeoutService implements ISouthBoundMappingTimeoutService {
     private static final Logger LOG = LoggerFactory.getLogger(TimeBucketWheel.class);
 
-    TimeBucketWheel timeBucketWheel;
+    private final TimeBucketWheel timeBucketWheel;
 
     public TimeBucketMappingTimeoutService(int numberOfBucket, long mappingRecordValidityInMillis,
                                            MappingSystem mappingSystem) {
index 56519d8a29dd0298d41f567b584f3211a4581e1c..91c8ea1d6a7143d2de147b0445c31fdc660e266c 100644 (file)
@@ -46,7 +46,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public final class LispNotificationHelper {
-    protected static final Logger LOG = LoggerFactory.getLogger(LispNotificationHelper.class);
+    private static final Logger LOG = LoggerFactory.getLogger(LispNotificationHelper.class);
     private static final Splitter COLON_SPLITTER = Splitter.on(':');
 
     // Utility class, should not be instantiated
@@ -103,8 +103,7 @@ public final class LispNotificationHelper {
 
     public static InetAddress getAddressByName(String ipAddress) {
         try {
-            InetAddress address = InetAddress.getByName(ipAddress);
-            return address;
+            return InetAddress.getByName(ipAddress);
         } catch (UnknownHostException e) {
             LOG.debug("Unknown host {}", ipAddress, e);
             return null;
index f8b09cf3d8103b2090c086f2afbce1ca6f9ef181..7e372c77f9081da698dda7f99df8d75767993e49 100644 (file)
@@ -20,7 +20,7 @@ import org.slf4j.Logger;
  * @author Lorand Jakab
  *
  */
-public class LoggingUtil {
+public final class LoggingUtil {
     // Utility class, should not be instantiated
     private LoggingUtil() {
     }
index b2b524149c795cbe22964d9d6201dce1e8eda63e..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;
@@ -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;