BGPCEP-754: Rework EffectiveRibInWriter
[bgpcep.git] / bgp / flowspec / src / main / java / org / opendaylight / protocol / bgp / flowspec / l3vpn / ipv6 / FlowspecL3vpnIpv6RIBSupport.java
index 0be0a679a5dee09e51b6a67d329f2c38f399f7de..794f67517e03b4c2c3d09b4d33e12d97eea294b9 100644 (file)
@@ -7,27 +7,73 @@
  */
 package org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv6;
 
+import java.util.Collection;
+import java.util.Collections;
 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
 import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRoute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
 
-public final class FlowspecL3vpnIpv6RIBSupport extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv6NlriParser> {
+public final class FlowspecL3vpnIpv6RIBSupport
+        extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv6NlriParser,
+        org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.bgp.rib.rib.peer.adj
+                .rib.in.tables.routes.FlowspecL3vpnIpv6RoutesCase, FlowspecL3vpnRoute, FlowspecL3vpnRouteKey> {
     private FlowspecL3vpnIpv6RIBSupport(SimpleFlowspecExtensionProviderContext context) {
         super(
-            FlowspecL3vpnIpv6RoutesCase.class,
-            FlowspecL3vpnIpv6Routes.class,
-            FlowspecL3vpnRoute.class,
-            DestinationFlowspecL3vpnIpv6.QNAME,
-            Ipv6AddressFamily.class,
-            new FlowspecL3vpnIpv6NlriParser(context.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
+                FlowspecL3vpnIpv6RoutesCase.class,
+                FlowspecL3vpnIpv6Routes.class,
+                FlowspecL3vpnRoute.class,
+                DestinationFlowspecL3vpnIpv6.QNAME,
+                Ipv6AddressFamily.class,
+                new FlowspecL3vpnIpv6NlriParser(context
+                        .getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6,
+                                SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
         );
     }
 
     public static FlowspecL3vpnIpv6RIBSupport getInstance(final SimpleFlowspecExtensionProviderContext context) {
         return new FlowspecL3vpnIpv6RIBSupport(context);
     }
+
+    @Override
+    public final FlowspecL3vpnRouteKey createNewRouteKey(final PathId pathId, final FlowspecL3vpnRouteKey routeKey) {
+        return new FlowspecL3vpnRouteKey(pathId, routeKey.getRouteKey());
+    }
+
+    @Override
+    public FlowspecL3vpnRouteKey extractRouteKey(final FlowspecL3vpnRoute route) {
+        return route.getKey();
+    }
+
+    @Override
+    public FlowspecL3vpnRoute createRoute(
+            final FlowspecL3vpnRoute route,
+            final FlowspecL3vpnRouteKey routeKey,
+            final PathId pathId,
+            final Attributes attributes) {
+        final FlowspecL3vpnRouteBuilder builder;
+        if (route != null) {
+            builder = new FlowspecL3vpnRouteBuilder(route);
+        } else {
+            builder = new FlowspecL3vpnRouteBuilder();
+        }
+        return builder.setRouteKey(routeKey.getRouteKey()).setPathId(pathId).setAttributes(attributes).build();
+    }
+
+    @Override
+    public Collection<FlowspecL3vpnRoute> changedRoutes(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
+            .ns.yang.bgp.flowspec.rev171207.bgp.rib.rib.peer.adj.rib.in.tables.routes.FlowspecL3vpnIpv6RoutesCase routes) {
+        final FlowspecL3vpnIpv6Routes routeCont = routes.getFlowspecL3vpnIpv6Routes();
+        if (routeCont == null) {
+            return Collections.emptyList();
+        }
+        return routeCont.getFlowspecL3vpnRoute();
+    }
 }