Move route target ext comm container 42/73142/10
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 20 Jun 2018 06:12:09 +0000 (08:12 +0200)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Wed, 20 Jun 2018 08:18:08 +0000 (10:18 +0200)
outside extendend communities cases.
 Allowing to reuse the models.

Change-Id: I9faab101f4b5ed0613fe26646be9da2fad58b942
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
17 files changed:
.gitignore
bgp/concepts/src/main/yang/bgp-types.yang
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/BGPActivator.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/As4RouteTargetExtendedHandler.java [new file with mode: 0644]
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTarget4OctectASEcHandler.java [moved from bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/four/octect/as/specific/RouteTarget4OctectASEcHandler.java with 64% similarity]
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetAsTwoOctetEcHandler.java [moved from bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/RouteTargetAsTwoOctetEcHandler.java with 58% similarity]
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetExtendedCommunityHandler.java [new file with mode: 0644]
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetIpv4EcHandler.java [moved from bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/RouteTargetIpv4EcHandler.java with 68% similarity]
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetIpv4Handler.java [new file with mode: 0644]
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/BGPParserTest.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/RouteOrigin4OctectASEcHandlerTest.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTarget4OctectASEcHandlerTest.java [moved from bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/RouteTarget4OctectASEcHandlerTest.java with 77% similarity]
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetAsTwoOctetEcHandlerTest.java [moved from bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/RouteTargetAsTwoOctetEcHandlerTest.java with 81% similarity]
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetIpv4EcHandlerTest.java [moved from bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/RouteTargetIpv4EcHandlerTest.java with 87% similarity]
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/extended/community/AbstractTwoOctetAsExtendedCommunity.java
bgp/parser-spi/src/test/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleExtendedCommunityRegistryTest.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/CommunitiesBuilder.java

index 0503148284ed583c04cdd20f94d43e8578c5f1bb..ae682d548745edf31d136122e67d4f2305a022b4 100644 (file)
@@ -36,3 +36,4 @@ maven-eclipse.xml
 .checkstyle
 .factorypath
 .fbExcludeFilterFile
+!**/route/target
index 24d202fefe521f4164d295d12244f725c35e7589..b19b1ded0e9a1903b267ace001f52c412be5b902 100644 (file)
@@ -301,6 +301,38 @@ module bgp-types {
         }
     }
 
