Fixup Augmentable and Identifiable methods changing
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / deserialization / multipart / MultipartReplyGroupDescDeserializer.java
index 9b01d3b01aac38b84d5c5d4b10febc1f2833a188..ab959bea9e37c37c2bfc3a2f30188030af3715d2 100644 (file)
@@ -20,16 +20,20 @@ import org.opendaylight.openflowplugin.impl.protocol.deserialization.util.Action
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 
-public class MultipartReplyGroupDescDeserializer implements OFDeserializer<MultipartReplyBody>, DeserializerRegistryInjector {
+public class MultipartReplyGroupDescDeserializer implements OFDeserializer<MultipartReplyBody>,
+        DeserializerRegistryInjector {
 
     private static final byte PADDING_IN_GROUP_DESC_HEADER = 1;
     private static final byte PADDING_IN_BUCKETS_HEADER = 4;
@@ -46,59 +50,60 @@ public class MultipartReplyGroupDescDeserializer implements OFDeserializer<Multi
             final int itemLength = message.readUnsignedShort();
 
             final GroupDescStatsBuilder itemBuilder = new GroupDescStatsBuilder()
-                .setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
+                    .setGroupType(GroupTypes.forValue(message.readUnsignedByte()));
 
             message.skipBytes(PADDING_IN_GROUP_DESC_HEADER);
             itemBuilder.setGroupId(new GroupId(message.readUnsignedInt()));
+            itemBuilder.withKey(new GroupDescStatsKey(itemBuilder.getGroupId()));
 
             final List<Bucket> subItems = new ArrayList<>();
             int actualLength = GROUP_DESC_HEADER_LENGTH;
 
+            long bucketKey = 0;
             while (actualLength < itemLength) {
                 final int bucketsLength = message.readUnsignedShort();
 
                 final BucketBuilder bucketBuilder = new BucketBuilder()
-                    .setWeight(message.readUnsignedShort())
-                    .setWatchPort(message.readUnsignedInt())
-                    .setWatchGroup(message.readUnsignedInt());
+                        .setBucketId(new BucketId(bucketKey))
+                        .withKey(new BucketKey(new BucketId(bucketKey)))
+                        .setWeight(message.readUnsignedShort())
+                        .setWatchPort(message.readUnsignedInt())
+                        .setWatchGroup(message.readUnsignedInt());
 
                 message.skipBytes(PADDING_IN_BUCKETS_HEADER);
-
-                if (message.readableBytes() > 0) {
-                    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list
+                final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list
                         .Action> actions = new ArrayList<>();
-                    final int startIndex = message.readerIndex();
-                    final int bucketLength = bucketsLength - BUCKETS_HEADER_LENGTH;
-                    int offset = 0;
-
-                    while ((message.readerIndex() - startIndex) < bucketLength) {
-                        actions.add(new ActionBuilder()
-                                .setKey(new ActionKey(offset))
-                                .setOrder(offset)
-                                .setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry,
-                                        ActionPath.GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION))
-                                .build());
-
-                        offset++;
-                    }
-
-                    bucketBuilder.setAction(actions);
+                final int startIndex = message.readerIndex();
+                final int bucketLength = bucketsLength - BUCKETS_HEADER_LENGTH;
+                int offset = 0;
+
+                while (message.readerIndex() - startIndex < bucketLength) {
+                    actions.add(new ActionBuilder()
+                            .withKey(new ActionKey(offset))
+                            .setOrder(offset)
+                            .setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry,
+                                    ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION))
+                            .build());
+
+                    offset++;
                 }
 
+                bucketBuilder.setAction(actions);
                 subItems.add(bucketBuilder.build());
+                bucketKey++;
                 actualLength += bucketsLength;
             }
 
             items.add(itemBuilder
                     .setBuckets(new BucketsBuilder()
-                        .setBucket(subItems)
-                        .build())
+                            .setBucket(subItems)
+                            .build())
                     .build());
         }
 
         return builder
-            .setGroupDescStats(items)
-            .build();
+                .setGroupDescStats(items)
+                .build();
     }
 
     @Override