Fix more type safety warnings 48/72648/5
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jun 2018 11:03:39 +0000 (13:03 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Jun 2018 12:05:21 +0000 (14:05 +0200)
We can use proper arguments to make warnings go away.

Change-Id: I626a3ed5b90c00822e0f62381d995c720fcc7108
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/spi/pojo/attributes/tunnel/identifier/SimpleTunnelIdentifierRegistry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPDispatcherImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/LocRibWriter.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBSupportContextImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBSupportContextRegistryImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RouteEntryDependenciesContainerImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/RIBSupportContext.java

index 62f212f657af09929f496d50420078cfaa72b543..69ccca182ffb33b99f0771e152e3ba3b77021868 100644 (file)
@@ -22,7 +22,7 @@ public final class SimpleTunnelIdentifierRegistry {
     public static final int NO_TUNNEL_INFORMATION_PRESENT = 0;
     private static final SimpleTunnelIdentifierRegistry SINGLETON = new SimpleTunnelIdentifierRegistry();
     private static final Logger LOG = LoggerFactory.getLogger(SimpleTunnelIdentifierRegistry.class);
-    private final HandlerRegistry<DataContainer, TunnelIdentifierParser, TunnelIdentifierSerializer> handlers =
+    private final HandlerRegistry<DataContainer, TunnelIdentifierParser<?>, TunnelIdentifierSerializer<?>> handlers =
             new HandlerRegistry<>();
 
     private SimpleTunnelIdentifierRegistry() {
@@ -33,7 +33,7 @@ public final class SimpleTunnelIdentifierRegistry {
     }
 
     public TunnelIdentifier parse(final int tunnelType, final ByteBuf buffer) {
-        final TunnelIdentifierParser parser = this.handlers.getParser(tunnelType);
+        final TunnelIdentifierParser<?> parser = this.handlers.getParser(tunnelType);
         if (!buffer.isReadable() || parser == null) {
             LOG.debug("Skipping parsing of PMSI Tunnel Attribute type {}", tunnelType);
             return null;
@@ -54,11 +54,11 @@ public final class SimpleTunnelIdentifierRegistry {
         return serializer.serialize(tunnel, tunnelBuffer);
     }
 
-    public AbstractRegistration registerParser(final TunnelIdentifierParser parser) {
+    public AbstractRegistration registerParser(final TunnelIdentifierParser<?> parser) {
         return this.handlers.registerParser(parser.getType(), parser);
     }
 
-    public AbstractRegistration registerSerializer(final TunnelIdentifierSerializer serializer) {
+    public AbstractRegistration registerSerializer(final TunnelIdentifierSerializer<?> serializer) {
         return this.handlers.registerSerializer(serializer.getClazz(), serializer);
     }
 }
index 5ac92300d8e682da9471391e0a382b808b43c99a..e7fd673692e7ab775cc5d95f131d6a25c0ef71d3 100644 (file)
@@ -167,7 +167,7 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         return this.bgpPeerRegistry;
     }
 
-    private synchronized ServerBootstrap createServerBootstrap(final ChannelPipelineInitializer initializer) {
+    private synchronized ServerBootstrap createServerBootstrap(final ChannelPipelineInitializer<?> initializer) {
         final ServerBootstrap serverBootstrap = new ServerBootstrap();
         if (Epoll.isAvailable()) {
             serverBootstrap.channel(EpollServerSocketChannel.class);
@@ -217,13 +217,12 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
             };
         }
 
-        static ChannelHandler createServerChannelHandler(final ChannelPipelineInitializer initializer) {
+        static <S extends BGPSession> ChannelHandler createServerChannelHandler(
+                final ChannelPipelineInitializer<S> initializer) {
             return new ChannelInitializer<SocketChannel>() {
                 @Override
-                @SuppressWarnings("unchecked")
                 protected void initChannel(final SocketChannel channel) {
-                    initializer.initializeChannel(channel,
-                            new DefaultPromise<BGPSessionImpl>(GlobalEventExecutor.INSTANCE));
+                    initializer.initializeChannel(channel, new DefaultPromise<>(GlobalEventExecutor.INSTANCE));
                 }
             };
         }
index 614e2dba2f297174bacbf863a0d24e0cd130c506..70de8d0ad913e9c9be8b59067bed0cc354211e29 100644 (file)
@@ -48,7 +48,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.ChoiceIn;
 import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
 import org.opendaylight.yangtools.yang.binding.Identifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
@@ -106,9 +109,8 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn
         this.peerImportParameters = peer;
     }
 
-    @SuppressWarnings("unchecked")
     public void init() {
-        final DataTreeIdentifier treeId = new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+        final DataTreeIdentifier<Tables> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
                 this.peerIId.child(AdjRibIn.class).child(Tables.class));
         LOG.debug("Registered Effective RIB on {}", this.peerIId);
         this.reg = requireNonNull(this.databroker).registerDataTreeChangeListener(treeId, this);
@@ -195,32 +197,34 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn
     }
 
     @SuppressWarnings("unchecked")
-    private void updateRoutes(
+    private <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>,
+        R extends Route & ChildOf<? super S> & Identifiable<I>, I extends Identifier<R>> void updateRoutes(
             final WriteTransaction tx,
-            final TablesKey tableKey, final RIBSupport ribSupport,
+            final TablesKey tableKey, final RIBSupport<C, S, R, I> ribSupport,
             final KeyedInstanceIdentifier<Tables, TablesKey> tablePath,
             final Collection<DataObjectModification<? extends DataObject>> routeChanges) {
         for (final DataObjectModification<? extends DataObject> routeChanged : routeChanges) {
-            final Identifier routeKey
-                    = ((InstanceIdentifier.IdentifiableItem) routeChanged.getIdentifier()).getKey();
+            final I routeKey
+                    = ((InstanceIdentifier.IdentifiableItem<R, I>) routeChanged.getIdentifier()).getKey();
             switch (routeChanged.getModificationType()) {
                 case SUBTREE_MODIFIED:
                 case WRITE:
-                    writeRoutes(tx, tableKey, ribSupport, tablePath, routeKey, (Route) routeChanged.getDataAfter());
+                    writeRoutes(tx, tableKey, ribSupport, tablePath, routeKey, (R) routeChanged.getDataAfter());
                     break;
                 case DELETE:
-                    final InstanceIdentifier routeIID = ribSupport.createRouteIdentifier(tablePath, routeKey);
+                    final InstanceIdentifier<R> routeIID = ribSupport.createRouteIdentifier(tablePath, routeKey);
                     tx.delete(LogicalDatastoreType.OPERATIONAL, routeIID);
                     break;
             }
         }
     }
 
-    @SuppressWarnings("unchecked")
-    private void writeRoutes(final WriteTransaction tx, final TablesKey tk, final RIBSupport ribSupport,
-            final KeyedInstanceIdentifier<Tables, TablesKey> tablePath, final Identifier routeKey,
-            final Route route) {
-        final InstanceIdentifier routeIID = ribSupport.createRouteIdentifier(tablePath, routeKey);
+    private <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>,
+        R extends Route & ChildOf<? super S> & Identifiable<I>, I extends Identifier<R>> void writeRoutes(
+                final WriteTransaction tx, final TablesKey tk, final RIBSupport<C, S, R, I> ribSupport,
+            final KeyedInstanceIdentifier<Tables, TablesKey> tablePath, final I routeKey,
+            final R route) {
+        final InstanceIdentifier<R> routeIID = ribSupport.createRouteIdentifier(tablePath, routeKey);
         CountersUtil.increment(this.prefixesReceived.get(tk), tk);
         final Optional<Attributes> effAtt = this.ribPolicies
                 .applyImportPolicies(this.peerImportParameters, route.getAttributes(),
index bb98822e2994e54a1cd066b6ba6c83cc651084bf..3313b1e6862a191685ee0c9a9764b6c4d274be2e 100644 (file)
@@ -119,7 +119,6 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
                 peerTracker, tablesKey, afiSafiType, pathSelectionStrategy);
     }
 
-    @SuppressWarnings("unchecked")
     private synchronized void init() {
         final WriteTransaction tx = this.chain.newWriteOnlyTransaction();
         tx.merge(LogicalDatastoreType.OPERATIONAL,
@@ -140,7 +139,7 @@ final class LocRibWriter implements AutoCloseable, TotalPrefixesCounter, TotalPa
         final InstanceIdentifier<Tables> tableId = this.ribIId.builder().child(Peer.class)
                 .child(EffectiveRibIn.class).child(Tables.class, this.tk).build();
         this.reg = this.dataBroker.registerDataTreeChangeListener(
-                new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, tableId), this);
+                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, tableId), this);
     }
 
     /**
index 0ef3b83f08552bc2268f34271f21082aac39715a..bd587872564314e087b1a5c96113aa196bb81e6c 100644 (file)
@@ -20,7 +20,14 @@ import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.ChoiceIn;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -43,8 +50,8 @@ class RIBSupportContextImpl extends RIBSupportContext {
     }
 
     @Override
-    public void writeRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tableId, final MpReachNlri nlri,
-            final Attributes attributes) {
+    public void writeRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tableId,
+            final MpReachNlri nlri, final Attributes attributes) {
         final ContainerNode domNlri = this.codecs.serializeReachNlri(nlri);
         final ContainerNode routeAttributes = this.codecs.serializeAttributes(attributes);
         this.ribSupport.putRoutes(tx, tableId, domNlri, routeAttributes);
@@ -64,18 +71,23 @@ class RIBSupportContextImpl extends RIBSupportContext {
 
         final ChoiceNode routes = this.ribSupport.emptyRoutes();
         Verify.verifyNotNull(routes, "Null empty routes in %s", this.ribSupport);
-        Verify.verify(Routes.QNAME.equals(routes.getNodeType()), "Empty routes have unexpected identifier %s, expected %s", routes.getNodeType(), Routes.QNAME);
+        Verify.verify(Routes.QNAME.equals(routes.getNodeType()),
+            "Empty routes have unexpected identifier %s, expected %s", routes.getNodeType(), Routes.QNAME);
 
         tx.put(LogicalDatastoreType.OPERATIONAL, tableId, tb.withChild(routes).build());
     }
 
     @Override
-    public void deleteRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tableId, final MpUnreachNlri nlri) {
+    public void deleteRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tableId,
+            final MpUnreachNlri nlri) {
         this.ribSupport.deleteRoutes(tx, tableId, this.codecs.serializeUnreachNlri(nlri));
     }
 
     @Override
-    public RIBSupport getRibSupport() {
-        return this.ribSupport;
+    @SuppressWarnings("unchecked")
+    public <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>,
+        R extends Route & ChildOf<? super S> & Identifiable<I>, I extends Identifier<R>>
+            RIBSupport<C, S, R, I> getRibSupport() {
+        return (RIBSupport<C, S, R, I>) this.ribSupport;
     }
 }
index b96c90d7c0a928c7d10ad5e5cd9592e9c2c40068..ed5a80bdf01afb84280a6eb248c7b7dbccd378ff 100644 (file)
@@ -57,18 +57,12 @@ final class RIBSupportContextRegistryImpl implements RIBSupportContextRegistry {
             R extends Route & ChildOf<? super S> & Identifiable<I>, I extends Identifier<R>>
             RIBSupport<C, S, R, I> getRIBSupport(final TablesKey key) {
         final RIBSupportContext ribSupport = getRIBSupportContext(key);
-        if (ribSupport != null) {
-            return ribSupport.getRibSupport();
-        }
-        return null;
+        return ribSupport == null ? null : ribSupport.getRibSupport();
     }
 
     @Override
     public RIBSupportContext getRIBSupportContext(final TablesKey key) {
         final RIBSupport<?, ?, ?, ?> ribSupport = this.extensionContext.getRIBSupport(key);
-        if (ribSupport != null) {
-            return this.contexts.getUnchecked(ribSupport);
-        }
-        return null;
+        return ribSupport == null ? null : this.contexts.getUnchecked(ribSupport);
     }
 }
index cc857baa6e0f3436b2cc3ad494b8f982f8a31e06..feae21443225f8a56e8b4a7371d8a72da5676c10 100644 (file)
@@ -13,8 +13,15 @@ import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
 import org.opendaylight.protocol.bgp.rib.spi.entry.RouteEntryDependenciesContainer;
 import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.ChoiceIn;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
 public final class RouteEntryDependenciesContainerImpl implements RouteEntryDependenciesContainer {
@@ -37,9 +44,12 @@ public final class RouteEntryDependenciesContainerImpl implements RouteEntryDepe
         this.locRibTarget = requireNonNull(locRibTarget);
     }
 
+    @SuppressWarnings("unchecked")
     @Override
-    public RIBSupport<?, ?, ?, ?> getRibSupport() {
-        return this.ribSupport;
+    public <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<C>,
+        R extends Route & ChildOf<S> & Identifiable<I>, I extends Identifier<R>>
+            RIBSupport<C, S, R, I> getRibSupport() {
+        return (RIBSupport<C, S, R, I>) this.ribSupport;
     }
 
     @Override
index 4c90a4467472cdcaf080784f5245a61471b59878..7b2461fc6eab3e74cde98b069238ec2e1d600332 100644 (file)
@@ -12,6 +12,14 @@ import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
+import org.opendaylight.yangtools.yang.binding.ChildOf;
+import org.opendaylight.yangtools.yang.binding.ChoiceIn;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.Identifiable;
+import org.opendaylight.yangtools.yang.binding.Identifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 /**
@@ -59,5 +67,7 @@ public abstract class RIBSupportContext {
      *
      * @return RIBSupport
      */
-    public abstract RIBSupport getRibSupport();
+    public abstract <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>,
+        R extends Route & ChildOf<? super S> & Identifiable<I>, I extends Identifier<R>>
+            RIBSupport<C, S, R, I> getRibSupport();
 }