+    grouping route-target-extended-community-grouping {
+        container route-target-extended-community {
+            description "Type 0x00 / Subtype 0x02";
+            reference "http://tools.ietf.org/html/rfc4360#section-4";
+
+            leaf global-administrator {
+                type short-as-number;
+            }
+            leaf local-administrator {
+                type binary {
+                    length "4";
+                }
+            }
+        }
+    }
+
+    grouping route-target-ipv4-grouping {
+        container route-target-ipv4 {
+            description "Type 0x01 / Subtype 0x02";
+            reference "http://tools.ietf.org/html/rfc4360#section-4";
+            uses route-ipv4-extended-community;
+        }
+    }
+
+    grouping as-4-route-target-extended-community-grouping {
+        container as-4-route-target-extended-community {
+            description "Type 0x02 / Subtype 0x02";
+            reference "https://tools.ietf.org/html/rfc5668";
+            uses as-4-spec-common;
+        }
+    }
+
     grouping extended-community {
         leaf transitive {
             type boolean;
@@ -343,16 +375,13 @@ module bgp-types {
                 }
             }
             case route-target-extended-community-case {
-                container route-target-extended-community {
-                    leaf global-administrator {
-                        type short-as-number;
-                    }
-                    leaf local-administrator {
-                        type binary {
-                            length "4";
-                        }
-                    }
-                }
+                uses route-target-extended-community-grouping;
+            }
+            case route-target-ipv4-case {
+                uses route-target-ipv4-grouping;
+            }
+            case as-4-route-target-extended-community-case {
+                uses as-4-route-target-extended-community-grouping;
             }
             case route-origin-extended-community-case {
                 container route-origin-extended-community {
@@ -366,12 +395,6 @@ module bgp-types {
                     }
                 }
             }
-            case route-target-ipv4-case {
-                container route-target-ipv4 {
-                    reference "http://tools.ietf.org/html/rfc4360#section-4";
-                    uses route-ipv4-extended-community;
-                }
-            }
             case route-origin-ipv4-case {
                 container route-origin-ipv4 {
                     reference "http://tools.ietf.org/html/rfc4360#section-5";
@@ -389,12 +412,6 @@ module bgp-types {
                     uses as-4-spec-common;
                 }
             }
-            case as-4-route-target-extended-community-case {
-                container as-4-route-target-extended-community {
-                    reference "https://tools.ietf.org/html/rfc5668";
-                    uses as-4-spec-common;
-                }
-            }
             case as-4-route-origin-extended-community-case {
                 container as-4-route-origin-extended-community {
                     reference "https://tools.ietf.org/html/rfc5668";
index d8215627c27330fe668c7a14e0e4c6216f3cdddb..a7c7114efc50068243ea44ee95d5606423a8c853 100755 (executable)
@@ -46,14 +46,14 @@ import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communi
 import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.OpaqueEcHandler;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.RouteOriginAsTwoOctetEcHandler;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.RouteOriginIpv4EcHandler;
-import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.RouteTargetAsTwoOctetEcHandler;
-import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.RouteTargetIpv4EcHandler;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.four.octect.as.specific.SourceAS4OctectHandler;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.SourceASHandler;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.VrfRouteImportHandler;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.four.octect.as.specific.Generic4OctASEcHandler;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.four.octect.as.specific.RouteOrigin4OctectASEcHandler;
-import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.four.octect.as.specific.RouteTarget4OctectASEcHandler;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target.RouteTarget4OctectASEcHandler;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target.RouteTargetAsTwoOctetEcHandler;
+import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target.RouteTargetIpv4EcHandler;
 import org.opendaylight.protocol.bgp.parser.spi.AbstractBGPExtensionProviderActivator;
 import org.opendaylight.protocol.bgp.parser.spi.AddressFamilyRegistry;
 import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/As4RouteTargetExtendedHandler.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/As4RouteTargetExtendedHandler.java
new file mode 100644 (file)
index 0000000..75a9069
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.bgp.parser.spi.extended.community.FourOctAsCommonECUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.as._4.route.target.extended.community.grouping.As4RouteTargetExtendedCommunity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.as._4.route.target.extended.community.grouping.As4RouteTargetExtendedCommunityBuilder;
+
+/**
+ * Route Target 4 Octet As Handler.
+ *
+ * @author Claudio D. Gasparini
+ */
+public final class As4RouteTargetExtendedHandler {
+    private As4RouteTargetExtendedHandler() {
+        throw new UnsupportedOperationException();
+    }
+
+    public static As4RouteTargetExtendedCommunity parse(final ByteBuf body) {
+        return new As4RouteTargetExtendedCommunityBuilder()
+                .setAs4SpecificCommon(FourOctAsCommonECUtil.parseCommon(body)).build();
+    }
+
+    public static void serialize(final As4RouteTargetExtendedCommunity as4RouteTargetExtendedCommunity,
+            final ByteBuf body) {
+        FourOctAsCommonECUtil.serializeCommon(as4RouteTargetExtendedCommunity.getAs4SpecificCommon(), body);
+    }
+}
\ No newline at end of file
@@ -6,34 +6,34 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.four.octect.as.specific;
+package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
 
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.Abstract4OctetAsExtendedCommunity;
-import org.opendaylight.protocol.bgp.parser.spi.extended.community.FourOctAsCommonECUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.As4RouteTargetExtendedCommunityCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.As4RouteTargetExtendedCommunityCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.as._4.route.target.extended.community._case.As4RouteTargetExtendedCommunityBuilder;
 
 public final class RouteTarget4OctectASEcHandler extends Abstract4OctetAsExtendedCommunity {
     private static final int SUBTYPE = 2;
 
     @Override
-    public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) throws BGPDocumentedException, BGPParsingException {
-        return new As4RouteTargetExtendedCommunityCaseBuilder().setAs4RouteTargetExtendedCommunity(new As4RouteTargetExtendedCommunityBuilder()
-            .setAs4SpecificCommon(FourOctAsCommonECUtil.parseCommon(body)).build()).build();
+    public ExtendedCommunity parseExtendedCommunity(final ByteBuf body)
+            throws BGPDocumentedException, BGPParsingException {
+        return new As4RouteTargetExtendedCommunityCaseBuilder()
+                .setAs4RouteTargetExtendedCommunity(As4RouteTargetExtendedHandler.parse(body)).build();
     }
 
     @Override
     public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
         Preconditions.checkArgument(extendedCommunity instanceof As4RouteTargetExtendedCommunityCase,
-            "The extended community %s is not As4RouteTargetExtendedCommunityCase type.", extendedCommunity);
-        FourOctAsCommonECUtil.serializeCommon(((As4RouteTargetExtendedCommunityCase) extendedCommunity).getAs4RouteTargetExtendedCommunity()
-            .getAs4SpecificCommon(), body);
+                "The extended community %s is not As4RouteTargetExtendedCommunityCase type.",
+                extendedCommunity);
+        As4RouteTargetExtendedHandler.serialize(((As4RouteTargetExtendedCommunityCase) extendedCommunity)
+                .getAs4RouteTargetExtendedCommunity(), body);
     }
 
     @Override
@@ -6,43 +6,37 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities;
+package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
 
 import com.google.common.base.Preconditions;
-import com.google.common.primitives.Ints;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractTwoOctetAsExtendedCommunity;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ShortAsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetExtendedCommunityCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetExtendedCommunityCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.target.extended.community._case.RouteTargetExtendedCommunity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.target.extended.community._case.RouteTargetExtendedCommunityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.extended.community.grouping.RouteTargetExtendedCommunity;
 
 public final class RouteTargetAsTwoOctetEcHandler extends AbstractTwoOctetAsExtendedCommunity {
 
     private static final int SUBTYPE = 2;
 
     @Override
-    public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
-        final RouteTargetExtendedCommunity targetTarget = new RouteTargetExtendedCommunityBuilder()
-            .setGlobalAdministrator(new ShortAsNumber((long) buffer.readUnsignedShort()))
-            .setLocalAdministrator(ByteArray.readBytes(buffer, AS_LOCAL_ADMIN_LENGTH))
-            .build();
-        return new RouteTargetExtendedCommunityCaseBuilder().setRouteTargetExtendedCommunity(targetTarget).build();
+    public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
+            throws BGPDocumentedException, BGPParsingException {
+        return new RouteTargetExtendedCommunityCaseBuilder().setRouteTargetExtendedCommunity(
+                RouteTargetExtendedCommunityHandler.parse(buffer)).build();
     }
 
     @Override
     public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
         Preconditions.checkArgument(extendedCommunity instanceof RouteTargetExtendedCommunityCase,
-                "The extended community %s is not RouteTargetExtendedCommunityCase type.", extendedCommunity);
-        final RouteTargetExtendedCommunity routeTarget = ((RouteTargetExtendedCommunityCase) extendedCommunity).getRouteTargetExtendedCommunity();
-        ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(routeTarget.getGlobalAdministrator().getValue()), byteAggregator);
-        byteAggregator.writeBytes(routeTarget.getLocalAdministrator());
+                "The extended community %s is not RouteTargetExtendedCommunityCase type.",
+                extendedCommunity);
+        final RouteTargetExtendedCommunity routeTarget = ((RouteTargetExtendedCommunityCase) extendedCommunity)
+                .getRouteTargetExtendedCommunity();
+        RouteTargetExtendedCommunityHandler.serialize(routeTarget, byteAggregator);
     }
 
     @Override
diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetExtendedCommunityHandler.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetExtendedCommunityHandler.java
new file mode 100644 (file)
index 0000000..a1b80e0
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
+
+import static org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractTwoOctetAsExtendedCommunity.AS_LOCAL_ADMIN_LENGTH;
+
+import com.google.common.primitives.Ints;
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufWriteUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ShortAsNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.extended.community.grouping.RouteTargetExtendedCommunity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.extended.community.grouping.RouteTargetExtendedCommunityBuilder;
+
+/**
+ * Route Target Extended Community Parser / Serializer.
+ *
+ * @author Claudio D. Gasparini
+ */
+public final class RouteTargetExtendedCommunityHandler {
+    private RouteTargetExtendedCommunityHandler() {
+        throw new UnsupportedOperationException();
+    }
+
+    public static RouteTargetExtendedCommunity parse(final ByteBuf buffer) {
+        return new RouteTargetExtendedCommunityBuilder()
+                .setGlobalAdministrator(new ShortAsNumber((long) buffer.readUnsignedShort()))
+                .setLocalAdministrator(ByteArray.readBytes(buffer, AS_LOCAL_ADMIN_LENGTH))
+                .build();
+    }
+
+    public static void serialize(final RouteTargetExtendedCommunity routeTarget, final ByteBuf byteAggregator) {
+        ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(routeTarget.getGlobalAdministrator().getValue()),
+                byteAggregator);
+        byteAggregator.writeBytes(routeTarget.getLocalAdministrator());
+    }
+}
@@ -6,20 +6,17 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities;
+package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
 
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractIpv4ExtendedCommunity;
-import org.opendaylight.protocol.util.ByteBufWriteUtil;
-import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetIpv4Case;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetIpv4CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.target.ipv4._case.RouteTargetIpv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.target.ipv4._case.RouteTargetIpv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4;
 
 public final class RouteTargetIpv4EcHandler extends AbstractIpv4ExtendedCommunity {
 
@@ -30,17 +27,13 @@ public final class RouteTargetIpv4EcHandler extends AbstractIpv4ExtendedCommunit
         Preconditions.checkArgument(extendedCommunity instanceof RouteTargetIpv4Case,
                 "The extended community %s is not RouteTargetAsTwoOctetCase type.", extendedCommunity);
         final RouteTargetIpv4 routeTarget = ((RouteTargetIpv4Case) extendedCommunity).getRouteTargetIpv4();
-        ByteBufWriteUtil.writeIpv4Address(routeTarget.getGlobalAdministrator(), byteAggregator);
-        ByteBufWriteUtil.writeUnsignedShort(routeTarget.getLocalAdministrator(), byteAggregator);
+        RouteTargetIpv4Handler.serialize(routeTarget, byteAggregator);
     }
 
     @Override
