Take advantage of default methods in DOMRpcProviderService 35/51035/11
authorRobert Varga <rovarga@cisco.com>
Wed, 25 Jan 2017 22:05:02 +0000 (23:05 +0100)
committerTom Pantelis <tompantelis@gmail.com>
Mon, 31 Jul 2017 20:22:55 +0000 (20:22 +0000)
We can make one of the methods default, as all implementations
are exactly the same (codifying contract).

Change-Id: I64f0b62fd3a0987ed1ed01ec14b2c4d3b77560ac
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/md/sal/dom/api/DOMRpcProviderService.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/BrokerImpl.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/AbstractDOMRpcProviderService.java
opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/md/sal/dom/spi/ForwardingDOMRpcProviderService.java

index 82de4b02a2f108ddc1c85d9415b7744f7e5c7192..21f0da24bfa4854938d885d8db70b4531ae1614b 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.md.sal.dom.api;
 
+import com.google.common.collect.ImmutableSet;
 import java.util.Set;
 import javax.annotation.Nonnull;
 
@@ -40,8 +41,10 @@ public interface DOMRpcProviderService extends DOMService {
      * @throws NullPointerException if implementation or types is null
      * @throws IllegalArgumentException if types is empty or contains a null element.
      */
-    @Nonnull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
-            @Nonnull T implementation, @Nonnull DOMRpcIdentifier... rpcs);
+    default @Nonnull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
+            @Nonnull final T implementation, @Nonnull final DOMRpcIdentifier... rpcs) {
+        return registerRpcImplementation(implementation, ImmutableSet.copyOf(rpcs));
+    }
 
     /**
      * Register an {@link DOMRpcImplementation} object with this service.
index 02d27108621b3308d00194db4c26e0d8945ee7ea..285173596208ffe301faf398bef0b8aa2993d73b 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.base.Verify;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableList.Builder;
-import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.MapDifference;
 import com.google.common.collect.MapDifference.ValueDifference;
 import com.google.common.collect.Maps;
@@ -64,12 +63,6 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP
         return rpcRouter;
     }
 
-    @Override
-    public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
-            final T implementation, final DOMRpcIdentifier... rpcs) {
-        return registerRpcImplementation(implementation, ImmutableSet.copyOf(rpcs));
-    }
-
     private synchronized void removeRpcImplementation(final DOMRpcImplementation implementation,
             final Set<DOMRpcIdentifier> rpcs) {
         final DOMRpcRoutingTable oldTable = routingTable;
index 33fc2446196d5473f9742883155b92d25110fc77..40a4efd6fea3d89c563cfb73cc842521ba4d3745 100644 (file)
@@ -161,13 +161,6 @@ public class BrokerImpl implements Broker, DOMRpcProviderService, DOMRpcService,
         return session;
     }
 
-
-    @Nonnull
-    @Override
-    public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(@Nonnull final T implementation, @Nonnull final DOMRpcIdentifier... rpcs) {
-        return rpcProvider.registerRpcImplementation(implementation, rpcs);
-    }
-
     @Nonnull
     @Override
     public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(@Nonnull final T implementation, @Nonnull final Set<DOMRpcIdentifier> rpcs) {
index c1374264cc8234fc5f51da6c1c49814c27f4539c..29598ac53f43413daf3a5142ff7c773b8316a6ba 100644 (file)
@@ -7,18 +7,14 @@
  */
 package org.opendaylight.controller.md.sal.dom.spi;
 
-import com.google.common.collect.ImmutableSet;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
 
 /**
  * Convenience abstract base class for {@link DOMRpcProviderService} implementations.
+ *
+ * @deprecated Useless class. Implement {@link DOMRpcProviderService} directly.
  */
+@Deprecated
 public abstract class AbstractDOMRpcProviderService implements DOMRpcProviderService {
-    @Override
-    public final <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
-        return registerRpcImplementation(implementation, ImmutableSet.copyOf(types));
-    }
+
 }
index 99c4cad8a923feeaa3f73e2d5897f36f971cbd28..626745588906e569f803e3307e13d9cf756d4e8e 100644 (file)
@@ -24,12 +24,8 @@ public abstract class ForwardingDOMRpcProviderService extends ForwardingObject i
     protected abstract @Nonnull DOMRpcProviderService delegate();
 
     @Override
-    public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
-        return delegate().registerRpcImplementation(implementation, types);
-    }
-
-    @Override
-    public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final Set<DOMRpcIdentifier> types) {
+    public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
+            final T implementation, final Set<DOMRpcIdentifier> types) {
         return delegate().registerRpcImplementation(implementation, types);
     }
 }