Make methods static 58/22158/1
authorDana Kutenicsova <dkutenic@cisco.com>
Tue, 9 Jun 2015 07:03:09 +0000 (09:03 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Tue, 9 Jun 2015 08:17:38 +0000 (08:17 +0000)
Some methods do not touch object state and can be made static. Turn them
into statics for better performance.

Change-Id: Ib561b6f5d0845261370ea28d6428262df887943f
Signed-off-by: Robert Varga <rovarga@cisco.com>
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
(cherry picked from commit fc38e78649a09a058450dfcfd02ee48a39aa35f3)

bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistry.java
bgp/rib-impl/src/test/java/org/opendaylight/controller/config/yang/bgp/rib/impl/AbstractRIBImplModuleTest.java
bgp/rib-impl/src/test/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPPeerAcceptorModuleTest.java
bgp/rib-impl/src/test/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPPeerModuleTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/BestPathSelectorTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserToSalTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistryTest.java

index 7c88d4cd324af1283ab2f3457bde0525d7c2752e..eef785ba1d880144c8e34cc193384f74a393b72b 100644 (file)
@@ -138,7 +138,7 @@ public class BGPPeer implements ReusableBGPPeer, Peer, AutoCloseable, BGPPeerRun
      * @param message Update message containing prefixes in NLRI
      * @return MpReachNlri with prefixes from the nlri field
      */
-    private MpReachNlri prefixesToMpReach(final Update message) {
+    private static MpReachNlri prefixesToMpReach(final Update message) {
         final List<Ipv4Prefixes> prefixes = new ArrayList<>();
         for (final Ipv4Prefix p : message.getNlri().getNlri()) {
             prefixes.add(new Ipv4PrefixesBuilder().setPrefix(p).build());
@@ -160,7 +160,7 @@ public class BGPPeer implements ReusableBGPPeer, Peer, AutoCloseable, BGPPeerRun
      * @param message Update message containing withdrawn routes
      * @return MpUnreachNlri with prefixes from the withdrawn routes field
      */
-    private MpUnreachNlri prefixesToMpUnreach(final Update message) {
+    private static MpUnreachNlri prefixesToMpUnreach(final Update message) {
         final List<Ipv4Prefixes> prefixes = new ArrayList<>();
         for (final Ipv4Prefix p : message.getWithdrawnRoutes().getWithdrawnRoutes()) {
             prefixes.add(new Ipv4PrefixesBuilder().setPrefix(p).build());
index d9cc66c838d91ae71cde932bf389e8bd8633e9cd..fa21bbfbe74ba553710d64305efc3d75296f03d7 100644 (file)
@@ -256,7 +256,7 @@ public final class StrictBGPPeerRegistry implements BGPPeerRegistry {
             return this.asNumber.getValue() > other.asNumber.getValue();
         }
 
-        private long toLong(final Ipv4Address from) {
+        private static long toLong(final Ipv4Address from) {
             final int i = InetAddresses.coerceToInteger(InetAddresses.forString(from.getValue()));
             return UnsignedInts.toLong(i);
         }
index 0d2a55539ed28043faea1a504e541f40a4d07c35..ff2bbe1d644e72e8cdd183382f2df01b8c2c0d49 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.controller.config.yang.bgp.rib.impl;
 
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
-
 import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import com.google.common.io.ByteSource;
@@ -301,7 +300,7 @@ public abstract class AbstractRIBImplModuleTest extends AbstractConfigTest {
         }
     }
 
-    private ObjectName createRibExtensionsInstance(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
+    private static ObjectName createRibExtensionsInstance(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
         final ObjectName nameCreated = transaction.createModule(RIBExtensionsImplModuleFactory.NAME, RIB_EXTENSIONS_INSTANCE_NAME);
         transaction.newMXBeanProxy(nameCreated, RIBExtensionsImplModuleMXBean.class);
         return nameCreated;
index 11e564e11f114a9106f4ce739d04feae33178f26..a6fe83a93dacebc83c9709635094cde759b23763 100644 (file)
@@ -14,7 +14,6 @@ import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
-
 import com.google.common.base.Optional;
 import com.google.common.collect.Lists;
 import io.netty.channel.Channel;
@@ -114,11 +113,11 @@ public class BGPPeerAcceptorModuleTest extends AbstractConfigTest {
         return transaction.commit();
     }
 
-    private ObjectName createPeerRegistry(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
+    private static ObjectName createPeerRegistry(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
         return transaction.createModule(StrictBgpPeerRegistryModuleFactory.NAME, "peer-registry");
     }
 
-    private ObjectName createDispatcher(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
+    private static ObjectName createDispatcher(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
         return transaction.createModule("dispatch", "mock");
     }
 
index 49759b502c1f9bd3a8eea1db06b352ce60cb6551..b9698eb5df6871ec6d992bedeefedefd3f37e6d3 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.controller.config.yang.bgp.rib.impl;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.mockito.Mockito.doReturn;
-
 import com.google.common.collect.Lists;
 import java.util.Collections;
 import java.util.List;
@@ -174,11 +173,11 @@ public class BGPPeerModuleTest extends AbstractRIBImplModuleTest {
         return nameCreated;
     }
 
-    private ObjectName createPeerRegistry(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
+    private static ObjectName createPeerRegistry(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
         return transaction.createModule(StrictBgpPeerRegistryModuleFactory.NAME, "peer-registry");
     }
 
-    private BGPDispatcherImplModuleMXBean getBgpDispatcherImplModuleMXBean(final ConfigTransactionJMXClient transaction,
+    private static BGPDispatcherImplModuleMXBean getBgpDispatcherImplModuleMXBean(final ConfigTransactionJMXClient transaction,
             final BGPPeerModuleMXBean mxBean) {
         final RIBImplModuleMXBean ribProxy = transaction.newMXBeanProxy(mxBean.getRib(), RIBImplModuleMXBean.class);
         final ObjectName dispatcherON = ribProxy.getBgpDispatcher();
index a21ceec88fb989652e8089fd0d7264a4ccc4a214..a595fc5323181d091b972939f4e83c2f2f79c9dd 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.protocol.bgp.rib.impl;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
-
 import com.google.common.primitives.UnsignedInteger;
 import org.junit.Test;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.AsPath;
@@ -118,11 +117,11 @@ public class BestPathSelectorTest {
         return this.dataContBuilder.build();
     }
 
-    private DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> createContBuilder(final QName qname) {
+    private static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> createContBuilder(final QName qname) {
         return ImmutableContainerNodeSchemaAwareBuilder.create().withNodeIdentifier(new NodeIdentifier(qname));
     }
 
-    private <T> ImmutableLeafNodeBuilder<T> createValueBuilder(final T value, final QName qname, final String localName) {
+    private static <T> ImmutableLeafNodeBuilder<T> createValueBuilder(final T value, final QName qname, final String localName) {
         final ImmutableLeafNodeBuilder<T> valueBuilder = new ImmutableLeafNodeBuilder<>();
         valueBuilder.withNodeIdentifier(new NodeIdentifier(QName.create(qname, localName))).withValue(value);
         return valueBuilder;
index 466c8576ffc06152fe858d225882d5eb21079db0..9b738540eb283431cec08a08a44325ed93fda5c3 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.protocol.bgp.rib.impl;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-
 import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import com.google.common.base.Throwables;
@@ -159,7 +158,7 @@ public class ParserToSalTest extends AbstractDataBrokerTest {
         reg.close();
     }
 
-    private Collection<byte[]> fixMessages(final Collection<byte[]> bgpMessages) {
+    private static Collection<byte[]> fixMessages(final Collection<byte[]> bgpMessages) {
         return Collections2.transform(bgpMessages, new Function<byte[], byte[]>() {
 
             @Nullable
index 0bb9f01a384d5e0171e6a398b623cb85039b03f4..f61a08d38ec4443125c3387f55467980c0363066 100644 (file)
@@ -240,14 +240,14 @@ public class PeerTest {
         Mockito.doReturn(readFuture).when(readTx).read(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.any(InstanceIdentifier.class));
     }
 
-    private BindingCodecTreeFactory createCodecFactory(final ClassLoadingStrategy str, final SchemaContext ctx) {
+    private static BindingCodecTreeFactory createCodecFactory(final ClassLoadingStrategy str, final SchemaContext ctx) {
         final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()));
         final BindingNormalizedNodeCodecRegistry codec = new BindingNormalizedNodeCodecRegistry(generator);
         codec.onBindingRuntimeContextUpdated(BindingRuntimeContext.create(str, ctx));
         return codec;
     }
 
-    private ModuleInfoBackedContext createClassLoadingStrategy() {
+    private static ModuleInfoBackedContext createClassLoadingStrategy() {
         final ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create();
         try {
             ctx.registerModuleInfo(BindingReflections.getModuleInfo(Ipv4Route.class));
index cf886a6ef99e18daca274920e902fe9a88bc60ef..a4812b3e34a2442edc70e9657f067665c1dbeba1 100644 (file)
@@ -11,7 +11,6 @@ package org.opendaylight.protocol.bgp.rib.impl;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.fail;
-
 import java.net.InetSocketAddress;
 import java.util.Collections;
 import org.junit.Before;
@@ -212,7 +211,7 @@ public class StrictBGPPeerRegistryTest {
         fail("Peer AS number mismatch");
     }
 
-    private ReusableBGPPeer getMockSession() {
+    private static ReusableBGPPeer getMockSession() {
         final ReusableBGPPeer mock = Mockito.mock(ReusableBGPPeer.class);
         Mockito.doNothing().when(mock).releaseConnection();
         return mock;
@@ -221,4 +220,4 @@ public class StrictBGPPeerRegistryTest {
     public BGPSessionPreferences getMockPreferences() {
         return new BGPSessionPreferences(AS1, 1,  new Ipv4Address("0.0.0.1"), Collections.<BgpParameters>emptyList());
     }
-}
\ No newline at end of file
+}