-    public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
-        final RouteTargetIpv4 routeTarget = new RouteTargetIpv4Builder()
-            .setGlobalAdministrator(Ipv4Util.addressForByteBuf(buffer))
-            .setLocalAdministrator(buffer.readUnsignedShort())
-            .build();
-        return new RouteTargetIpv4CaseBuilder().setRouteTargetIpv4(routeTarget).build();
+    public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
+            throws BGPDocumentedException, BGPParsingException {
+        return new RouteTargetIpv4CaseBuilder().setRouteTargetIpv4(RouteTargetIpv4Handler.parse(buffer)).build();
     }
 
     @Override
diff --git a/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetIpv4Handler.java b/bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetIpv4Handler.java
new file mode 100644 (file)
index 0000000..90d99f8
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.util.ByteBufWriteUtil;
+import org.opendaylight.protocol.util.Ipv4Util;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4Builder;
+
+/**
+ * Route Target Ipv4 Handler.
+ *
+ * @author Claudio D. Gasparini
+ */
+public final class RouteTargetIpv4Handler {
+    private RouteTargetIpv4Handler() {
+        throw new UnsupportedOperationException();
+    }
+
+    public static void serialize(final RouteTargetIpv4 routeTarget, final ByteBuf byteAggregator) {
+        ByteBufWriteUtil.writeIpv4Address(routeTarget.getGlobalAdministrator(), byteAggregator);
+        ByteBufWriteUtil.writeUnsignedShort(routeTarget.getLocalAdministrator(), byteAggregator);
+    }
+
+    public static RouteTargetIpv4 parse(final ByteBuf buffer) {
+        return new RouteTargetIpv4Builder()
+                .setGlobalAdministrator(Ipv4Util.addressForByteBuf(buffer))
+                .setLocalAdministrator(buffer.readUnsignedShort())
+                .build();
+    }
+}
index d1534f4a06fb2143996cdc18688fbfa5e7a51060..1a283944099934dddea852fa2167821d281973c6 100644 (file)
@@ -66,10 +66,10 @@ 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.SubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetIpv4CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.target.ipv4._case.RouteTargetIpv4Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCase;
 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.ipv4.next.hop._case.Ipv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4Builder;
 
 public class BGPParserTest {
 
@@ -408,7 +408,8 @@ public class BGPParserTest {
         comms.add(new ExtendedCommunitiesBuilder().setTransitive(true).setExtendedCommunity(
                 new RouteTargetIpv4CaseBuilder().setRouteTargetIpv4(
                         new RouteTargetIpv4Builder().setGlobalAdministrator(
-                                new Ipv4Address("192.168.1.0")).setLocalAdministrator(4660).build()).build()).build());
+                                new Ipv4Address("192.168.1.0")).setLocalAdministrator(4660)
+                                .build()).build()).build());
 
         // check path attributes
         final Attributes attrs = message.getAttributes();
