From cb068ff4942e1786bcacc2c9ed07f7bdf9cb5ea9 Mon Sep 17 00:00:00 2001 From: "Claudio D. Gasparini" Date: Thu, 14 Jun 2018 16:56:18 +0200 Subject: [PATCH] Improve Attribute serializer/parser Interfaces use Attribute interface as parameter instead of DataObject. Removing all redundant cast and validations Change-Id: I97aa58e71cf27a38daf618839d8070ef6dcec48a Signed-off-by: Claudio D. Gasparini --- .../bgp/evpn/impl/EvpnRibSupport.java | 2 +- .../bgp/evpn/impl/nlri/EvpnNlriParser.java | 6 +- .../flowspec/AbstractFlowspecNlriParser.java | 6 +- .../AbstractFlowspecL3vpnNlriParser.java | 3 +- .../bgp/inet/codec/Ipv4NlriParser.java | 7 +- .../bgp/inet/codec/Ipv6NlriParser.java | 7 +- .../mcast/nlri/L3vpnMcastIpv4NlriHandler.java | 7 +- .../mcast/nlri/L3vpnMcastIpv6NlriHandler.java | 7 +- .../l3vpn/unicast/AbstractVpnNlriParser.java | 6 +- .../bgp/labeled/unicast/LUNlriParser.java | 6 +- .../attribute/LinkstateAttributeParser.java | 7 +- .../impl/nlri/LinkstateNlriParser.java | 7 +- ...PEDistinguisherLabelsAttributeHandler.java | 6 +- .../PMSITunnelAttributeHandler.java | 7 +- .../mvpn/impl/nlri/MvpnIpv4NlriHandler.java | 7 +- .../mvpn/impl/nlri/MvpnIpv6NlriHandler.java | 7 +- .../update/AS4AggregatorAttributeParser.java | 4 +- .../update/AS4PathAttributeParser.java | 4 +- .../update/AggregatorAttributeParser.java | 8 +-- .../message/update/AigpAttributeParser.java | 8 +-- .../message/update/AsPathAttributeParser.java | 7 +- .../AtomicAggregateAttributeParser.java | 9 +-- .../update/BgpPrefixSidAttributeParser.java | 7 +- .../update/ClusterIdAttributeParser.java | 10 +-- .../update/CommunitiesAttributeParser.java | 11 +-- .../ExtendedCommunitiesAttributeParser.java | 8 +-- .../LocalPreferenceAttributeParser.java | 10 +-- .../update/MPReachAttributeParser.java | 9 +-- .../update/MPUnreachAttributeParser.java | 12 ++-- ...MultiExitDiscriminatorAttributeParser.java | 8 +-- .../update/NextHopAttributeParser.java | 7 +- .../message/update/OriginAttributeParser.java | 34 +++++----- .../update/OriginatorIdAttributeParser.java | 9 +-- .../UnrecognizedAttributesSerializer.java | 10 +-- .../bgp/parser/spi/AttributeRegistry.java | 3 +- .../bgp/parser/spi/AttributeSerializer.java | 5 +- .../bgp/parser/spi/NlriSerializer.java | 4 +- .../spi/pojo/SimpleAttributeRegistry.java | 7 +- .../bgp/parser/spi/pojo/BgpTestActivator.java | 67 ++++++++++--------- .../parser/spi/pojo/SimpleRegistryTest.java | 32 ++++----- .../bgp/rib/spi/AbstractRIBSupport.java | 13 ++-- 41 files changed, 143 insertions(+), 261 deletions(-) diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java index 2a27f33197..c5d84b1a03 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java @@ -103,7 +103,7 @@ final class EvpnRibSupport extends AbstractRIBSupport routes = maybeRoutes.get(); if (routes instanceof UnkeyedListNode) { - final YangInstanceIdentifier base = routesPath.node(routesContainerIdentifier()).node(routeNid()); + final YangInstanceIdentifier base = routesYangInstanceIdentifier(routesPath); for (final UnkeyedListEntryNode e : ((UnkeyedListNode) routes).getValue()) { final NodeIdentifierWithPredicates routeKey = createRouteKey(e); function.apply(tx, base, routeKey, e, attributes); diff --git a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParser.java b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParser.java index e627ba32b2..42e9be00d4 100644 --- a/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParser.java +++ b/bgp/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EvpnNlriParser.java @@ -11,7 +11,6 @@ import static org.opendaylight.bgp.concepts.RouteDistinguisherUtil.parseRouteDis import static org.opendaylight.bgp.concepts.RouteDistinguisherUtil.serializeRouteDistinquisher; import static org.opendaylight.protocol.bgp.evpn.impl.nlri.NlriModelUtil.extractRouteDistinguisher; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.ArrayList; @@ -45,7 +44,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.SubsequentAddressFamily; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; @@ -142,9 +140,7 @@ public final class EvpnNlriParser implements NlriParser, NlriSerializer { } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a Attributes object"); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); if (pathAttributes1 != null) { diff --git a/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecNlriParser.java b/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecNlriParser.java index eacd40e3c6..299ec26ce9 100644 --- a/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecNlriParser.java +++ b/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/AbstractFlowspecNlriParser.java @@ -87,7 +87,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.SubsequentAddressFamily; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; @@ -187,10 +186,7 @@ public abstract class AbstractFlowspecNlriParser implements NlriParser, NlriSeri public abstract DestinationType createAdvertizedRoutesDestinationType(@Nonnull Object[] nlriFields, @Nullable PathId pathId); @Override - public final void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Attributes pathAttributes = (Attributes) attribute; + public final void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); diff --git a/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/AbstractFlowspecL3vpnNlriParser.java b/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/AbstractFlowspecL3vpnNlriParser.java index a1cfc3fa67..bb1125fae5 100644 --- a/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/AbstractFlowspecL3vpnNlriParser.java +++ b/bgp/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/AbstractFlowspecL3vpnNlriParser.java @@ -27,7 +27,8 @@ import org.slf4j.LoggerFactory; public abstract class AbstractFlowspecL3vpnNlriParser extends AbstractFlowspecNlriParser { private static final Logger LOG = LoggerFactory.getLogger(AbstractFlowspecL3vpnNlriParser.class); - public static final NodeIdentifier RD_NID = new NodeIdentifier(QName.create(Flowspec.QNAME.getNamespace(), Flowspec.QNAME.getRevision(), "route-distinguisher")); + public static final NodeIdentifier RD_NID = new NodeIdentifier(QName.create(Flowspec.QNAME.getModule(), + "route-distinguisher")); protected AbstractFlowspecL3vpnNlriParser(final SimpleFlowspecTypeRegistry flowspecTypeRegistry) { super(flowspecTypeRegistry); diff --git a/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/codec/Ipv4NlriParser.java b/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/codec/Ipv4NlriParser.java index ed8fe06029..3064f00778 100644 --- a/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/codec/Ipv4NlriParser.java +++ b/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/codec/Ipv4NlriParser.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.inet.codec; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; @@ -37,7 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.SubsequentAddressFamily; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class Ipv4NlriParser implements NlriParser, NlriSerializer { @@ -74,10 +72,7 @@ public final class Ipv4NlriParser implements NlriParser, NlriSerializer { } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); if (pathAttributes1 != null) { diff --git a/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/codec/Ipv6NlriParser.java b/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/codec/Ipv6NlriParser.java index aad2127269..7af69ba40f 100644 --- a/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/codec/Ipv6NlriParser.java +++ b/bgp/inet/src/main/java/org/opendaylight/protocol/bgp/inet/codec/Ipv6NlriParser.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.inet.codec; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; @@ -37,7 +36,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.SubsequentAddressFamily; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class Ipv6NlriParser implements NlriParser, NlriSerializer { @@ -74,10 +72,7 @@ public final class Ipv6NlriParser implements NlriParser, NlriSerializer { } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); if (pathAttributes1 != null) { diff --git a/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/mcast/nlri/L3vpnMcastIpv4NlriHandler.java b/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/mcast/nlri/L3vpnMcastIpv4NlriHandler.java index d7378a3b3a..6367739b18 100644 --- a/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/mcast/nlri/L3vpnMcastIpv4NlriHandler.java +++ b/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/mcast/nlri/L3vpnMcastIpv4NlriHandler.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.l3vpn.mcast.nlri; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import org.opendaylight.protocol.bgp.parser.BGPParsingException; import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl; @@ -30,7 +29,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutes; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; /** * https://tools.ietf.org/html/rfc6514#section-4. @@ -76,10 +74,7 @@ public final class L3vpnMcastIpv4NlriHandler implements NlriParser, NlriSerializ } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a Attributes object"); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); if (pathAttributes1 != null) { diff --git a/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/mcast/nlri/L3vpnMcastIpv6NlriHandler.java b/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/mcast/nlri/L3vpnMcastIpv6NlriHandler.java index 9463c31a51..700f4dc559 100644 --- a/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/mcast/nlri/L3vpnMcastIpv6NlriHandler.java +++ b/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/mcast/nlri/L3vpnMcastIpv6NlriHandler.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.l3vpn.mcast.nlri; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import org.opendaylight.protocol.bgp.parser.BGPParsingException; import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl; @@ -30,7 +29,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutes; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; /** * https://tools.ietf.org/html/rfc6514#section-4. @@ -76,10 +74,7 @@ public final class L3vpnMcastIpv6NlriHandler implements NlriParser, NlriSerializ } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a Attributes object"); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); if (pathAttributes1 != null) { diff --git a/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/unicast/AbstractVpnNlriParser.java b/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/unicast/AbstractVpnNlriParser.java index ed46786fc3..596afabaec 100644 --- a/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/unicast/AbstractVpnNlriParser.java +++ b/bgp/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/unicast/AbstractVpnNlriParser.java @@ -27,7 +27,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutes; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutes; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.destination.type.VpnDestination; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -78,10 +77,7 @@ public abstract class AbstractVpnNlriParser implements NlriParser, NlriSerialize } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a Attributes object"); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); List vpnDst = null; diff --git a/bgp/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/LUNlriParser.java b/bgp/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/LUNlriParser.java index febefe4292..58f1eb10d6 100644 --- a/bgp/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/LUNlriParser.java +++ b/bgp/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/LUNlriParser.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.labeled.unicast; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.ArrayList; @@ -53,7 +52,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel; -import org.opendaylight.yangtools.yang.binding.DataObject; public class LUNlriParser implements NlriParser, NlriSerializer { @@ -62,9 +60,7 @@ public class LUNlriParser implements NlriParser, NlriSerializer { private static final int WITHDRAW_LABEL_INT_VALUE = 0x800000; @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a Attributes object"); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); if (pathAttributes1 != null) { diff --git a/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/LinkstateAttributeParser.java b/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/LinkstateAttributeParser.java index 8082b7e0e8..117204d189 100644 --- a/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/LinkstateAttributeParser.java +++ b/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/LinkstateAttributeParser.java @@ -7,7 +7,6 @@ */ package org.opendaylight.protocol.bgp.linkstate.impl.attribute; -import com.google.common.base.Preconditions; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import io.netty.buffer.ByteBuf; @@ -36,7 +35,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess 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.multiprotocol.rev180329.Attributes2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -140,9 +138,8 @@ public final class LinkstateAttributeParser implements AttributeParser, Attribut */ @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object."); - final Attributes1 pathAttributes1 = ((Attributes) attribute).augmentation(Attributes1.class); + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { + final Attributes1 pathAttributes1 = attribute.augmentation(Attributes1.class); if (pathAttributes1 == null) { return; } diff --git a/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/nlri/LinkstateNlriParser.java b/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/nlri/LinkstateNlriParser.java index fb6016f7db..34dd366928 100644 --- a/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/nlri/LinkstateNlriParser.java +++ b/bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/nlri/LinkstateNlriParser.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.linkstate.impl.nlri; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import java.math.BigInteger; import java.util.ArrayList; @@ -47,7 +46,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutes; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; @@ -140,10 +138,7 @@ public final class LinkstateNlriParser implements NlriParser, NlriSerializer { } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); if (pathAttributes1 != null) { diff --git a/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/PEDistinguisherLabelsAttributeHandler.java b/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/PEDistinguisherLabelsAttributeHandler.java index edc2ac8d7f..6b58ca572f 100644 --- a/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/PEDistinguisherLabelsAttributeHandler.java +++ b/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/PEDistinguisherLabelsAttributeHandler.java @@ -74,11 +74,9 @@ public final class PEDistinguisherLabelsAttributeHandler implements AttributePar } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { final PeDistinguisherLabelsAttributeAugmentation att = - ((Attributes) attribute).augmentation(PeDistinguisherLabelsAttributeAugmentation.class); + attribute.augmentation(PeDistinguisherLabelsAttributeAugmentation.class); if (att == null) { return; diff --git a/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/PMSITunnelAttributeHandler.java b/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/PMSITunnelAttributeHandler.java index 3c58e54185..41ef178edb 100644 --- a/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/PMSITunnelAttributeHandler.java +++ b/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/PMSITunnelAttributeHandler.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.mvpn.impl.attributes; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.opendaylight.protocol.bgp.mvpn.spi.pojo.attributes.tunnel.identifier.SimpleTunnelIdentifierRegistry; @@ -79,10 +78,8 @@ public final class PMSITunnelAttributeHandler implements AttributeParser, Attrib } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final PmsiTunnelAugmentation pmsiTunnelAugmentation = ((Attributes) attribute) + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { + final PmsiTunnelAugmentation pmsiTunnelAugmentation = attribute .augmentation(PmsiTunnelAugmentation.class); if (pmsiTunnelAugmentation == null) { return; diff --git a/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/MvpnIpv4NlriHandler.java b/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/MvpnIpv4NlriHandler.java index edbf1f7516..da00045a23 100644 --- a/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/MvpnIpv4NlriHandler.java +++ b/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/MvpnIpv4NlriHandler.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.mvpn.impl.nlri; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import org.opendaylight.protocol.bgp.parser.BGPParsingException; import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl; @@ -27,7 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.ipv4.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationMvpnIpv4AdvertizedCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.ipv4.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationMvpnIpv4WithdrawnCase; -import org.opendaylight.yangtools.yang.binding.DataObject; /** * https://tools.ietf.org/html/rfc6514#section-4. @@ -65,10 +63,7 @@ public final class MvpnIpv4NlriHandler implements NlriParser, NlriSerializer { } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a Attributes object"); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); if (pathAttributes1 != null) { diff --git a/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/MvpnIpv6NlriHandler.java b/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/MvpnIpv6NlriHandler.java index 04541b0060..d432cf26b1 100644 --- a/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/MvpnIpv6NlriHandler.java +++ b/bgp/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/MvpnIpv6NlriHandler.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.mvpn.impl.nlri; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import org.opendaylight.protocol.bgp.parser.BGPParsingException; import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl; @@ -27,7 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.mp.unreach.nlri.WithdrawnRoutesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.ipv6.rev180417.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationMvpnIpv6AdvertizedCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.ipv6.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationMvpnIpv6WithdrawnCase; -import org.opendaylight.yangtools.yang.binding.DataObject; /** * https://tools.ietf.org/html/rfc6514#section-4. @@ -66,10 +64,7 @@ public final class MvpnIpv6NlriHandler implements NlriParser, NlriSerializer { } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a Attributes object"); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); if (pathAttributes1 != null) { diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AS4AggregatorAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AS4AggregatorAttributeParser.java index 871d60d51c..8e52de0a2a 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AS4AggregatorAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AS4AggregatorAttributeParser.java @@ -10,8 +10,8 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update; import io.netty.buffer.ByteBuf; import org.opendaylight.protocol.bgp.parser.spi.AttributeParser; import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer; +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.yangtools.yang.binding.DataObject; public final class AS4AggregatorAttributeParser implements AttributeParser, AttributeSerializer { @@ -23,7 +23,7 @@ public final class AS4AggregatorAttributeParser implements AttributeParser, Attr } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { // AS4 Aggregator is ignored } } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AS4PathAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AS4PathAttributeParser.java index ea202a6c01..ff7b08595a 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AS4PathAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AS4PathAttributeParser.java @@ -10,8 +10,8 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update; import io.netty.buffer.ByteBuf; import org.opendaylight.protocol.bgp.parser.spi.AttributeParser; import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer; +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.yangtools.yang.binding.DataObject; public final class AS4PathAttributeParser implements AttributeParser, AttributeSerializer { @@ -23,7 +23,7 @@ public final class AS4PathAttributeParser implements AttributeParser, AttributeS } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { // AS4 Path is ignored } } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AggregatorAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AggregatorAttributeParser.java index c44e09b128..28f026de83 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AggregatorAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AggregatorAttributeParser.java @@ -24,7 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.Aggregator; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.AggregatorBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ShortAsNumber; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class AggregatorAttributeParser implements AttributeParser, AttributeSerializer { @@ -39,7 +38,7 @@ public final class AggregatorAttributeParser implements AttributeParser, Attribu /** * Parse {@link Aggregator} from bytes * - * @param buffer byte buffer to be parsed + * @param buffer byte buffer to be parsed * @param builder AttributesBuilder into which parsed {@link Aggregator} will be set */ @Override @@ -50,10 +49,7 @@ public final class AggregatorAttributeParser implements AttributeParser, Attribu } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Aggregator aggregator = pathAttributes.getAggregator(); if (aggregator == null) { return; diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AigpAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AigpAttributeParser.java index 99224ce8fb..92ae2f8076 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AigpAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AigpAttributeParser.java @@ -7,7 +7,6 @@ */ package org.opendaylight.protocol.bgp.parser.impl.message.update; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.math.BigInteger; @@ -23,7 +22,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.aigp.AigpTlv; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.aigp.AigpTlvBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.AccumulatedIgpMetric; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,10 +45,8 @@ public class AigpAttributeParser implements AttributeParser, AttributeSerializer } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Aigp aigpAttribute = ((Attributes) attribute).getAigp(); + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { + final Aigp aigpAttribute = attribute.getAigp(); if (aigpAttribute == null) { return; } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AsPathAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AsPathAttributeParser.java index e3a8161bff..c655448cde 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AsPathAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AsPathAttributeParser.java @@ -9,7 +9,6 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update; import static java.util.Objects.requireNonNull; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.ArrayList; @@ -30,7 +29,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.AsPathBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.as.path.Segments; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.as.path.SegmentsBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -95,10 +93,7 @@ public final class AsPathAttributeParser implements AttributeParser, AttributeSe } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final AsPath asPath = pathAttributes.getAsPath(); if (asPath == null) { return; diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AtomicAggregateAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AtomicAggregateAttributeParser.java index 97f402c139..acc3acbea1 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AtomicAggregateAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AtomicAggregateAttributeParser.java @@ -7,7 +7,6 @@ */ package org.opendaylight.protocol.bgp.parser.impl.message.update; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.opendaylight.protocol.bgp.parser.spi.AttributeParser; @@ -16,9 +15,8 @@ import org.opendaylight.protocol.bgp.parser.spi.AttributeUtil; 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.AtomicAggregateBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; -public final class AtomicAggregateAttributeParser implements AttributeParser,AttributeSerializer { +public final class AtomicAggregateAttributeParser implements AttributeParser, AttributeSerializer { public static final int TYPE = 6; @@ -28,10 +26,7 @@ public final class AtomicAggregateAttributeParser implements AttributeParser,Att } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { if (pathAttributes.getAtomicAggregate() == null) { return; } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/BgpPrefixSidAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/BgpPrefixSidAttributeParser.java index b8e5c9924a..6c31d06b91 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/BgpPrefixSidAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/BgpPrefixSidAttributeParser.java @@ -9,7 +9,6 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update; import static java.util.Objects.requireNonNull; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; @@ -25,7 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.bgp.prefix.sid.BgpPrefixSidTlvs; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.bgp.prefix.sid.BgpPrefixSidTlvsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class BgpPrefixSidAttributeParser implements AttributeParser, AttributeSerializer { @@ -38,10 +36,7 @@ public final class BgpPrefixSidAttributeParser implements AttributeParser, Attri } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final BgpPrefixSid prefixSid = pathAttributes.getBgpPrefixSid(); if (prefixSid == null) { return; diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/ClusterIdAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/ClusterIdAttributeParser.java index e6ee76c953..f1a21501b9 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/ClusterIdAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/ClusterIdAttributeParser.java @@ -7,7 +7,6 @@ */ package org.opendaylight.protocol.bgp.parser.impl.message.update; -import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -21,7 +20,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.ClusterId; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.ClusterIdBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ClusterIdentifier; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class ClusterIdAttributeParser implements AttributeParser, AttributeSerializer { @@ -37,15 +35,13 @@ public final class ClusterIdAttributeParser implements AttributeParser, Attribut } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final ClusterId cid = ((Attributes) attribute).getClusterId(); + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { + final ClusterId cid = pathAttributes.getClusterId(); if (cid == null) { return; } final List cluster = cid.getCluster(); - if (cluster == null || cluster.isEmpty()) { + if (cluster == null || cluster.isEmpty()) { return; } final ByteBuf clusterIdBuffer = Unpooled.buffer(); diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/CommunitiesAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/CommunitiesAttributeParser.java index 929dae63cb..de197f89a1 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/CommunitiesAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/CommunitiesAttributeParser.java @@ -9,8 +9,6 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update; import static java.util.Objects.requireNonNull; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -27,7 +25,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess 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.Communities; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Community; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class CommunitiesAttributeParser implements AttributeParser, AttributeSerializer { @@ -64,8 +61,7 @@ public final class CommunitiesAttributeParser implements AttributeParser, Attrib * @return new Community * @throws BGPDocumentedException */ - @VisibleForTesting - public static Community parseCommunity(final ReferenceCache refCache, final ByteBuf buffer) + private static Community parseCommunity(final ReferenceCache refCache, final ByteBuf buffer) throws BGPDocumentedException { if (buffer.readableBytes() != COMMUNITY_LENGTH) { throw new BGPDocumentedException("Community with wrong length: " @@ -83,9 +79,8 @@ public final class CommunitiesAttributeParser implements AttributeParser, Attrib } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object."); - final List communities = ((Attributes) attribute).getCommunities(); + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { + final List communities = pathAttributes.getCommunities(); if (communities == null || communities.isEmpty()) { return; } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/ExtendedCommunitiesAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/ExtendedCommunitiesAttributeParser.java index 765e573fb7..4b7b649819 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/ExtendedCommunitiesAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/ExtendedCommunitiesAttributeParser.java @@ -10,7 +10,6 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update; import static java.util.Objects.requireNonNull; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.ArrayList; @@ -24,7 +23,6 @@ import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommu 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.ExtendedCommunities; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class ExtendedCommunitiesAttributeParser implements AttributeParser, AttributeSerializer { @@ -50,10 +48,8 @@ public final class ExtendedCommunitiesAttributeParser implements AttributeParser } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final List communitiesList = ((Attributes) attribute).getExtendedCommunities(); + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { + final List communitiesList = pathAttributes.getExtendedCommunities(); if (communitiesList == null || communitiesList.isEmpty()) { return; } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/LocalPreferenceAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/LocalPreferenceAttributeParser.java index f55931d053..f49943bf13 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/LocalPreferenceAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/LocalPreferenceAttributeParser.java @@ -7,7 +7,6 @@ */ package org.opendaylight.protocol.bgp.parser.impl.message.update; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.opendaylight.protocol.bgp.parser.spi.AttributeParser; @@ -17,9 +16,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess 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.LocalPref; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPrefBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; -public final class LocalPreferenceAttributeParser implements AttributeParser,AttributeSerializer { +public final class LocalPreferenceAttributeParser implements AttributeParser, AttributeSerializer { public static final int TYPE = 5; @@ -29,10 +27,8 @@ public final class LocalPreferenceAttributeParser implements AttributeParser,Att } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final LocalPref lp = ((Attributes) attribute).getLocalPref(); + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { + final LocalPref lp = attribute.getLocalPref(); if (lp == null) { return; } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MPReachAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MPReachAttributeParser.java index ad3c9c2a30..23b9208b4a 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MPReachAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MPReachAttributeParser.java @@ -9,7 +9,6 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update; import static java.util.Objects.requireNonNull; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.opendaylight.protocol.bgp.parser.BGPDocumentedException; @@ -24,7 +23,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlri; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class MPReachAttributeParser extends ReachAttributeParser{ @@ -52,10 +50,7 @@ public final class MPReachAttributeParser extends ReachAttributeParser{ } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes pathAttributes, final ByteBuf byteAggregator) { final Attributes1 pathAttributes1 = pathAttributes.augmentation(Attributes1.class); if (pathAttributes1 == null) { return; @@ -65,7 +60,7 @@ public final class MPReachAttributeParser extends ReachAttributeParser{ this.reg.serializeMpReach(mpReachNlri, reachBuffer); for (final NlriSerializer nlriSerializer : this.reg.getSerializers()) { - nlriSerializer.serializeAttribute(attribute, reachBuffer); + nlriSerializer.serializeAttribute(pathAttributes, reachBuffer); } AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, reachBuffer, byteAggregator); } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MPUnreachAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MPUnreachAttributeParser.java index 19eeb0db05..4bebea7c6c 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MPUnreachAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MPUnreachAttributeParser.java @@ -9,7 +9,6 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update; import static java.util.Objects.requireNonNull; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.opendaylight.protocol.bgp.parser.BGPDocumentedException; @@ -24,7 +23,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes2Builder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlri; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class MPUnreachAttributeParser extends ReachAttributeParser { public static final int TYPE = 15; @@ -51,10 +49,8 @@ public final class MPUnreachAttributeParser extends ReachAttributeParser { } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Attributes pathAttributes = (Attributes) attribute; + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { + final Attributes pathAttributes = attribute; final Attributes2 pathAttributes2 = pathAttributes.augmentation(Attributes2.class); if (pathAttributes2 == null) { return; @@ -62,8 +58,8 @@ public final class MPUnreachAttributeParser extends ReachAttributeParser { final MpUnreachNlri mpUnreachNlri = pathAttributes2.getMpUnreachNlri(); final ByteBuf unreachBuffer = Unpooled.buffer(); this.reg.serializeMpUnReach(mpUnreachNlri, unreachBuffer); - for (final NlriSerializer nlriSerializer : this.reg.getSerializers()){ - nlriSerializer.serializeAttribute(attribute,unreachBuffer); + for (final NlriSerializer nlriSerializer : this.reg.getSerializers()) { + nlriSerializer.serializeAttribute(attribute, unreachBuffer); } AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, unreachBuffer, byteAggregator); } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MultiExitDiscriminatorAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MultiExitDiscriminatorAttributeParser.java index 3f76d7e035..2acdbf3843 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MultiExitDiscriminatorAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MultiExitDiscriminatorAttributeParser.java @@ -7,7 +7,6 @@ */ package org.opendaylight.protocol.bgp.parser.impl.message.update; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.opendaylight.protocol.bgp.parser.spi.AttributeParser; @@ -17,7 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess 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.MultiExitDisc; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.MultiExitDiscBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class MultiExitDiscriminatorAttributeParser implements AttributeParser, AttributeSerializer { @@ -29,10 +27,8 @@ public final class MultiExitDiscriminatorAttributeParser implements AttributePar } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final MultiExitDisc multiExitDisc = ((Attributes) attribute).getMultiExitDisc(); + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { + final MultiExitDisc multiExitDisc = attribute.getMultiExitDisc(); if (multiExitDisc == null) { return; } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/NextHopAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/NextHopAttributeParser.java index c4b1998caa..be99513f11 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/NextHopAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/NextHopAttributeParser.java @@ -18,7 +18,6 @@ import org.opendaylight.protocol.util.Ipv4Util; 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.types.rev180329.next.hop.CNextHop; -import org.opendaylight.yangtools.yang.binding.DataObject; public final class NextHopAttributeParser implements AttributeParser, AttributeSerializer { @@ -33,10 +32,8 @@ public final class NextHopAttributeParser implements AttributeParser, AttributeS } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final CNextHop cNextHop = ((Attributes) attribute).getCNextHop(); + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { + final CNextHop cNextHop = attribute.getCNextHop(); if (cNextHop == null) { return; } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/OriginAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/OriginAttributeParser.java index 0f541a1c92..d7cf13efd6 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/OriginAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/OriginAttributeParser.java @@ -7,7 +7,6 @@ */ package org.opendaylight.protocol.bgp.parser.impl.message.update; -import com.google.common.base.Preconditions; import com.google.common.primitives.UnsignedBytes; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -21,7 +20,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.Origin; 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.yangtools.yang.binding.DataObject; public final class OriginAttributeParser implements AttributeParser, AttributeSerializer { @@ -37,33 +35,31 @@ public final class OriginAttributeParser implements AttributeParser, AttributeSe final BgpOrigin borigin = BgpOrigin.forValue(UnsignedBytes.toInt(rawOrigin)); if (borigin == null) { throw new BGPDocumentedException("Unknown Origin type.", BGPError.ORIGIN_ATTR_NOT_VALID, - new byte[] { (byte) 0x01, (byte) 0x01, rawOrigin} ); + new byte[]{(byte) 0x01, (byte) 0x01, rawOrigin}); } switch (borigin) { - case Egp: - builder.setOrigin(EGP); - return; - case Igp: - builder.setOrigin(IGP); - return; - case Incomplete: - builder.setOrigin(INC); - return; - default: - return; + case Egp: + builder.setOrigin(EGP); + return; + case Igp: + builder.setOrigin(IGP); + return; + case Incomplete: + builder.setOrigin(INC); + return; + default: + return; } } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final Origin origin = ((Attributes) attribute).getOrigin(); + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { + final Origin origin = attribute.getOrigin(); if (origin == null) { return; } AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE, - Unpooled.wrappedBuffer(new byte[] {UnsignedBytes.checkedCast(origin.getValue().getIntValue())}), + Unpooled.wrappedBuffer(new byte[]{UnsignedBytes.checkedCast(origin.getValue().getIntValue())}), byteAggregator); } } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/OriginatorIdAttributeParser.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/OriginatorIdAttributeParser.java index 90c6cba4fd..6cd7fd03fb 100644 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/OriginatorIdAttributeParser.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/OriginatorIdAttributeParser.java @@ -18,9 +18,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess 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.OriginatorIdBuilder; -import org.opendaylight.yangtools.yang.binding.DataObject; -public final class OriginatorIdAttributeParser implements AttributeParser,AttributeSerializer { +public final class OriginatorIdAttributeParser implements AttributeParser, AttributeSerializer { public static final int TYPE = 9; @@ -33,10 +32,8 @@ public final class OriginatorIdAttributeParser implements AttributeParser,Attrib } @Override - public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attribute instanceof Attributes, - "Attribute parameter is not a PathAttribute object."); - final OriginatorId originator = ((Attributes) attribute).getOriginatorId(); + public void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator) { + final OriginatorId originator = attribute.getOriginatorId(); if (originator == null) { return; } diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/UnrecognizedAttributesSerializer.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/UnrecognizedAttributesSerializer.java index 8de008d827..859148a2f9 100755 --- a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/UnrecognizedAttributesSerializer.java +++ b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/UnrecognizedAttributesSerializer.java @@ -8,7 +8,6 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update; -import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import java.util.List; @@ -16,7 +15,6 @@ import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer; import org.opendaylight.protocol.bgp.parser.spi.AttributeUtil; 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.attributes.UnrecognizedAttributes; -import org.opendaylight.yangtools.yang.binding.DataObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,14 +22,12 @@ public class UnrecognizedAttributesSerializer implements AttributeSerializer { private static final Logger LOG = LoggerFactory.getLogger(UnrecognizedAttributesSerializer.class); @Override - public void serializeAttribute(final DataObject attributes, final ByteBuf byteAggregator) { - Preconditions.checkArgument(attributes instanceof Attributes, - "Attributes parameter is not a PathAttribute object."); - final List unrecognizedAttrs = ((Attributes) attributes).getUnrecognizedAttributes(); + public void serializeAttribute(final Attributes attributes, final ByteBuf byteAggregator) { + final List unrecognizedAttrs = attributes.getUnrecognizedAttributes(); if (unrecognizedAttrs == null) { return; } - for (final UnrecognizedAttributes unrecognizedAttr: unrecognizedAttrs) { + for (final UnrecognizedAttributes unrecognizedAttr : unrecognizedAttrs) { LOG.trace("Serializing unrecognized attribute of type {}", unrecognizedAttr.getType()); int flags = AttributeUtil.OPTIONAL; if (unrecognizedAttr.isPartial()) { diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeRegistry.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeRegistry.java index 5dbcc741d2..4dc857cd19 100644 --- a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeRegistry.java +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeRegistry.java @@ -13,7 +13,6 @@ import javax.annotation.Nullable; import org.opendaylight.protocol.bgp.parser.BGPDocumentedException; import org.opendaylight.protocol.bgp.parser.BGPParsingException; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes; -import org.opendaylight.yangtools.yang.binding.DataObject; /** * @@ -35,5 +34,5 @@ public interface AttributeRegistry { * @param attribute Input BGP Attribute. * @param byteAggregator Output buffer. */ - void serializeAttribute(@Nonnull DataObject attribute, @Nonnull ByteBuf byteAggregator); + void serializeAttribute(@Nonnull Attributes attribute, @Nonnull ByteBuf byteAggregator); } diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeSerializer.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeSerializer.java index e3f334687c..ea5191751c 100644 --- a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeSerializer.java +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/AttributeSerializer.java @@ -8,11 +8,10 @@ package org.opendaylight.protocol.bgp.parser.spi; import io.netty.buffer.ByteBuf; - -import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes; public interface AttributeSerializer { - void serializeAttribute(final DataObject attribute,final ByteBuf byteAggregator); + void serializeAttribute(final Attributes attribute,final ByteBuf byteAggregator); } diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/NlriSerializer.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/NlriSerializer.java index d604d694d7..0f4d7e441c 100644 --- a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/NlriSerializer.java +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/NlriSerializer.java @@ -9,10 +9,10 @@ package org.opendaylight.protocol.bgp.parser.spi; import io.netty.buffer.ByteBuf; -import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes; public interface NlriSerializer { - void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator); + void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator); } diff --git a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleAttributeRegistry.java b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleAttributeRegistry.java index 50c6f4cc0e..ef9a782d9a 100644 --- a/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleAttributeRegistry.java +++ b/bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleAttributeRegistry.java @@ -46,7 +46,7 @@ final class SimpleAttributeRegistry implements AttributeRegistry { private final AttributeParser parser; private final ByteBuf buffer; - public RawAttribute(final AttributeParser parser, final ByteBuf buffer) { + RawAttribute(final AttributeParser parser, final ByteBuf buffer) { this.parser = requireNonNull(parser); this.buffer = requireNonNull(buffer); } @@ -102,7 +102,8 @@ final class SimpleAttributeRegistry implements AttributeRegistry { } } - private void processUnrecognized(final BitArray flags, final int type, final ByteBuf buffer, final int len) throws BGPDocumentedException { + private void processUnrecognized(final BitArray flags, final int type, final ByteBuf buffer, final int len) + throws BGPDocumentedException { if (!flags.get(OPTIONAL_BIT)) { throw new BGPDocumentedException("Well known attribute not recognized.", BGPError.WELL_KNOWN_ATTR_NOT_RECOGNIZED); } @@ -139,7 +140,7 @@ final class SimpleAttributeRegistry implements AttributeRegistry { } @Override - public void serializeAttribute(final DataObject attribute,final ByteBuf byteAggregator) { + public void serializeAttribute(final Attributes attribute,final ByteBuf byteAggregator) { for (final AttributeSerializer serializer : this.roSerializers.get()) { serializer.serializeAttribute(attribute, byteAggregator); } diff --git a/bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/BgpTestActivator.java b/bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/BgpTestActivator.java index 127806308b..594d5181a2 100644 --- a/bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/BgpTestActivator.java +++ b/bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/BgpTestActivator.java @@ -8,6 +8,10 @@ package org.opendaylight.protocol.bgp.parser.spi.pojo; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + import com.google.common.collect.Lists; import io.netty.buffer.ByteBuf; import java.util.List; @@ -38,6 +42,7 @@ import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommu import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.BgpParameters; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.bgp.parameters.optional.capabilities.CParameters; +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.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlriBuilder; @@ -148,37 +153,37 @@ public class BgpTestActivator extends AbstractBGPExtensionProviderActivator { private void initMock() { MockitoAnnotations.initMocks(this); try { - Mockito.doNothing().when(this.attrParser).parseAttribute(Mockito.any(ByteBuf.class), Mockito.any(AttributesBuilder.class), - Mockito.any(PeerSpecificParserConstraint.class)); - Mockito.doReturn(EMPTY).when(this.attrParser).toString(); - Mockito.doNothing().when(this.attrSerializer).serializeAttribute(Mockito.any(DataObject.class), Mockito.any(ByteBuf.class)); - Mockito.doReturn(EMPTY).when(this.attrSerializer).toString(); - - Mockito.doReturn(null).when(this.paramParser).parseParameter(Mockito.any(ByteBuf.class)); - Mockito.doReturn(EMPTY).when(this.paramParser).toString(); - Mockito.doNothing().when(this.paramSerializer).serializeParameter(Mockito.any(BgpParameters.class), Mockito.any(ByteBuf.class)); - Mockito.doReturn(EMPTY).when(this.paramSerializer).toString(); - - Mockito.doReturn(null).when(this.capaParser).parseCapability(Mockito.any(ByteBuf.class)); - Mockito.doReturn(EMPTY).when(this.capaParser).toString(); - Mockito.doNothing().when(this.capaSerializer).serializeCapability(Mockito.any(CParameters.class), Mockito.any(ByteBuf.class)); - Mockito.doReturn(EMPTY).when(this.capaSerializer).toString(); - - Mockito.doReturn(null).when(this.sidTlvParser).parseBgpPrefixSidTlv(Mockito.any(ByteBuf.class)); - Mockito.doReturn(EMPTY).when(this.sidTlvParser).toString(); - Mockito.doNothing().when(this.sidTlvSerializer).serializeBgpPrefixSidTlv(Mockito.any(BgpPrefixSidTlv.class), Mockito.any(ByteBuf.class)); - Mockito.doReturn(EMPTY).when(this.sidTlvSerializer).toString(); - Mockito.doReturn(0).when(this.sidTlvSerializer).getType(); - - Mockito.doReturn(Mockito.mock(Notification.class)).when(this.msgParser).parseMessageBody(Mockito.any(ByteBuf.class), Mockito.anyInt(), - Mockito.any(PeerSpecificParserConstraint.class)); - Mockito.doReturn(EMPTY).when(this.msgParser).toString(); - Mockito.doNothing().when(this.msgSerializer).serializeMessage(Mockito.any(Notification.class), Mockito.any(ByteBuf.class)); - Mockito.doReturn(EMPTY).when(this.msgSerializer).toString(); - - Mockito.doNothing().when(this.nlriParser).parseNlri(Mockito.any(ByteBuf.class), Mockito.any(MpUnreachNlriBuilder.class), Mockito.any()); - Mockito.doNothing().when(this.nlriParser).parseNlri(Mockito.any(ByteBuf.class), Mockito.any(MpReachNlriBuilder.class), Mockito.any()); - Mockito.doReturn(EMPTY).when(this.nlriParser).toString(); + Mockito.doNothing().when(this.attrParser).parseAttribute(any(ByteBuf.class), any(AttributesBuilder.class), + any(PeerSpecificParserConstraint.class)); + doReturn(EMPTY).when(this.attrParser).toString(); + Mockito.doNothing().when(this.attrSerializer).serializeAttribute(any(Attributes.class), any(ByteBuf.class)); + doReturn(EMPTY).when(this.attrSerializer).toString(); + + doReturn(null).when(this.paramParser).parseParameter(any(ByteBuf.class)); + doReturn(EMPTY).when(this.paramParser).toString(); + Mockito.doNothing().when(this.paramSerializer).serializeParameter(any(BgpParameters.class), any(ByteBuf.class)); + doReturn(EMPTY).when(this.paramSerializer).toString(); + + doReturn(null).when(this.capaParser).parseCapability(any(ByteBuf.class)); + doReturn(EMPTY).when(this.capaParser).toString(); + Mockito.doNothing().when(this.capaSerializer).serializeCapability(any(CParameters.class), any(ByteBuf.class)); + doReturn(EMPTY).when(this.capaSerializer).toString(); + + doReturn(null).when(this.sidTlvParser).parseBgpPrefixSidTlv(any(ByteBuf.class)); + doReturn(EMPTY).when(this.sidTlvParser).toString(); + Mockito.doNothing().when(this.sidTlvSerializer).serializeBgpPrefixSidTlv(any(BgpPrefixSidTlv.class), any(ByteBuf.class)); + doReturn(EMPTY).when(this.sidTlvSerializer).toString(); + doReturn(0).when(this.sidTlvSerializer).getType(); + + doReturn(mock(Notification.class)).when(this.msgParser).parseMessageBody(any(ByteBuf.class), Mockito.anyInt(), + any(PeerSpecificParserConstraint.class)); + doReturn(EMPTY).when(this.msgParser).toString(); + Mockito.doNothing().when(this.msgSerializer).serializeMessage(any(Notification.class), any(ByteBuf.class)); + doReturn(EMPTY).when(this.msgSerializer).toString(); + + Mockito.doNothing().when(this.nlriParser).parseNlri(any(ByteBuf.class), any(MpUnreachNlriBuilder.class), any()); + Mockito.doNothing().when(this.nlriParser).parseNlri(any(ByteBuf.class), any(MpReachNlriBuilder.class), any()); + doReturn(EMPTY).when(this.nlriParser).toString(); } catch (BGPDocumentedException | BGPParsingException e) { Assert.fail(); diff --git a/bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleRegistryTest.java b/bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleRegistryTest.java index 7c5f35bf5c..ab8046a60b 100644 --- a/bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleRegistryTest.java +++ b/bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleRegistryTest.java @@ -10,6 +10,7 @@ package org.opendaylight.protocol.bgp.parser.spi.pojo; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; @@ -37,6 +38,7 @@ import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint; import org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.BgpParameters; +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.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpReachNlri; @@ -84,17 +86,17 @@ public class SimpleRegistryTest { 0x00, 0x00, 0x00 }; final ByteBuf byteAggregator = Unpooled.buffer(attributeBytes.length); - attrReg.serializeAttribute(Mockito.mock(DataObject.class), byteAggregator); + attrReg.serializeAttribute(mock(Attributes.class), byteAggregator); attrReg.parseAttributes(Unpooled.wrappedBuffer(attributeBytes), CONSTRAINT); - verify(this.activator.attrParser, times(1)).parseAttribute(Mockito.any(ByteBuf.class), Mockito.any(AttributesBuilder.class), - Mockito.any(PeerSpecificParserConstraint.class)); - verify(this.activator.attrSerializer, times(1)).serializeAttribute(Mockito.any(DataObject.class), Mockito.any(ByteBuf.class)); + verify(this.activator.attrParser, times(1)).parseAttribute(any(ByteBuf.class), any(AttributesBuilder.class), + any(PeerSpecificParserConstraint.class)); + verify(this.activator.attrSerializer, times(1)).serializeAttribute(any(Attributes.class), any(ByteBuf.class)); } @Test public void testSimpleParameter() throws Exception { final ParameterRegistry paramReg = this.ctx.getParameterRegistry(); - final BgpParameters param = Mockito.mock(BgpParameters.class); + final BgpParameters param = mock(BgpParameters.class); Mockito.doReturn(BgpParameters.class).when(param).getImplementedInterface(); final byte[] paramBytes = { 0x00, 0x00 @@ -102,8 +104,8 @@ public class SimpleRegistryTest { final ByteBuf buffer = Unpooled.buffer(paramBytes.length); paramReg.serializeParameter(param, buffer); paramReg.parseParameter(0, Unpooled.wrappedBuffer(paramBytes)); - verify(this.activator.paramParser, times(1)).parseParameter(Mockito.any(ByteBuf.class)); - verify(this.activator.paramSerializer, times(1)).serializeParameter(Mockito.any(BgpParameters.class), Mockito.any(ByteBuf.class)); + verify(this.activator.paramParser, times(1)).parseParameter(any(ByteBuf.class)); + verify(this.activator.paramSerializer, times(1)).serializeParameter(any(BgpParameters.class), any(ByteBuf.class)); } @Test @@ -113,7 +115,7 @@ public class SimpleRegistryTest { 0x0, 0x00 }; capaRegistry.parseCapability(BgpTestActivator.TYPE, Unpooled.wrappedBuffer(capabilityBytes)); - verify(this.activator.capaParser, times(1)).parseCapability(Mockito.any(ByteBuf.class)); + verify(this.activator.capaParser, times(1)).parseCapability(any(ByteBuf.class)); } @Test @@ -128,10 +130,10 @@ public class SimpleRegistryTest { final ByteBuf buffer = Unpooled.buffer(tlvBytes.length); sidTlvReg.serializeBgpPrefixSidTlv(tlv, buffer); - verify(this.activator.sidTlvSerializer, times(1)).serializeBgpPrefixSidTlv(Mockito.any(BgpPrefixSidTlv.class), Mockito.any(ByteBuf.class)); + verify(this.activator.sidTlvSerializer, times(1)).serializeBgpPrefixSidTlv(any(BgpPrefixSidTlv.class), any(ByteBuf.class)); sidTlvReg.parseBgpPrefixSidTlv(BgpTestActivator.TYPE, Unpooled.wrappedBuffer(tlvBytes)); - verify(this.activator.sidTlvParser, times(1)).parseBgpPrefixSidTlv(Mockito.any(ByteBuf.class)); + verify(this.activator.sidTlvParser, times(1)).parseBgpPrefixSidTlv(any(ByteBuf.class)); } @Test @@ -151,9 +153,9 @@ public class SimpleRegistryTest { final ByteBuf buffer = Unpooled.buffer(msgBytes.length); msgRegistry.serializeMessage(msg, buffer); msgRegistry.parseMessage(Unpooled.wrappedBuffer(msgBytes), CONSTRAINT); - verify(this.activator.msgParser, times(1)).parseMessageBody(Mockito.any(ByteBuf.class), Mockito.anyInt(), - Mockito.any(PeerSpecificParserConstraint.class)); - verify(this.activator.msgSerializer, times(1)).serializeMessage(Mockito.any(Notification.class), Mockito.any(ByteBuf.class)); + verify(this.activator.msgParser, times(1)).parseMessageBody(any(ByteBuf.class), Mockito.anyInt(), + any(PeerSpecificParserConstraint.class)); + verify(this.activator.msgSerializer, times(1)).serializeMessage(any(Notification.class), any(ByteBuf.class)); } @Test @@ -185,7 +187,7 @@ public class SimpleRegistryTest { nlriReg.serializeMpReach(mpReach, buffer); assertArrayEquals(mpReachBytes, buffer.array()); assertEquals(mpReach, nlriReg.parseMpReach(Unpooled.wrappedBuffer(mpReachBytes), CONSTRAINT)); - verify(this.activator.nlriParser, times(1)).parseNlri(Mockito.any(ByteBuf.class), Mockito.any(MpReachNlriBuilder.class), Mockito.any()); + verify(this.activator.nlriParser, times(1)).parseNlri(any(ByteBuf.class), any(MpReachNlriBuilder.class), any()); } @Test @@ -231,6 +233,6 @@ public class SimpleRegistryTest { nlriReg.serializeMpUnReach(mpUnreach, buffer); assertArrayEquals(mpUnreachBytes, buffer.array()); assertEquals(mpUnreach, nlriReg.parseMpUnreach(Unpooled.wrappedBuffer(mpUnreachBytes), CONSTRAINT)); - verify(this.activator.nlriParser, times(1)).parseNlri(Mockito.any(ByteBuf.class), Mockito.any(MpUnreachNlriBuilder.class), Mockito.any()); + verify(this.activator.nlriParser, times(1)).parseNlri(any(ByteBuf.class), any(MpUnreachNlriBuilder.class), any()); } } diff --git a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupport.java b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupport.java index 6b141b3fce..b7b2002af0 100644 --- a/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupport.java +++ b/bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/AbstractRIBSupport.java @@ -97,8 +97,8 @@ public abstract class AbstractRIBSupport< private final LoadingCache routesPath = CacheBuilder.newBuilder() .weakValues().build(new CacheLoader() { @Override - public YangInstanceIdentifier load(@Nonnull final YangInstanceIdentifier routesPath) { - return routesPath.node(routesContainerIdentifier()).node(routeQName()); + public YangInstanceIdentifier load(@Nonnull final YangInstanceIdentifier routesTablePaths) { + return routesTablePaths.node(routesContainerIdentifier()).node(routeQName()); } }); private final NodeIdentifier routesContainerIdentifier; @@ -377,8 +377,9 @@ public abstract class AbstractRIBSupport< } @Override - public final YangInstanceIdentifier routePath(final YangInstanceIdentifier routesPath, final PathArgument routeId) { - return routesPath.node(this.routesContainerIdentifier).node(routeNid()).node(routeId); + public final YangInstanceIdentifier routePath( + final YangInstanceIdentifier routesTablePaths, final PathArgument routeId) { + return routesYangInstanceIdentifier(routesTablePaths).node(routeId); } @Override @@ -508,7 +509,7 @@ public abstract class AbstractRIBSupport< return null; } - protected YangInstanceIdentifier routesYangInstanceIdentifier(final YangInstanceIdentifier routesPath) { - return this.routesPath.getUnchecked(routesPath); + protected YangInstanceIdentifier routesYangInstanceIdentifier(final YangInstanceIdentifier routesTablePaths) { + return this.routesPath.getUnchecked(routesTablePaths); } } -- 2.36.6