Bump upstreams
[bgpcep.git] / bgp / openconfig-rp-spi / src / main / java / org / opendaylight / protocol / bgp / openconfig / routing / policy / spi / registry / ActionsRegistryImpl.java
index 1d3b9c8b9d7e2888c4efa1adbb8ae6eb3dbb9a39..a9025ddf99c86ac0f65a06fbe1c6c6f88a6e2dd1 100644 (file)
@@ -13,7 +13,6 @@ import com.google.common.base.Preconditions;
 import java.util.HashMap;
 import java.util.Map;
 import org.checkerframework.checker.lock.qual.GuardedBy;
-import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.ActionsAugPolicy;
 import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.action.BgpActionAugPolicy;
@@ -32,17 +31,17 @@ import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev1
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.statement.Actions;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-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.message.rev180329.path.attributes.AttributesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPrefBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.MultiExitDiscBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.OriginBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpOrigin;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.CNextHop;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv6NextHopCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv6.next.hop._case.Ipv6NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.MultiExitDiscBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpOrigin;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.CNextHop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv6NextHopCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv6.next.hop._case.Ipv6NextHopBuilder;
 import org.opendaylight.yangtools.concepts.AbstractRegistration;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 import org.opendaylight.yangtools.yang.binding.ChildOf;
@@ -191,13 +190,13 @@ final class ActionsRegistryImpl {
                         if (address.getIpv4Address() != null) {
                             nhNew = new Ipv4NextHopCaseBuilder()
                                     .setIpv4NextHop(new Ipv4NextHopBuilder()
-                                        .setGlobal(IetfInetUtil.INSTANCE.ipv4AddressNoZoneFor(address.getIpv4Address()))
+                                        .setGlobal(IetfInetUtil.ipv4AddressNoZoneFor(address.getIpv4Address()))
                                         .build())
                                     .build();
                         } else {
                             nhNew = new Ipv6NextHopCaseBuilder()
                                     .setIpv6NextHop(new Ipv6NextHopBuilder()
-                                        .setGlobal(IetfInetUtil.INSTANCE.ipv6AddressNoZoneFor(address.getIpv6Address()))
+                                        .setGlobal(IetfInetUtil.ipv6AddressNoZoneFor(address.getIpv6Address()))
                                         .build())
                                     .build();
                         }
@@ -213,21 +212,15 @@ final class ActionsRegistryImpl {
                 attributesUpdated = attributesUpdatedBuilder.build();
             }
 
-            final Map<Class<? extends Augmentation<?>>, Augmentation<?>> bgpConditionsAug = BindingReflections
-                    .getAugmentations(bgpAction);
-
-            if (bgpConditionsAug != null) {
-                for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry
-                        : bgpConditionsAug.entrySet()) {
-                    final BgpActionAugPolicy handler = this.bgpAugActionsRegistry.get(entry.getKey());
-                    if (handler == null) {
-                        continue;
-                    } else if (attributesUpdated == null) {
-                        return null;
-                    }
-                    attributesUpdated = handler.applyExportAction(routeEntryInfo, routeEntryExportParameters,
-                            attributesUpdated, entry.getValue());
+            for (final Augmentation<BgpActions> action : bgpAction.augmentations().values()) {
+                final BgpActionAugPolicy handler = this.bgpAugActionsRegistry.get(action.implementedInterface());
+                if (handler == null) {
+                    continue;
+                } else if (attributesUpdated == null) {
+                    return null;
                 }
+                attributesUpdated = handler.applyExportAction(routeEntryInfo, routeEntryExportParameters,
+                    attributesUpdated, action);
             }
         }
 
@@ -236,22 +229,15 @@ final class ActionsRegistryImpl {
         }
 
         // Export Actions Aug
-        final Map<Class<? extends Augmentation<?>>, Augmentation<?>> conditionsAug = BindingReflections
-                .getAugmentations(actions);
-
-        if (conditionsAug == null) {
-            return attributes;
-        }
-
-        for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry : conditionsAug.entrySet()) {
-            final ActionsAugPolicy handler = this.actionsRegistry.get(entry.getKey());
+        for (final Augmentation<Actions> entry : actions.augmentations().values()) {
+            final ActionsAugPolicy handler = this.actionsRegistry.get(entry.implementedInterface());
             if (attributesUpdated == null) {
                 return null;
             } else if (handler == null) {
                 continue;
             }
-            attributesUpdated = handler.applyExportAction(routeEntryInfo, routeEntryExportParameters,
-                    attributesUpdated, (Augmentation<Actions>) entry.getValue());
+            attributesUpdated = handler.applyExportAction(routeEntryInfo, routeEntryExportParameters, attributesUpdated,
+                entry);
         }
 
         return attributesUpdated;
@@ -303,44 +289,30 @@ final class ActionsRegistryImpl {
                 return null;
             }
 
-            final Map<Class<? extends Augmentation<?>>, Augmentation<?>> bgpConditionsAug = BindingReflections
-                    .getAugmentations(bgpAction);
-
-            if (bgpConditionsAug == null) {
-                return attributes;
-            }
-
-            for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry
-                    : bgpConditionsAug.entrySet()) {
-                final BgpActionAugPolicy handler = this.bgpAugActionsRegistry.get(entry.getKey());
+            for (final Augmentation<BgpActions> action : bgpAction.augmentations().values()) {
+                final BgpActionAugPolicy handler = this.bgpAugActionsRegistry.get(action.implementedInterface());
                 if (handler == null) {
                     continue;
                 } else if (attributesUpdated == null) {
                     return null;
                 }
                 attributesUpdated = handler.applyImportAction(routeEntryInfo, routeParameters, attributesUpdated,
-                        entry.getValue());
+                    action);
             }
             if (attributesUpdated == null) {
                 return null;
             }
         }
-        // Augmented Actions
-        final Map<Class<? extends Augmentation<?>>, Augmentation<?>> conditionsAug = BindingReflections
-                .getAugmentations(actions);
 
-        if (conditionsAug == null) {
-            return attributesUpdated;
-        }
-        for (final Map.Entry<Class<? extends Augmentation<?>>, Augmentation<?>> entry : conditionsAug.entrySet()) {
-            final ActionsAugPolicy handler = this.actionsRegistry.get(entry.getKey());
+        // Augmented Actions
+        for (final Augmentation<Actions> action : actions.augmentations().values()) {
+            final ActionsAugPolicy handler = this.actionsRegistry.get(action.implementedInterface());
             if (handler == null) {
                 continue;
             } else if (attributesUpdated == null) {
                 return null;
             }
-            attributesUpdated = handler.applyImportAction(routeEntryInfo, routeParameters, attributesUpdated,
-                    (Augmentation<Actions>) entry.getValue());
+            attributesUpdated = handler.applyImportAction(routeEntryInfo, routeParameters, attributesUpdated, action);
         }
         return attributesUpdated;
     }