config-manager: final parameters
[controller.git] / opendaylight / config / config-manager / src / test / java / org / opendaylight / controller / config / manager / testingservices / scheduledthreadpool / TestingScheduledThreadPoolModule.java
index 2b9760cfc4e922fe8663bfd653bc285fc3c1bc4b..cf0d9d17df07566306ff26f834fa303fe8fcdf31 100644 (file)
@@ -12,9 +12,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import java.io.Closeable;
-
 import javax.annotation.Nullable;
-
 import org.opendaylight.controller.config.api.ModuleIdentifier;
 import org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule;
 import org.opendaylight.controller.config.api.runtime.RootRuntimeBeanRegistrator;
@@ -41,9 +39,9 @@ public class TestingScheduledThreadPoolModule implements Module,
     private RootRuntimeBeanRegistrator runtimeBeanRegistrator;
     private boolean recreate;
 
-    public TestingScheduledThreadPoolModule(ModuleIdentifier identifier,
-            @Nullable AutoCloseable oldCloseable,
-            @Nullable TestingScheduledThreadPoolImpl oldInstance) {
+    public TestingScheduledThreadPoolModule(final ModuleIdentifier identifier,
+            @Nullable final AutoCloseable oldCloseable,
+            @Nullable final TestingScheduledThreadPoolImpl oldInstance) {
         this.identifier = identifier;
         this.oldCloseable = oldCloseable;
         this.oldInstance = oldInstance;
@@ -51,7 +49,7 @@ public class TestingScheduledThreadPoolModule implements Module,
 
     @Override
     public void setRuntimeBeanRegistrator(
-            RootRuntimeBeanRegistrator runtimeBeanRegistrator) {
+            final RootRuntimeBeanRegistrator runtimeBeanRegistrator) {
         this.runtimeBeanRegistrator = runtimeBeanRegistrator;
     }
 
@@ -63,13 +61,19 @@ public class TestingScheduledThreadPoolModule implements Module,
                 "Parameter 'ThreadCount' must be greater than 0");
     }
 
+    @Override
+    public boolean canReuse(final Module oldModule) {
+        return getClass().isInstance(oldModule) && getThreadCount() ==
+                ((TestingScheduledThreadPoolModule) oldModule).getThreadCount();
+    }
+
     @Override
     public int getThreadCount() {
         return threadCount;
     }
 
     @Override
-    public void setThreadCount(int threadCount) {
+    public void setThreadCount(final int threadCount) {
         this.threadCount = threadCount;
     }
 
@@ -85,7 +89,7 @@ public class TestingScheduledThreadPoolModule implements Module,
                 if (oldCloseable != null) {
                     try {
                         oldCloseable.close();
-                    } catch (Exception e) {
+                    } catch (final Exception e) {
                         throw new RuntimeException(e);
                     }
                 }
@@ -104,7 +108,7 @@ public class TestingScheduledThreadPoolModule implements Module,
     }
 
     @Override
-    public void setRecreate(boolean recreate) {
+    public void setRecreate(final boolean recreate) {
         this.recreate = recreate;
     }