BGPCEP-754: Rework EffectiveRibInWriter
[bgpcep.git] / bgp / labeled-unicast / src / main / java / org / opendaylight / protocol / bgp / labeled / unicast / LabeledUnicastIpv4RIBSupport.java
index ab499b8f3257a1059e97f3757a523aac839d98b8..51c81ffe9e49665861d3eecc48bd4819bb0ed2cc 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.protocol.bgp.labeled.unicast;
 
 import java.util.Collection;
-import javax.annotation.Nonnull;
+import java.util.Collections;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.LabeledUnicastSubsequentAddressFamily;
@@ -25,7 +25,9 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 
-public final class LabeledUnicastIpv4RIBSupport extends AbstractLabeledUnicastRIBSupport {
+public final class LabeledUnicastIpv4RIBSupport extends AbstractLabeledUnicastRIBSupport<org.opendaylight.yang.gen.v1
+        .urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.bgp.rib.rib.peer.adj.rib.in.tables
+        .routes.LabeledUnicastRoutesCase> {
     private static final LabeledUnicastIpv4RIBSupport SINGLETON = new LabeledUnicastIpv4RIBSupport();
 
     private LabeledUnicastIpv4RIBSupport() {
@@ -37,16 +39,14 @@ public final class LabeledUnicastIpv4RIBSupport extends AbstractLabeledUnicastRI
         return SINGLETON;
     }
 
-    @Nonnull
     @Override
-    protected DestinationType buildDestination(@Nonnull final Collection<MapEntryNode> routes) {
+    protected DestinationType buildDestination(final Collection<MapEntryNode> routes) {
         return new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
             new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(extractRoutes(routes)).build()).build();
     }
 
-    @Nonnull
     @Override
-    protected DestinationType buildWithdrawnDestination(@Nonnull final Collection<MapEntryNode> routes) {
+    protected DestinationType buildWithdrawnDestination(final Collection<MapEntryNode> routes) {
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
             new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(
                 extractRoutes(routes)).build()).build();
@@ -60,4 +60,15 @@ public final class LabeledUnicastIpv4RIBSupport extends AbstractLabeledUnicastRI
         }
         return null;
     }
+
+    @Override
+    public Collection<LabeledUnicastRoute> changedRoutes(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
+            .ns.yang.bgp.labeled.unicast.rev171207.bgp.rib.rib.peer.adj.rib.in.tables.routes
+            .LabeledUnicastRoutesCase routes) {
+        final LabeledUnicastRoutes routeCont =  routes.getLabeledUnicastRoutes();
+        if (routeCont == null) {
+            return Collections.emptyList();
+        }
+        return routeCont.getLabeledUnicastRoute();
+    }
 }