From e472058ffda7ab483a69d814761cfd6f026ec4ad Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 4 Jul 2018 16:39:21 +0200 Subject: [PATCH] Make methods static These methods are private without touching object state, make them static. Change-Id: I01d675a02098426917e019fb66761b13cacf3d4a Signed-off-by: Robert Varga --- .../singleton/impl/NetconfTopologyManager.java | 2 +- .../singleton/impl/RemoteDeviceConnectorImpl.java | 11 ++++------- .../singleton/impl/MountPointEndToEndTest.java | 2 +- .../singleton/impl/NetconfNodeActorTest.java | 4 ++-- .../impl/tx/ProxyReadWriteTransactionTest.java | 2 +- .../netconf/topology/AbstractNetconfTopology.java | 14 +++++++------- 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java index 86b7111f78..6fe65a21f4 100644 --- a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java +++ b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/NetconfTopologyManager.java @@ -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) { diff --git a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java index 71fbda8ae3..5244692290 100644 --- a/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java +++ b/netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java @@ -225,7 +225,7 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector { : new NetconfDeviceCommunicator(remoteDeviceId, device, rpcMessageLimit), salFacade); } - private Optional getUserCapabilities(final NetconfNode node) { + private static Optional 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 getOdlHelloCapabilities(final NetconfNode node) { + private static List 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) { diff --git a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java index 8791fc203a..07e5753914 100644 --- a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java +++ b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/MountPointEndToEndTest.java @@ -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)); } diff --git a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeActorTest.java b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeActorTest.java index 5abb6ce320..09415d9c67 100644 --- a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeActorTest.java +++ b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeActorTest.java @@ -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>() { @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() : ""; } diff --git a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/ProxyReadWriteTransactionTest.java b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/ProxyReadWriteTransactionTest.java index 434be24a6d..ca74457f3d 100644 --- a/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/ProxyReadWriteTransactionTest.java +++ b/netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/tx/ProxyReadWriteTransactionTest.java @@ -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()); diff --git a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java index 8300eee947..c9ec7bf87f 100644 --- a/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java +++ b/netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java @@ -542,18 +542,18 @@ public abstract class AbstractNetconfTopology implements NetconfTopology { protected abstract RemoteDeviceHandler 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 getUserCapabilities(final NetconfNode node) { + private static Optional 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) { -- 2.36.6