index 16483c0543a1e41205431d03382098067991db55..f2bc880a3999fe60b6d40c3fa20bd94dbecf22f2 100644 (file)
@@ -27,10 +27,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 
 public final class RouteOrigin4OctectASEcHandlerTest {
 
-    static final byte[] INPUT = {
+    public static final byte[] INPUT = {
         0, 0, 0, 20, 0, 100
     };
-    static final As4SpecificCommon AS_COMMON = new As4SpecificCommonBuilder().setAsNumber(new AsNumber(20L))
+    public static final As4SpecificCommon AS_COMMON = new As4SpecificCommonBuilder().setAsNumber(new AsNumber(20L))
         .setLocalAdministrator(100).build();
     RouteOrigin4OctectASEcHandler handler;
 
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities;
+package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
 
 import static org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.RouteOrigin4OctectASEcHandlerTest.AS_COMMON;
 import static org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.RouteOrigin4OctectASEcHandlerTest.INPUT;
@@ -14,30 +14,23 @@ import static org.opendaylight.protocol.bgp.parser.impl.message.update.extended.
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
-import org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.four.octect.as.specific.RouteTarget4OctectASEcHandler;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.as._4.route.target.extended.community.grouping.As4RouteTargetExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.As4RouteOriginExtendedCommunityCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.As4RouteTargetExtendedCommunityCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.As4RouteTargetExtendedCommunityCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.as._4.route.target.extended.community._case.As4RouteTargetExtendedCommunityBuilder;
 
 public class RouteTarget4OctectASEcHandlerTest {
-    RouteTarget4OctectASEcHandler handler;
-
-    @Before
-    public void Setup() {
-        this.handler = new RouteTarget4OctectASEcHandler();
-    }
+    private final RouteTarget4OctectASEcHandler handler = new RouteTarget4OctectASEcHandler();
 
     @Test
     public void testHandler() throws BGPDocumentedException, BGPParsingException {
         final As4RouteTargetExtendedCommunityCase expected = new As4RouteTargetExtendedCommunityCaseBuilder()
-            .setAs4RouteTargetExtendedCommunity(new As4RouteTargetExtendedCommunityBuilder()
-                .setAs4SpecificCommon(AS_COMMON).build()).build();
+                .setAs4RouteTargetExtendedCommunity(new As4RouteTargetExtendedCommunityBuilder()
+                        .setAs4SpecificCommon(AS_COMMON).build()).build();
 
         final ExtendedCommunity exComm = this.handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
         Assert.assertEquals(expected, exComm);
@@ -47,7 +40,7 @@ public class RouteTarget4OctectASEcHandlerTest {
         Assert.assertArrayEquals(INPUT, output.array());
     }
 
-    @Test(expected=IllegalArgumentException.class)
+    @Test(expected = IllegalArgumentException.class)
     public void testHandlerError() throws BGPDocumentedException, BGPParsingException {
         this.handler.serializeExtendedCommunity(new As4RouteOriginExtendedCommunityCaseBuilder().build(), null);
     }
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities;
+package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -18,7 +18,7 @@ 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.extended.community.ExtendedCommunity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetExtendedCommunityCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetExtendedCommunityCaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.target.extended.community._case.RouteTargetExtendedCommunityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.extended.community.grouping.RouteTargetExtendedCommunityBuilder;
 
 public class RouteTargetAsTwoOctetEcHandlerTest {
 
@@ -29,9 +29,11 @@ public class RouteTargetAsTwoOctetEcHandlerTest {
     @Test
     public void testHandler() throws BGPDocumentedException, BGPParsingException {
         final RouteTargetAsTwoOctetEcHandler handler = new RouteTargetAsTwoOctetEcHandler();
-        final RouteTargetExtendedCommunityCase expected = new RouteTargetExtendedCommunityCaseBuilder().setRouteTargetExtendedCommunity(
-                new RouteTargetExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(35L)).setLocalAdministrator(
-                        new byte[] { 4, 2, 8, 7 }).build()).build();
+        final RouteTargetExtendedCommunityCase expected = new RouteTargetExtendedCommunityCaseBuilder()
+                .setRouteTargetExtendedCommunity(new RouteTargetExtendedCommunityBuilder()
+                        .setGlobalAdministrator(new ShortAsNumber(35L))
+                        .setLocalAdministrator(new byte[]{4, 2, 8, 7})
+                        .build()).build();
 
         final ExtendedCommunity exComm = handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
         Assert.assertEquals(expected, exComm);
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities;
+package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
@@ -18,7 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetIpv4Case;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetIpv4CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.target.ipv4._case.RouteTargetIpv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4Builder;
 
 public class RouteTargetIpv4EcHandlerTest {
 
@@ -31,9 +31,9 @@ public class RouteTargetIpv4EcHandlerTest {
         final RouteTargetIpv4EcHandler handler = new RouteTargetIpv4EcHandler();
         final RouteTargetIpv4Case expected = new RouteTargetIpv4CaseBuilder().setRouteTargetIpv4(
                 new RouteTargetIpv4Builder()
-                    .setGlobalAdministrator(new Ipv4Address("12.51.2.5"))
-                    .setLocalAdministrator(5421)
-                    .build()).build();
+                        .setGlobalAdministrator(new Ipv4Address("12.51.2.5"))
+                        .setLocalAdministrator(5421)
+                        .build()).build();
 
         final ExtendedCommunity exComm = handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT));
         Assert.assertEquals(expected, exComm);
index bc8acfd3f6d00253841e55206ee8ab9acbe032de..a7757b736f7977b4af44db996d654ab403f7513f 100644 (file)
@@ -13,7 +13,7 @@ public abstract class AbstractTwoOctetAsExtendedCommunity implements ExtendedCom
 
     private static final int TYPE = 0;
 
-    protected static final int AS_LOCAL_ADMIN_LENGTH = 4;
+    public static final int AS_LOCAL_ADMIN_LENGTH = 4;
 
     @Override
     public final int getType(final boolean isTransitive) {
index 7c80fa66353939009afe1cf3e9b3df16845886aa..04a90a15fdc943a6a48d37196ac11ea94520e30c 100644 (file)
@@ -8,12 +8,20 @@
 
 package org.opendaylight.protocol.bgp.parser.spi.pojo;
 
+import static org.junit.Assert.assertNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.Mockito;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunityParser;
@@ -24,24 +32,24 @@ 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.extended.community.extended.community.RouteOriginIpv4CaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetIpv4Case;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.RouteTargetIpv4CaseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.target.ipv4._case.RouteTargetIpv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4Builder;
 
 public class SimpleExtendedCommunityRegistryTest {
 
     private SimpleExtendedCommunityRegistry register;
 
-    private final ExtendedCommunityParser parser = Mockito.mock(ExtendedCommunityParser.class);
-    private final ExtendedCommunitySerializer serializer = Mockito.mock(ExtendedCommunitySerializer.class);
+    private final ExtendedCommunityParser parser = mock(ExtendedCommunityParser.class);
+    private final ExtendedCommunitySerializer serializer = mock(ExtendedCommunitySerializer.class);
 
     @Before
     public void setup() throws BGPDocumentedException, BGPParsingException {
         this.register = new SimpleExtendedCommunityRegistry();
         this.register.registerExtendedCommunityParser(0, 0, this.parser);
         this.register.registerExtendedCommunitySerializer(RouteTargetIpv4Case.class, this.serializer);
-        Mockito.doReturn(0).when(this.serializer).getType(Mockito.anyBoolean());
-        Mockito.doReturn(0).when(this.serializer).getSubType();
-        Mockito.doNothing().when(this.serializer).serializeExtendedCommunity(Mockito.any(ExtendedCommunity.class), Mockito.any(ByteBuf.class));
-        Mockito.doReturn(null).when(this.parser).parseExtendedCommunity(Mockito.any(ByteBuf.class));
+        doReturn(0).when(this.serializer).getType(anyBoolean());
+        doReturn(0).when(this.serializer).getSubType();
+        doNothing().when(this.serializer).serializeExtendedCommunity(any(ExtendedCommunity.class), any(ByteBuf.class));
+        doReturn(null).when(this.parser).parseExtendedCommunity(any(ByteBuf.class));
 
     }
 
@@ -49,31 +57,37 @@ public class SimpleExtendedCommunityRegistryTest {
     public void testExtendedCommunityRegistry() throws BGPDocumentedException, BGPParsingException {
         final ByteBuf output = Unpooled.buffer();
         this.register.serializeExtendedCommunity(
-                new ExtendedCommunitiesBuilder().setTransitive(true).setExtendedCommunity(new RouteTargetIpv4CaseBuilder().setRouteTargetIpv4(new RouteTargetIpv4Builder().build()).build()).build(), output);
-        Mockito.verify(this.serializer).serializeExtendedCommunity(Mockito.any(ExtendedCommunity.class), Mockito.any(ByteBuf.class));
+                new ExtendedCommunitiesBuilder().setTransitive(true)
+                        .setExtendedCommunity(new RouteTargetIpv4CaseBuilder()
+                                .setRouteTargetIpv4(new RouteTargetIpv4Builder().build()).build()).build(), output);
+        verify(this.serializer).serializeExtendedCommunity(any(ExtendedCommunity.class), any(ByteBuf.class));
         //no value serialized, just header
         Assert.assertEquals(2, output.readableBytes());
 
-        final ExtendedCommunities parsedExtendedCommunity = this.register.parseExtendedCommunity(Unpooled.copiedBuffer(new byte[] {0, 0, 0, 0, 0, 0, 0, 0}));
-        Mockito.verify(this.parser).parseExtendedCommunity(Mockito.any(ByteBuf.class));
+        final ExtendedCommunities parsedExtendedCommunity =
+                this.register.parseExtendedCommunity(Unpooled.copiedBuffer(new byte[] {0, 0, 0, 0, 0, 0, 0, 0}));
+        verify(this.parser).parseExtendedCommunity(any(ByteBuf.class));
         Assert.assertTrue(parsedExtendedCommunity.isTransitive());
         //no value parser
-        Assert.assertNull(parsedExtendedCommunity.getExtendedCommunity());
+        assertNull(parsedExtendedCommunity.getExtendedCommunity());
     }
 
     @Test
     public void testExtendedCommunityRegistryUnknown() throws BGPDocumentedException, BGPParsingException {
         final ByteBuf output = Unpooled.buffer();
         this.register.serializeExtendedCommunity(
-                new ExtendedCommunitiesBuilder().setTransitive(false).setExtendedCommunity(new RouteOriginIpv4CaseBuilder().build()).build(), output);
+                new ExtendedCommunitiesBuilder().setTransitive(false)
+                        .setExtendedCommunity(new RouteOriginIpv4CaseBuilder().build()).build(), output);
         //no ex. community was serialized
         Assert.assertEquals(0, output.readableBytes());
-        Mockito.verify(this.serializer, Mockito.never()).serializeExtendedCommunity(Mockito.any(ExtendedCommunity.class), Mockito.any(ByteBuf.class));
+        verify(this.serializer, never())
+                .serializeExtendedCommunity(any(ExtendedCommunity.class), any(ByteBuf.class));
 
-        final ExtendedCommunities noExtCommunity = this.register.parseExtendedCommunity(Unpooled.copiedBuffer(new byte[] {0, 1, 0, 0, 0, 0, 0, 0}));
+        final ExtendedCommunities noExtCommunity = this.register
+                .parseExtendedCommunity(Unpooled.copiedBuffer(new byte[] {0, 1, 0, 0, 0, 0, 0, 0}));
         //no ext. community was parsed
-        Assert.assertNull(noExtCommunity);
-        Mockito.verify(this.parser, Mockito.never()).parseExtendedCommunity(Mockito.any(ByteBuf.class));
+        assertNull(noExtCommunity);
+        verify(this.parser, never()).parseExtendedCommunity(any(ByteBuf.class));
     }
 
     @Test(expected=IllegalArgumentException.class)
index 4b51030bf3ef7155c5b7831c23a2d9380f84ee70..18565c7b8c8f9faf11fc1e9de36ab33893030843 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.ExtendedCommunities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.ExtendedCommunitiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ShortAsNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.as._4.route.target.extended.community.grouping.As4RouteTargetExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.as._4.spec.common.As4SpecificCommon;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.as._4.spec.common.As4SpecificCommonBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
@@ -31,15 +32,14 @@ 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.extended.community.extended.community.RouteTargetIpv4CaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.as._4.generic.spec.extended.community._case.As4GenericSpecExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.as._4.route.origin.extended.community._case.As4RouteOriginExtendedCommunityBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.as._4.route.target.extended.community._case.As4RouteTargetExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.as.specific.extended.community._case.AsSpecificExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.inet4.specific.extended.community._case.Inet4SpecificExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.link.bandwidth._case.LinkBandwidthExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.opaque.extended.community._case.OpaqueExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.origin.extended.community._case.RouteOriginExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.origin.ipv4._case.RouteOriginIpv4Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.target.extended.community._case.RouteTargetExtendedCommunityBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.extended.community.route.target.ipv4._case.RouteTargetIpv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.extended.community.grouping.RouteTargetExtendedCommunityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
 import org.slf4j.Logger;