Make methods static 49/73749/4
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 4 Jul 2018 14:39:21 +0000 (16:39 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 4 Jul 2018 15:33:23 +0000 (17:33 +0200)
These methods are private without touching object state,
make them static.

Change-Id: I01d675a02098426917e019fb66761b13cacf3d4a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeActorTest.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/ProxyReadWriteTransactionTest.java
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java

index 86b7111f78ce325bfd0b6ee6285f08df3ee30922..6fe65a21f49eb38343b53d8e9a5d194647ae08e3 100644 (file)
@@ -219,7 +219,7 @@ public class NetconfTopologyManager
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
-    private void close(AutoCloseable closeable) {
+    private static void close(AutoCloseable closeable) {
         try {
             closeable.close();
         } catch (Exception e) {
index 71fbda8ae35d6e16df313d235905055574160be1..52446922908603798865a4668e201cb31b7f5745 100644 (file)
@@ -225,7 +225,7 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
                         : new NetconfDeviceCommunicator(remoteDeviceId, device, rpcMessageLimit), salFacade);
     }
 
-    private Optional<NetconfSessionPreferences> getUserCapabilities(final NetconfNode node) {
+    private static Optional<NetconfSessionPreferences> getUserCapabilities(final NetconfNode node) {
         if (node.getYangModuleCapabilities() == null && node.getNonModuleCapabilities() == null) {
             return Optional.empty();
         }
@@ -249,7 +249,7 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
     }
 
     //TODO: duplicate code
-    private InetSocketAddress getSocketAddress(final Host host, final int port) {
+    private static InetSocketAddress getSocketAddress(final Host host, final int port) {
         if (host.getDomainName() != null) {
             return new InetSocketAddress(host.getDomainName().getValue(), port);
         } else {
@@ -302,12 +302,9 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
         return builder.build();
     }
 
-    private List<Uri> getOdlHelloCapabilities(final NetconfNode node) {
+    private static List<Uri> getOdlHelloCapabilities(final NetconfNode node) {
         final OdlHelloMessageCapabilities helloCapabilities = node.getOdlHelloMessageCapabilities();
-        if (helloCapabilities != null) {
-            return helloCapabilities.getCapability();
-        }
-        return null;
+        return helloCapabilities != null ? helloCapabilities.getCapability() : null;
     }
 
     private AuthenticationHandler getHandlerFromCredentials(final Credentials credentials) {
index 8791fc203a2d639e851271a5ac6ad274c0f9d00d..07e57539148366885cd21d88a03cb7e10b4154d2 100644 (file)
@@ -231,7 +231,7 @@ public class MountPointEndToEndTest {
         LOG.info("****** Setup complete");
     }
 
-    private void deleteCacheDir() {
+    private static void deleteCacheDir() {
         FileUtils.deleteQuietly(new File(NetconfTopologyUtils.CACHE_DIRECTORY));
     }
 
index 5abb6ce320a87034961515730249c803a8321c80..09415d9c67fcf16d0b03f0efdc14f9601a12fa92 100644 (file)
@@ -560,7 +560,7 @@ public class NetconfNodeActorTest {
         doReturn(mockMountPointReg).when(mockMountPointBuilder).register();
     }
 
-    private PotentialSchemaSource<?> withSourceId(final SourceIdentifier identifier) {
+    private static PotentialSchemaSource<?> withSourceId(final SourceIdentifier identifier) {
         return argThat(new ArgumentMatcher<PotentialSchemaSource<?>>() {
             @Override
             public boolean matches(final Object argument) {
@@ -570,7 +570,7 @@ public class NetconfNodeActorTest {
         });
     }
 
-    private String convertStreamToString(final InputStream is) {
+    private static String convertStreamToString(final InputStream is) {
         try (Scanner scanner = new Scanner(is)) {
             return scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
         }
index 434be24a6d1d0cd658dd8e2be2a3db1a19bfe674..ca74457f3da054d4d914f451ac9c2619d0dd762e 100644 (file)
@@ -398,7 +398,7 @@ public class ProxyReadWriteTransactionTest {
         }
     }
 
-    private void verifyDocumentedException(Throwable cause) {
+    private static void verifyDocumentedException(Throwable cause) {
         assertTrue("Unexpected cause " + cause, cause instanceof DocumentedException);
         final DocumentedException de = (DocumentedException) cause;
         assertEquals(DocumentedException.ErrorSeverity.WARNING, de.getErrorSeverity());
index 8300eee947cc170fb2891d431f4248a5de6275ff..c9ec7bf87facb077e98af782900f0283749e0d6d 100644 (file)
@@ -542,18 +542,18 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
 
     protected abstract RemoteDeviceHandler<NetconfSessionPreferences> createSalFacade(RemoteDeviceId id);
 
-    private InetSocketAddress getSocketAddress(final Host host, final int port) {
+    private static InetSocketAddress getSocketAddress(final Host host, final int port) {
         if (host.getDomainName() != null) {
             return new InetSocketAddress(host.getDomainName().getValue(), port);
-        } else {
-            final IpAddress ipAddress = host.getIpAddress();
-            final String ip = ipAddress.getIpv4Address() != null
-                    ? ipAddress.getIpv4Address().getValue() : ipAddress.getIpv6Address().getValue();
-            return new InetSocketAddress(ip, port);
         }
+
+        final IpAddress ipAddress = host.getIpAddress();
+        final String ip = ipAddress.getIpv4Address() != null ? ipAddress.getIpv4Address().getValue()
+                : ipAddress.getIpv6Address().getValue();
+        return new InetSocketAddress(ip, port);
     }
 
-    private Optional<UserPreferences> getUserCapabilities(final NetconfNode node) {
+    private static Optional<UserPreferences> getUserCapabilities(final NetconfNode node) {
         // if none of yang-module-capabilities or non-module-capabilities is specified
         // just return absent
         if (node.getYangModuleCapabilities() == null && node.getNonModuleCapabilities() == null) {