Bug 2756 - Instruction model update 39/16039/3
authorMichal Polkorab <michal.polkorab@pantheon.sk>
Wed, 4 Mar 2015 18:01:01 +0000 (19:01 +0100)
committerMichal Polkorab <michal.polkorab@pantheon.sk>
Tue, 24 Mar 2015 16:44:03 +0000 (17:44 +0100)
Change-Id: Id1fbcd55f44a7e60b24ed10d7852fa0a100cf6b5
Signed-off-by: Michal Polkorab <michal.polkorab@pantheon.sk>
30 files changed:
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ExperimenterInstructionSerializerKey.java
openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java
openflow-protocol-api/src/main/yang/openflow-augments.yang
openflow-protocol-api/src/main/yang/openflow-instruction.yang
openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java
openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/KeysTest.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java [deleted file]
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/FlowModInputMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java

index fb2365bf6122228c386d8ba2b3d163d1cbd35b2e..15ee03a04bc5994afe2de8b8a5f3b5573968bc5c 100644 (file)
@@ -8,12 +8,12 @@
 
 package org.opendaylight.openflowjava.protocol.api.keys;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase;
 
 /**
  * @author michal.polkorab
  */
-public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey<Experimenter>
+public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey<ExperimenterIdCase>
         implements ExperimenterSerializerKey {
 
     /**
@@ -21,7 +21,7 @@ public final class ExperimenterInstructionSerializerKey extends InstructionSeria
      * @param experimenterId experimenter / vendor ID
      */
     public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) {
-        super(msgVersion, Experimenter.class, experimenterId);
+        super(msgVersion, ExperimenterIdCase.class, experimenterId);
     }
 
 }
\ No newline at end of file
index 2b7df97c23cdcb825da1a73c48831bf43c0ed25c..6f9a299b00be47084e820c4c64cd38049cba426c 100644 (file)
@@ -8,14 +8,14 @@
 
 package org.opendaylight.openflowjava.protocol.api.keys;
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
 
 /**
  * @author michal.polkorab
  * @param <T> instruction type
  */
-public class InstructionSerializerKey<T extends InstructionBase>
+public class InstructionSerializerKey<T extends InstructionChoice>
         extends MessageTypeKey<Instruction>{
 
     private Class<T> instructionType;
index 292bd96113008b193a9e23afdeff88d2f281dbe2..34ca8c43e3864fe1d2a492eb5048cf8ba9492a09 100644 (file)
      }
 
 // OFP_INSTRUCTION AUGMENTS
-     augment "/ofinstruction:instruction-container/ofinstruction:instruction" {
-         ext:augment-identifier "table-id-instruction";
-         leaf table-id {
-             type uint8;
-         }
-     }
-     augment "/ofinstruction:instruction-container/ofinstruction:instruction" {
-         ext:augment-identifier "metadata-instruction";
-         leaf metadata {
-             type binary;
-         }
-         leaf metadata-mask {
-             type binary;
-         }
-     }
-     augment "/ofinstruction:instruction-container/ofinstruction:instruction" {
-         ext:augment-identifier "actions-instruction";
-         uses ofaction:actions-grouping;
-     }
-     augment "/ofinstruction:instruction-container/ofinstruction:instruction" {
-         ext:augment-identifier "meter-id-instruction";
-         leaf meter-id {
-             type uint32;
-         }
-     }
-     augment "/ofinstruction:instruction-container/ofinstruction:instruction" {
-         ext:augment-identifier "experimenter-id-instruction";
-         leaf experimenter {
-             type oft:experimenter-id;
+     augment "/ofinstruction:instruction-container/ofinstruction:instruction-choice" {
+         case experimenter-id-case {
+             container experimenter {
+                 leaf experimenter-id {
+                     type oft:experimenter-id;
+                 }
+             }
          }
      }
 
index 671556e104bc83a4e2503d31a2e4c3f62391049f..293e3803cdab7f5b5ed46aa8e2e5933649429b4d 100644 (file)
     prefix "ofinstruction";
 
     import openflow-types { prefix oft; }
+    import openflow-action {prefix ofaction;}
 
     revision "2013-07-31" {
         description "OpenFlow 1.3 - instruction model";
     }
 
-    identity goto_table {
-        description " Setup the next table in the lookup pipeline";
-        base oft:instruction-base;
-    }
-    identity write_metadata {
-        description " Setup the metadata field for use later in     pipeline";
-        base oft:instruction-base;
-    }
-    identity write_actions {
-        description " Write the action(s) onto the datapath action set";
-        base oft:instruction-base;
-    }
-    identity apply_actions {
-        description " Applies the action(s) immediately";
-        base oft:instruction-base;
-    }
-    identity clear_actions {
-        description " Clears all actions from the datapath action set";
-        base oft:instruction-base;
-    }
-    identity meter {
-        description " Apply meter (rate limiter)";
-        base oft:instruction-base;
-    }
-    identity experimenter {
-        description "Experimenter instruction";
-        base oft:instruction-base;
-    }
-
     container instruction-container {
-        uses instructions-grouping;
+        uses instruction-grouping;
     }
 
     grouping instructions-grouping {
         list instruction {
             config false;
-            leaf type {
-                type identityref {
-                    base oft:instruction-base;
+            uses instruction-grouping;
+        }
+    }
+
+    grouping instruction-grouping {
+        choice instruction-choice {
+            case goto-table-case {
+                container goto-table {
+                    leaf table-id {
+                        type uint8;
+                    }
+                }
+            }
+            case write-metadata-case {
+                container write-metadata {
+                    leaf metadata {
+                        type binary;
+                    }
+                    leaf metadata-mask {
+                        type binary;
+                    }
+                }
+            }
+            case write-actions-case {
+                container write-actions {
+                    uses ofaction:actions-grouping;
+                }
+            }
+            case apply-actions-case {
+                container apply-actions {
+                    uses ofaction:actions-grouping;
+                }
+            }
+            case clear-actions-case {
+                // empty instruction
+            }
+            case meter-case {
+                container meter {
+                    leaf meter-id {
+                        type uint32;
+                    }
                 }
             }
         }
     }
-
 }
\ No newline at end of file
index a51a2d70e7150a32eaa890c61fdbdc6e9927f2fb..17ecf58222b0e37163a28e0cee7bbdb66a219c57 100644 (file)
@@ -11,8 +11,8 @@ package org.opendaylight.openflowjava.protocol.api.keys;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
 
 /**
  * @author michal.polkorab
@@ -26,24 +26,24 @@ public class InstructionSerializerKeyTest {
     @Test
     public void test() {
         InstructionSerializerKey<?> key1 =
-                new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+                new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L);
                 InstructionSerializerKey<?> key2 =
-                new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+                new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L);
         Assert.assertTrue("Wrong equals", key1.equals(key2));
         Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode());
-        key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null);
+        key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, null);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
         key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
-        key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L);
+        key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActionsCase.class, 42L);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
-        key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L);
+        key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 55L);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
-        key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L);
+        key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActionsCase.class, 42L);
         Assert.assertFalse("Wrong equals", key1.equals(key2));
         Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode());
     }
@@ -54,14 +54,14 @@ public class InstructionSerializerKeyTest {
     @Test
     public void testEquals(){
         InstructionSerializerKey<?> key1 =
-                new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+                new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L);
         InstructionSerializerKey<?> key2 =
-                new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+                new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L);
 
         Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1));
         Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object()));
 
-        key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null);
+        key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, null);
         Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2));
 
         key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L);
@@ -75,11 +75,11 @@ public class InstructionSerializerKeyTest {
     @Test
     public void testToString(){
         InstructionSerializerKey<?> key1 =
-                new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L);
+                new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActionsCase.class, 42L);
 
-        Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight"
-                + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction"
-                + " instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
-                + ".instruction.rev130731.ApplyActions vendorID: 42", key1.toString());
+        Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn"
+                + ".opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction "
+                + "instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction"
+                + ".rev130731.instruction.grouping.instruction.choice.ApplyActionsCase vendorID: 42", key1.toString());
     }
 }
\ No newline at end of file
index 09ecbda47ec49f73fd54040a58483fe9b9e8d53f..c23d4b3c6a63fb084f29209311755328ec8e023e 100644 (file)
@@ -53,10 +53,11 @@ public class KeysTest {
         Assert.assertFalse(actionSerializerKey.equals(experimenterActionSerializerKey));
         Assert.assertFalse(experimenterActionSerializerKey.equals(actionSerializerKey));
 
-        InstructionSerializerKey<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter> instructionSerializerKey = new InstructionSerializerKey<>(
-                EncodeConstants.OF13_VERSION_ID,
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter.class,
-                1L);
+        InstructionSerializerKey<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225
+        .instruction.container.instruction.choice.ExperimenterIdCase> instructionSerializerKey =
+                new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, org.opendaylight.yang.gen.v1.urn
+                        .opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice
+                        .ExperimenterIdCase.class, 1L);
         ExperimenterInstructionSerializerKey experimenterInstructionSerializerKey = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 1L);
         Assert.assertEquals(instructionSerializerKey, experimenterInstructionSerializerKey);
         Assert.assertEquals(instructionSerializerKey.hashCode(), experimenterInstructionSerializerKey.hashCode());
index 10ba7c2f442e98f7f2ebe85268c35c2a9e072230..2d17ed63eeeb71d5fa69803d00b4add1e082eca1 100644 (file)
@@ -14,46 +14,32 @@ import java.util.List;
 
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker;
 import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
 
 /**
  * @author michal.polkorab
  *
  */
-public abstract class AbstractActionInstructionDeserializer extends AbstractInstructionDeserializer
-        implements DeserializerRegistryInjector {
+public abstract class AbstractActionInstructionDeserializer implements OFDeserializer<Instruction>,
+        DeserializerRegistryInjector {
 
     private DeserializerRegistry registry;
 
-    @Override
-    public Instruction deserialize(ByteBuf input) {
-        InstructionBuilder builder = new InstructionBuilder();
-        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-        builder.setType(getType());
-        int instructionLength = input.readUnsignedShort();
-        input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
-        ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();
+    protected List<Action> deserializeActions(ByteBuf input, int instructionLength) {
         int length = instructionLength - InstructionConstants.STANDARD_INSTRUCTION_LENGTH;
         CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
         List<Action> actions = ListDeserializer.deserializeList(
                 EncodeConstants.OF13_VERSION_ID, length, input, keyMaker, getRegistry());
-        actionsBuilder.setAction(actions);
-        builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
-        return builder.build();
+        return actions;
     }
 
-    protected abstract Class<? extends InstructionBase> getType();
-
     protected DeserializerRegistry getRegistry() {
         return registry;
     }
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java
deleted file mode 100644 (file)
index 38a6645..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. 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.openflowjava.protocol.impl.deserialization.instruction;
-
-import io.netty.buffer.ByteBuf;
-
-import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
-import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
-
-/**
- * @author michal.polkorab
- *
- */
-public abstract class AbstractInstructionDeserializer implements OFDeserializer<Instruction>,
-        HeaderDeserializer<Instruction> {
-
-    @Override
-    public Instruction deserializeHeader(ByteBuf rawMessage) {
-        InstructionBuilder builder = processHeader(rawMessage);
-        rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-        return builder.build();
-    }
-
-    protected InstructionBuilder processHeader(ByteBuf input) {
-        InstructionBuilder builder = new InstructionBuilder();
-        int type = input.readUnsignedShort();
-        switch (type) {
-        case 1:
-            builder.setType(GotoTable.class);
-            break;
-        case 2:
-            builder.setType(WriteMetadata.class);
-            break;
-        case 3:
-            builder.setType(WriteActions.class);
-            break;
-        case 4:
-            builder.setType(ApplyActions.class);
-            break;
-        case 5:
-            builder.setType(ClearActions.class);
-            break;
-        case 6:
-            builder.setType(Meter.class);
-            break;
-        default:
-            throw new IllegalStateException("Unknown instruction type received, type: " + type);
-        }
-        return builder;
-    }
-}
index c55aaceac484a8c3373c484afec6572eb060e41a..ff5bffce92b7a4bdc8b1902dc70a233f1c446fae 100644 (file)
@@ -8,18 +8,43 @@
 
 package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 
 /**
  * @author michal.polkorab
  *
  */
-public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer {
+public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer
+        implements HeaderDeserializer<Instruction> {
+
+    @Override
+    public Instruction deserialize(ByteBuf input) {
+        InstructionBuilder builder = new InstructionBuilder();
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        int instructionLength = input.readUnsignedShort();
+        input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+        ApplyActionsCaseBuilder caseBuilder = new ApplyActionsCaseBuilder();
+        ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder();
+        actionsBuilder.setAction(deserializeActions(input, instructionLength));
+        caseBuilder.setApplyActions(actionsBuilder.build());
+        builder.setInstructionChoice(caseBuilder.build());
+        return builder.build();
+    }
 
     @Override
-    protected Class<? extends InstructionBase> getType() {
-        return ApplyActions.class;
+    public Instruction deserializeHeader(ByteBuf input) {
+        InstructionBuilder builder = new InstructionBuilder();
+        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        builder.setInstructionChoice(new ApplyActionsCaseBuilder().build());
+        return builder.build();
     }
 
 }
index b3c29c8d91d09af588d1cbbfab5a30f125232016..24fe5cfba769c82c0d0accbe117a346f09675f35 100644 (file)
@@ -10,14 +10,11 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
 
 import io.netty.buffer.ByteBuf;
 
-import java.util.ArrayList;
-import java.util.List;
-
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 
@@ -25,18 +22,23 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
  * @author michal.polkorab
  *
  */
-public class ClearActionsInstructionDeserializer extends AbstractInstructionDeserializer {
+public class ClearActionsInstructionDeserializer implements OFDeserializer<Instruction>,
+        HeaderDeserializer<Instruction> {
 
     @Override
     public Instruction deserialize(ByteBuf input) {
-        InstructionBuilder builder = super.processHeader(input);
-        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        InstructionBuilder builder =  new InstructionBuilder();
+        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
-        ActionsInstructionBuilder actionsBuilder =
-                new ActionsInstructionBuilder();
-        List<Action> actions = new ArrayList<>();
-        actionsBuilder.setAction(actions);
-        builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
+        builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
+        return builder.build();
+    }
+
+    @Override
+    public Instruction deserializeHeader(ByteBuf input) {
+        InstructionBuilder builder = new InstructionBuilder();
+        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
         return builder.build();
     }
 }
\ No newline at end of file
index 0940aae99f7ee4af2ee377e244968add8944f362..31191b1d70478398c586414192c7ea0f5a53d691 100644 (file)
@@ -10,11 +10,12 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
 
 import io.netty.buffer.ByteBuf;
 
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 
@@ -22,18 +23,27 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
  * @author michal.polkorab
  *
  */
-public class GoToTableInstructionDeserializer extends AbstractInstructionDeserializer {
+public class GoToTableInstructionDeserializer  implements OFDeserializer<Instruction>,
+        HeaderDeserializer<Instruction> {
 
     @Override
     public Instruction deserialize(ByteBuf input) {
         InstructionBuilder builder = new InstructionBuilder();
-        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-        builder.setType(GotoTable.class);
-        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-        TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder();
-        tableBuilder.setTableId(input.readUnsignedByte());
-        builder.addAugmentation(TableIdInstruction.class, tableBuilder.build());
+        GotoTableCaseBuilder caseBuilder = new GotoTableCaseBuilder();
+        GotoTableBuilder instructionBuilder = new GotoTableBuilder();
+        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        instructionBuilder.setTableId(input.readUnsignedByte());
+        caseBuilder.setGotoTable(instructionBuilder.build());
+        builder.setInstructionChoice(caseBuilder.build());
         input.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE);
         return builder.build();
     }
+
+    @Override
+    public Instruction deserializeHeader(ByteBuf input) {
+        InstructionBuilder builder = new InstructionBuilder();
+        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        builder.setInstructionChoice(new GotoTableCaseBuilder().build());
+        return builder.build();
+    }
 }
index fa6c6bb55fb343d5c3e9458dda96224a248113d4..4667a4d8fa78babf40afe704b4d52bd09d48e7f6 100644 (file)
@@ -10,10 +10,11 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
 
 import io.netty.buffer.ByteBuf;
 
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 
@@ -21,17 +22,26 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
  * @author michal.polkorab
  *
  */
-public class MeterInstructionDeserializer extends AbstractInstructionDeserializer {
+public class MeterInstructionDeserializer implements OFDeserializer<Instruction>,
+        HeaderDeserializer<Instruction> {
 
     @Override
     public Instruction deserialize(ByteBuf input) {
         InstructionBuilder builder = new InstructionBuilder();
-        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-        builder.setType(Meter.class);
-        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-        MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();
-        meterBuilder.setMeterId(input.readUnsignedInt());
-        builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());
+        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        MeterCaseBuilder caseBuilder = new MeterCaseBuilder();
+        MeterBuilder instructionBuilder = new MeterBuilder();
+        instructionBuilder.setMeterId(input.readUnsignedInt());
+        caseBuilder.setMeter(instructionBuilder.build());
+        builder.setInstructionChoice(caseBuilder.build());
+        return builder.build();
+    }
+
+    @Override
+    public Instruction deserializeHeader(ByteBuf input) {
+        InstructionBuilder builder = new InstructionBuilder();
+        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        builder.setInstructionChoice(new MeterCaseBuilder().build());
         return builder.build();
     }
 
index c60532b083e4c06819ed4097efb45a0cad036234..4699ef69949aeb7f5fce529031300bc1e37a34e0 100644 (file)
@@ -8,18 +8,43 @@
 
 package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
+import io.netty.buffer.ByteBuf;
+
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 
 /**
  * @author michal.polkorab
  *
  */
-public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer {
+public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer
+        implements HeaderDeserializer<Instruction> {
+
+    @Override
+    public Instruction deserialize(ByteBuf input) {
+        InstructionBuilder builder = new InstructionBuilder();
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        int instructionLength = input.readUnsignedShort();
+        input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+        WriteActionsCaseBuilder caseBuilder = new WriteActionsCaseBuilder();
+        WriteActionsBuilder actionsBuilder = new WriteActionsBuilder();
+        actionsBuilder.setAction(deserializeActions(input, instructionLength));
+        caseBuilder.setWriteActions(actionsBuilder.build());
+        builder.setInstructionChoice(caseBuilder.build());
+        return builder.build();
+    }
 
     @Override
-    protected Class<? extends InstructionBase> getType() {
-        return WriteActions.class;
+    public Instruction deserializeHeader(ByteBuf input) {
+        InstructionBuilder builder = new InstructionBuilder();
+        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        builder.setInstructionChoice(new WriteActionsCaseBuilder().build());
+        return builder.build();
     }
 
 }
index 51646b626aa6a7702a5601e19ac5808c7a1c41e7..919fc50d2a24ffdfa1ff3e6d3006482b590298d8 100644 (file)
@@ -10,11 +10,12 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
 
 import io.netty.buffer.ByteBuf;
 
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 
@@ -22,23 +23,32 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
  * @author michal.polkorab
  *
  */
-public class WriteMetadataInstructionDeserializer extends AbstractInstructionDeserializer {
+public class WriteMetadataInstructionDeserializer implements OFDeserializer<Instruction>,
+        HeaderDeserializer<Instruction> {
 
     @Override
     public Instruction deserialize(ByteBuf input) {
         InstructionBuilder builder = new InstructionBuilder();
-        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-        builder.setType(WriteMetadata.class);
-        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
         input.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);
-        MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder();
+        WriteMetadataCaseBuilder caseBuilder = new WriteMetadataCaseBuilder();
+        WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
         byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
         input.readBytes(metadata);
         metadataBuilder.setMetadata(metadata);
         byte[] metadataMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
         input.readBytes(metadataMask);
         metadataBuilder.setMetadataMask(metadataMask);
-        builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build());
+        caseBuilder.setWriteMetadata(metadataBuilder.build());
+        builder.setInstructionChoice(caseBuilder.build());
+        return builder.build();
+    }
+
+    @Override
+    public Instruction deserializeHeader(ByteBuf input) {
+        InstructionBuilder builder = new InstructionBuilder();
+        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        builder.setInstructionChoice(new WriteMetadataCaseBuilder().build());
         return builder.build();
     }
 }
index 46674e52ca276440582aeae0a3a8580eef5307b0..3c9ff80be6ef55a0076fb3221ca5d149aa2b939b 100644 (file)
@@ -17,12 +17,12 @@ import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.Met
 import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteActionsInstructionSerializer;
 import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteMetadataInstructionSerializer;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionSerializerRegistryHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;
 
 /**
  * @author michal.polkorab
@@ -42,11 +42,11 @@ public final class InstructionsInitializer {
         // register OF v1.3 instruction serializers
         InstructionSerializerRegistryHelper helper= new InstructionSerializerRegistryHelper(
                 EncodeConstants.OF13_VERSION_ID, serializerRegistry);
-        helper.registerSerializer(GotoTable.class, new GoToTableInstructionSerializer());
-        helper.registerSerializer(WriteMetadata.class, new WriteMetadataInstructionSerializer());
-        helper.registerSerializer(WriteActions.class, new WriteActionsInstructionSerializer());
-        helper.registerSerializer(ApplyActions.class, new ApplyActionsInstructionSerializer());
-        helper.registerSerializer(ClearActions.class, new ClearActionsInstructionSerializer());
-        helper.registerSerializer(Meter.class, new MeterInstructionSerializer());
+        helper.registerSerializer(GotoTableCase.class, new GoToTableInstructionSerializer());
+        helper.registerSerializer(WriteMetadataCase.class, new WriteMetadataInstructionSerializer());
+        helper.registerSerializer(WriteActionsCase.class, new WriteActionsInstructionSerializer());
+        helper.registerSerializer(ApplyActionsCase.class, new ApplyActionsInstructionSerializer());
+        helper.registerSerializer(ClearActionsCase.class, new ClearActionsInstructionSerializer());
+        helper.registerSerializer(MeterCase.class, new MeterInstructionSerializer());
     }
 }
index 5a75e530536d27a900e69f2dee2e8de239a663a6..c1f3d7bbd0280feebdfe354fba5eac40e9cf70d8 100644 (file)
@@ -19,9 +19,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer;
 import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker;
 import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 
 /**
  * @author michal.polkorab
@@ -35,22 +33,13 @@ public abstract class AbstractActionInstructionSerializer extends AbstractInstru
 
     private SerializerRegistry registry;
 
-    @Override
-    public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
-        int startIndex = outBuffer.writerIndex();
-        outBuffer.writeShort(getType());
-        if (instruction.getAugmentation(ActionsInstruction.class) != null) {
-            List<Action> actions = instruction.getAugmentation(ActionsInstruction.class).getAction();
-            int lengthIndex = outBuffer.writerIndex();
-            outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
-            outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
-            ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer);
-            int instructionLength = outBuffer.writerIndex() - startIndex;
-            outBuffer.setShort(lengthIndex, instructionLength);
-        } else {
-            outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
-            outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
-        }
+    protected void writeActions(final List<Action> actions, final ByteBuf outBuffer, int startIndex) {
+        int lengthIndex = outBuffer.writerIndex();
+        outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
+        outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+        ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer);
+        int instructionLength = outBuffer.writerIndex() - startIndex;
+        outBuffer.setShort(lengthIndex, instructionLength);
     }
 
     protected SerializerRegistry getRegistry() {
index 2aaae19ba71ca4442d7fe9811d29286b5278d4b8..4d6f1f53ec2e4d54b7aee5cb9a42f0c1cb3c2cfd 100644 (file)
@@ -8,7 +8,14 @@
 
 package org.opendaylight.openflowjava.protocol.impl.serialization.instruction;
 
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 
 /**
  * @author michal.polkorab
@@ -16,6 +23,20 @@ import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
  */
 public class ApplyActionsInstructionSerializer extends AbstractActionInstructionSerializer {
 
+    @Override
+    public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
+        int startIndex = outBuffer.writerIndex();
+        outBuffer.writeShort(getType());
+        ApplyActionsCase actionsCase = (ApplyActionsCase) instruction.getInstructionChoice();
+        if (actionsCase != null) {
+            List<Action> actions = actionsCase.getApplyActions().getAction();
+            writeActions(actions, outBuffer, startIndex);
+        } else {
+            outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
+            outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+        }
+    }
+
     @Override
     protected int getType() {
         return InstructionConstants.APPLY_ACTIONS_TYPE;
index 00162502e9b530b6305df73f02890ca4f46a0899..b8585b05f52835dddf5f330069db839bf240fa53 100644 (file)
@@ -8,13 +8,23 @@
 
 package org.opendaylight.openflowjava.protocol.impl.serialization.instruction;
 
+import io.netty.buffer.ByteBuf;
+
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 
 /**
  * @author michal.polkorab
  *
  */
-public class ClearActionsInstructionSerializer extends AbstractActionInstructionSerializer {
+public class ClearActionsInstructionSerializer extends AbstractInstructionSerializer {
+
+    @Override
+    public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
+        outBuffer.writeShort(getType());
+        outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
+        outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+    }
 
     @Override
     protected int getType() {
index 47c7c43cf51d2c02ae4a139043a0d0267e6257fd..4aca403bea699a7597e84e6ea4449a0d2d2d5d02 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.instruction;
 import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 
 /**
@@ -24,7 +24,8 @@ public class GoToTableInstructionSerializer extends AbstractInstructionSerialize
     public void serialize(Instruction instruction, ByteBuf outBuffer) {
         outBuffer.writeShort(getType());
         outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
-        outBuffer.writeByte(instruction.getAugmentation(TableIdInstruction.class).getTableId());
+        outBuffer.writeByte(((GotoTableCase) instruction.getInstructionChoice())
+                .getGotoTable().getTableId());
         outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE);
     }
 
index 1387d1e2cd9c745546d76f8e6ded8f817efcc15d..cd1099fef8cb7e2e8ad674ff4d134d7dabf1c632 100644 (file)
@@ -11,7 +11,7 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.instruction;
 import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 
 /**
@@ -24,8 +24,8 @@ public class MeterInstructionSerializer extends AbstractInstructionSerializer {
     public void serialize(Instruction instruction, ByteBuf outBuffer) {
         outBuffer.writeShort(getType());
         outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
-        outBuffer.writeInt(instruction.
-                getAugmentation(MeterIdInstruction.class).getMeterId().intValue());
+        outBuffer.writeInt(((MeterCase) instruction.getInstructionChoice())
+                .getMeter().getMeterId().intValue());
     }
 
     @Override
index 10e20504a4cd2ff643eaa75f6358b2fd98b2be91..28393a5e9cce232a057574714918b9e9ed970db0 100644 (file)
@@ -8,7 +8,14 @@
 
 package org.opendaylight.openflowjava.protocol.impl.serialization.instruction;
 
+import io.netty.buffer.ByteBuf;
+
+import java.util.List;
+
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 
 /**
  * @author michal.polkorab
@@ -16,6 +23,20 @@ import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
  */
 public class WriteActionsInstructionSerializer extends AbstractActionInstructionSerializer {
 
+    @Override
+    public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
+        int startIndex = outBuffer.writerIndex();
+        outBuffer.writeShort(getType());
+        WriteActionsCase actionsCase = (WriteActionsCase) instruction.getInstructionChoice();
+        if (actionsCase != null) {
+            List<Action> actions = actionsCase.getWriteActions().getAction();
+            writeActions(actions, outBuffer, startIndex);
+        } else {
+            outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
+            outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
+        }
+    }
+
     @Override
     protected int getType() {
         return InstructionConstants.WRITE_ACTIONS_TYPE;
index 3b407fdc455ab358aacc3b1c9c793490b89c4739..a9b2a90754d141b87807fa71b420e94278e04564 100644 (file)
@@ -11,7 +11,8 @@ package org.opendaylight.openflowjava.protocol.impl.serialization.instruction;
 import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadata;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 
 /**
@@ -25,7 +26,8 @@ public class WriteMetadataInstructionSerializer extends AbstractInstructionSeria
         outBuffer.writeShort(getType());
         outBuffer.writeShort(InstructionConstants.WRITE_METADATA_LENGTH);
         outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA);
-        MetadataInstruction metadata = instruction.getAugmentation(MetadataInstruction.class);
+        WriteMetadata metadata = ((WriteMetadataCase) instruction.getInstructionChoice())
+                .getWriteMetadata();
         outBuffer.writeBytes(metadata.getMetadata());
         outBuffer.writeBytes(metadata.getMetadataMask());
     }
index d85fbbdd6461127c5d8dbc15b288331c181aa4aa..78a361803b01b783795b12d8e2b31cb63ed28124 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.openflowjava.protocol.impl.util;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
 
 /**
  * @author michal.polkorab
@@ -34,7 +34,7 @@ public class InstructionSerializerRegistryHelper {
      * @param instructionType
      * @param serializer
      */
-    public <T extends InstructionBase> void registerSerializer(Class<T> instructionType,
+    public <T extends InstructionChoice> void registerSerializer(Class<T> instructionType,
             OFGeneralSerializer serializer) {
         serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version,
                 instructionType, null), serializer);
index b5a2a4a5225f1d7001ab5ccef433ab4bcfc4b4b6..e74ac05fa253bbbc6e615398078096d0d90b5627 100644 (file)
@@ -14,10 +14,10 @@ import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSe
 import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
@@ -74,7 +74,8 @@ public abstract class TypeKeyMakerFactory {
                             expIdCase.getExperimenter().getExperimenter().getValue(),
                             expIdCase.getExperimenter().getSubType());
                 }
-                return new ActionSerializerKey<>(getVersion(), (Class<ActionChoice>) entry.getActionChoice().getImplementedInterface(), null);
+                return new ActionSerializerKey<>(getVersion(),
+                        (Class<ActionChoice>) entry.getActionChoice().getImplementedInterface(), null);
             }
         };
     }
@@ -88,13 +89,15 @@ public abstract class TypeKeyMakerFactory {
         return new AbstractTypeKeyMaker<Instruction>(version) {
             @Override
             public MessageTypeKey<?> make(Instruction entry) {
-                if (entry.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
-                        .instruction.rev130731.Experimenter.class)) {
+                if (entry.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
+                        .augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase) {
                     return new ExperimenterInstructionSerializerKey(getVersion(),
-                            entry.getAugmentation(ExperimenterIdInstruction.class)
-                            .getExperimenter().getValue());
+                            ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction
+                                    .container.instruction.choice.ExperimenterIdCase) entry.getInstructionChoice())
+                                    .getExperimenter().getExperimenterId().getValue());
                 }
-                return new InstructionSerializerKey<>(getVersion(), entry.getType(), null);
+                return new InstructionSerializerKey<>(getVersion(),
+                        (Class<InstructionChoice>) entry.getInstructionChoice().getImplementedInterface(), null);
             }
         };
     }
index b7a76b4262b43f0404e1be367aa90b892f4b8ec1..1d8c8431846022986a3374fcbe6d83f770332e20 100644 (file)
@@ -13,12 +13,12 @@ import io.netty.buffer.ByteBuf;
 import org.junit.Assert;
 import org.junit.Test;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 
 /**
@@ -31,35 +31,30 @@ public class AbstractInstructionDeserializerTest {
      * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different
      * instruction types
      */
-    @Test(expected=IllegalStateException.class)
+    @Test
     public void test() {
         ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04");
-        GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer();
-        Instruction instruction = deserializer.deserializeHeader(buffer);
-        Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType());
+        Instruction instruction = new GoToTableInstructionDeserializer().deserializeHeader(buffer);
+        Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof GotoTableCase);
 
         buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04");
-        instruction = deserializer.deserializeHeader(buffer);
-        Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType());
+        instruction = new WriteMetadataInstructionDeserializer().deserializeHeader(buffer);
+        Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof WriteMetadataCase);
 
         buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04");
-        instruction = deserializer.deserializeHeader(buffer);
-        Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType());
+        instruction = new WriteActionsInstructionDeserializer().deserializeHeader(buffer);
+        Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof WriteActionsCase);
 
         buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04");
-        instruction = deserializer.deserializeHeader(buffer);
-        Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType());
+        instruction = new ApplyActionsInstructionDeserializer().deserializeHeader(buffer);
+        Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof ApplyActionsCase);
 
         buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04");
-        instruction = deserializer.deserializeHeader(buffer);
-        Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType());
+        instruction = new ClearActionsInstructionDeserializer().deserializeHeader(buffer);
+        Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof ClearActionsCase);
 
         buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04");
-        instruction = deserializer.deserializeHeader(buffer);
-        Assert.assertEquals("Wrong type", Meter.class, instruction.getType());
-
-        buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04");
-        instruction = deserializer.deserializeHeader(buffer);
-        // exception expected
+        instruction = new MeterInstructionDeserializer().deserializeHeader(buffer);
+        Assert.assertTrue("Wrong type", instruction.getInstructionChoice() instanceof MeterCase);
     }
 }
\ No newline at end of file
index 4c3caa4d98ab110fa18ff9b9744a3afa48cc1163..edf21a2c6f1cce1b05feb5103891fa4e27b58960 100644 (file)
@@ -24,19 +24,16 @@ import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
@@ -124,19 +121,22 @@ public class FlowModInputMessageFactoryTest {
         builder.setMatch(matchBuilder.build());
         List<Instruction> instructions = new ArrayList<>();
         InstructionBuilder insBuilder = new InstructionBuilder();
-        insBuilder.setType(GotoTable.class);
-        TableIdInstructionBuilder idBuilder = new TableIdInstructionBuilder();
-        idBuilder.setTableId((short) 43);
-        insBuilder.addAugmentation(TableIdInstruction.class, idBuilder.build());
+        GotoTableCaseBuilder goToCaseBuilder = new GotoTableCaseBuilder();
+        GotoTableBuilder instructionBuilder = new GotoTableBuilder();
+        instructionBuilder.setTableId((short) 43);
+        goToCaseBuilder.setGotoTable(instructionBuilder.build());
+        insBuilder.setInstructionChoice(goToCaseBuilder.build());
         instructions.add(insBuilder.build());
-        insBuilder.setType(WriteMetadata.class);
-        MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder();
-        metaBuilder.setMetadata(cookie);
-        metaBuilder.setMetadataMask(cookieMask);
-        insBuilder.addAugmentation(MetadataInstruction.class, metaBuilder.build());
+        WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
+        WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
+        metadataBuilder.setMetadata(cookie);
+        metadataBuilder.setMetadataMask(cookieMask);
+        metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
+        insBuilder.setInstructionChoice(metadataCaseBuilder.build());
         instructions.add(insBuilder.build());
         insBuilder = new InstructionBuilder();
-        insBuilder.setType(ApplyActions.class);
+        ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+        ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder();
         List<Action> actions = new ArrayList<>();
         ActionBuilder actionBuilder = new ActionBuilder();
         OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
@@ -146,9 +146,9 @@ public class FlowModInputMessageFactoryTest {
         caseBuilder.setOutputAction(outputBuilder.build());
         actionBuilder.setActionChoice(caseBuilder.build());
         actions.add(actionBuilder.build());
-        ActionsInstructionBuilder actionInstructionBuilder = new ActionsInstructionBuilder();
-        actionInstructionBuilder.setAction(actions);
-        insBuilder.addAugmentation(ActionsInstruction.class, actionInstructionBuilder.build());
+        actionsBuilder.setAction(actions);
+        applyActionsCaseBuilder.setApplyActions(actionsBuilder.build());
+        insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
         instructions.add(insBuilder.build());
         builder.setInstruction(instructions);
         FlowModInput message = builder.build();
index 3ad8ced1ad533278cfd0e42fe7daa7d61ccce1ec..48695a8cb37c7df15dad69ada27a754a9d9e5c92 100644 (file)
@@ -46,12 +46,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
@@ -147,10 +147,10 @@ public class MultipartRequestTableFeaturesTest {
                 new InstructionRelatedTableFeaturePropertyBuilder();
         List<Instruction> insIds = new ArrayList<>();
         InstructionBuilder insBuilder = new InstructionBuilder();
-        insBuilder.setType(WriteActions.class);
+        insBuilder.setInstructionChoice(new WriteActionsCaseBuilder().build());
         insIds.add(insBuilder.build());
         insBuilder = new InstructionBuilder();
-        insBuilder.setType(GotoTable.class);
+        insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
         insIds.add(insBuilder.build());
         insPropBuilder.setInstruction(insIds);
         propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
@@ -160,19 +160,19 @@ public class MultipartRequestTableFeaturesTest {
         insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
         insIds = new ArrayList<>();
         insBuilder = new InstructionBuilder();
-        insBuilder.setType(WriteMetadata.class);
+        insBuilder.setInstructionChoice(new WriteMetadataCaseBuilder().build());
         insIds.add(insBuilder.build());
         insBuilder = new InstructionBuilder();
-        insBuilder.setType(ApplyActions.class);
+        insBuilder.setInstructionChoice(new ApplyActionsCaseBuilder().build());
         insIds.add(insBuilder.build());
         insBuilder = new InstructionBuilder();
-        insBuilder.setType(Meter.class);
+        insBuilder.setInstructionChoice(new MeterCaseBuilder().build());
         insIds.add(insBuilder.build());
         insBuilder = new InstructionBuilder();
-        insBuilder.setType(ClearActions.class);
+        insBuilder.setInstructionChoice(new ClearActionsCaseBuilder().build());
         insIds.add(insBuilder.build());
         insBuilder = new InstructionBuilder();
-        insBuilder.setType(GotoTable.class);
+        insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
         insIds.add(insBuilder.build());
         insPropBuilder.setInstruction(insIds);
         propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
index 909918a69ca961f81c7ebd72ef95896e579f248e..60f187618d9e451e699f214c9036b763631847ca 100644 (file)
@@ -18,15 +18,17 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegi
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetQueueCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 
 /**
@@ -63,46 +65,43 @@ public class InstructionsDeserializerTest {
         List<Instruction> instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,
                 message.readableBytes(), message, keyMaker, registry);
         Instruction i1 = instructions.get(0);
-        Assert.assertEquals("Wrong type - i1", "org.opendaylight.yang.gen.v1.urn."
-                + "opendaylight.openflow.common.instruction.rev130731.GotoTable", i1.getType().getName());
-        Assert.assertEquals("Wrong table-id - i1", 10, i1.getAugmentation(TableIdInstruction.class).getTableId().intValue());
+        Assert.assertTrue("Wrong type - i1", i1.getInstructionChoice() instanceof GotoTableCase);
+        Assert.assertEquals("Wrong table-id - i1", 10, ((GotoTableCase) i1.getInstructionChoice())
+                .getGotoTable().getTableId().intValue());
         Instruction i2 = instructions.get(1);
-        Assert.assertEquals("Wrong type - i2", "org.opendaylight.yang.gen.v1.urn."
-                + "opendaylight.openflow.common.instruction.rev130731.WriteMetadata", i2.getType().getName());
+        Assert.assertTrue("Wrong type - i2", i2.getInstructionChoice() instanceof WriteMetadataCase);
         Assert.assertArrayEquals("Wrong metadata - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 20"),
-                i2.getAugmentation(MetadataInstruction.class).getMetadata());
+                ((WriteMetadataCase) i2.getInstructionChoice()).getWriteMetadata().getMetadata());
         Assert.assertArrayEquals("Wrong metadata-mask - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 30"),
-                i2.getAugmentation(MetadataInstruction.class).getMetadataMask());
+                ((WriteMetadataCase) i2.getInstructionChoice()).getWriteMetadata().getMetadataMask());
         Instruction i3 = instructions.get(2);
-        Assert.assertEquals("Wrong type - i3", "org.opendaylight.yang.gen.v1.urn."
-                + "opendaylight.openflow.common.instruction.rev130731.ClearActions", i3.getType().getName());
-        Assert.assertEquals("Wrong instructions - i3", 0, i3.getAugmentation(ActionsInstruction.class).getAction().size());
+        Assert.assertTrue("Wrong type - i3", i3.getInstructionChoice() instanceof ClearActionsCase);
         Instruction i4 = instructions.get(3);
-        Assert.assertEquals("Wrong type - i4", "org.opendaylight.yang.gen.v1.urn."
-                + "opendaylight.openflow.common.instruction.rev130731.Meter", i4.getType().getName());
-        Assert.assertEquals("Wrong meterId - i4", 66051, i4.getAugmentation(MeterIdInstruction.class).getMeterId().intValue());
+        Assert.assertTrue("Wrong type - i4", i4.getInstructionChoice() instanceof MeterCase);
+        Assert.assertEquals("Wrong meterId - i4", 66051, ((MeterCase) i4.getInstructionChoice())
+                .getMeter().getMeterId().intValue());
         Instruction i5 = instructions.get(4);
-        Assert.assertEquals("Wrong type - i5", "org.opendaylight.yang.gen.v1.urn."
-                + "opendaylight.openflow.common.instruction.rev130731.WriteActions", i5.getType().getName());
-        Assert.assertEquals("Wrong instructions - i5", 2, i5.getAugmentation(ActionsInstruction.class).getAction().size());
-        Action action1 = i5.getAugmentation(ActionsInstruction.class).getAction().get(0);
+        Assert.assertTrue("Wrong type - i5", i5.getInstructionChoice() instanceof WriteActionsCase);
+        Assert.assertEquals("Wrong instructions - i5", 2, ((WriteActionsCase) i5.getInstructionChoice())
+                .getWriteActions().getAction().size());
+        Action action1 = ((WriteActionsCase) i5.getInstructionChoice()).getWriteActions().getAction().get(0);
         Assert.assertTrue("Wrong action", action1.getActionChoice() instanceof OutputActionCase);
         Assert.assertEquals("Wrong action", 37, ((OutputActionCase) action1.getActionChoice()).getOutputAction()
                 .getPort().getValue().intValue());
         Assert.assertEquals("Wrong action", 53, ((OutputActionCase) action1.getActionChoice()).getOutputAction()
                 .getMaxLength().intValue());
-        Action action2 = i5.getAugmentation(ActionsInstruction.class).getAction().get(1);
+        Action action2 = ((WriteActionsCase) i5.getInstructionChoice()).getWriteActions().getAction().get(1);
         Assert.assertTrue("Wrong action", action2.getActionChoice() instanceof GroupCase);
         Assert.assertEquals("Wrong action", 80, ((GroupCase) action2.getActionChoice()).getGroupAction().getGroupId().intValue());
         Instruction i6 = instructions.get(5);
-        Assert.assertEquals("Wrong type - i6", "org.opendaylight.yang.gen.v1.urn."
-                + "opendaylight.openflow.common.instruction.rev130731.ApplyActions", i6.getType().getName());
-        Assert.assertEquals("Wrong instructions - i6", 2, i6.getAugmentation(ActionsInstruction.class).getAction().size());
-        action1 = i6.getAugmentation(ActionsInstruction.class).getAction().get(0);
+        Assert.assertTrue("Wrong type - i6", i6.getInstructionChoice() instanceof ApplyActionsCase);
+        Assert.assertEquals("Wrong instructions - i6", 2, ((ApplyActionsCase) i6.getInstructionChoice())
+                .getApplyActions().getAction().size());
+        action1 = ((ApplyActionsCase) i6.getInstructionChoice()).getApplyActions().getAction().get(0);
         Assert.assertTrue("Wrong action", action1.getActionChoice() instanceof SetQueueCase);
         Assert.assertEquals("Wrong action", 37, ((SetQueueCase) action1.getActionChoice()).getSetQueueAction()
                 .getQueueId().intValue());
-        action2 = i6.getAugmentation(ActionsInstruction.class).getAction().get(1);
+        action2 = ((ApplyActionsCase) i6.getInstructionChoice()).getApplyActions().getAction().get(1);
         Assert.assertTrue("Wrong action", action2.getActionChoice() instanceof SetMplsTtlCase);
         Assert.assertEquals("Wrong action", 5, ((SetMplsTtlCase) action2.getActionChoice()).getSetMplsTtlAction()
                 .getMplsTtl().shortValue());
index 99290012ae2cd2c33fde4c91ebd17fd5af5a40d1..251c4c945d09bc894993bf326cbed74ac34c7452 100644 (file)
@@ -20,14 +20,6 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegist
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionsInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MetadataInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.MeterIdInstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.TableIdInstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;
@@ -37,12 +29,17 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.ttl._case.SetNwTtlActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ClearActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
@@ -73,34 +70,37 @@ public class OF13InstructionsSerializerTest {
         List<Instruction> instructions = new ArrayList<>();
         // Goto_table instruction
         InstructionBuilder builder = new InstructionBuilder();
-        builder.setType(GotoTable.class);
-        TableIdInstructionBuilder tableIdBuilder = new TableIdInstructionBuilder();
-        tableIdBuilder.setTableId((short) 5);
-        builder.addAugmentation(TableIdInstruction.class, tableIdBuilder.build());
+        GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
+        GotoTableBuilder instructionBuilder = new GotoTableBuilder();
+        instructionBuilder.setTableId((short) 5);
+        gotoCaseBuilder.setGotoTable(instructionBuilder.build());
+        builder.setInstructionChoice(gotoCaseBuilder.build());
         instructions.add(builder.build());
-        builder = new InstructionBuilder();
         // Write_metadata instruction
-        builder.setType(WriteMetadata.class);
-        MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder();
-        metaBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07"));
-        metaBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00"));
-        builder.addAugmentation(MetadataInstruction.class, metaBuilder.build());
+        builder = new InstructionBuilder();
+        WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
+        WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
+        metadataBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07"));
+        metadataBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00"));
+        metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
+        builder.setInstructionChoice(metadataCaseBuilder.build());
         instructions.add(builder.build());
         // Clear_actions instruction
         builder = new InstructionBuilder();
-        builder.setType(ClearActions.class);
+        builder.setInstructionChoice(new ClearActionsCaseBuilder().build());
         instructions.add(builder.build());
         // Meter instruction
         builder = new InstructionBuilder();
-        builder.setType(Meter.class);
-        MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();
+        MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
+        MeterBuilder meterBuilder = new MeterBuilder();
         meterBuilder.setMeterId(42L);
-        builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());
+        meterCaseBuilder.setMeter(meterBuilder.build());
+        builder.setInstructionChoice(meterCaseBuilder.build());
         instructions.add(builder.build());
         // Write_actions instruction
         builder = new InstructionBuilder();
-        builder.setType(WriteActions.class);
-        ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder();
+        WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
+        WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
         List<Action> actions = new ArrayList<>();
         ActionBuilder actionBuilder = new ActionBuilder();
         OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
@@ -117,13 +117,14 @@ public class OF13InstructionsSerializerTest {
         ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build());
         actionBuilder.setActionChoice(ttlCaseBuilder.build());
         actions.add(actionBuilder.build());
-        actionsBuilder.setAction(actions);
-        builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
+        writeActionsBuilder.setAction(actions);
+        writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
+        builder.setInstructionChoice(writeActionsCaseBuilder.build());
         instructions.add(builder.build());
         // Apply_actions instruction
         builder = new InstructionBuilder();
-        builder.setType(ApplyActions.class);
-        actionsBuilder = new ActionsInstructionBuilder();
+        ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+        ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
         actions = new ArrayList<>();
         actionBuilder = new ActionBuilder();
         PushVlanCaseBuilder vlanCaseBuilder = new PushVlanCaseBuilder();
@@ -135,8 +136,9 @@ public class OF13InstructionsSerializerTest {
         actionBuilder = new ActionBuilder();
         actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
         actions.add(actionBuilder.build());
-        actionsBuilder.setAction(actions);
-        builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build());
+        applyActionsBuilder.setAction(actions);
+        applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
+        builder.setInstructionChoice(applyActionsCaseBuilder.build());
         instructions.add(builder.build());
 
         ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
index 629e2490bc490359af97bd1e8e355b5751eddfd5..dd76638933b32d3d5d761b77d303a222ddb1aaca 100644 (file)
@@ -17,8 +17,6 @@ import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType;
@@ -26,7 +24,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
@@ -97,13 +96,13 @@ public class TypeKeyMakerFactoryTest {
         Assert.assertNotNull("Null keyMaker", keyMaker);
 
         InstructionBuilder builder = new InstructionBuilder();
-        builder.setType(GotoTable.class);
+        builder.setInstructionChoice(new GotoTableCaseBuilder().build());
         Instruction instruction = builder.build();
         MessageTypeKey<?> key = keyMaker.make(instruction);
 
         Assert.assertNotNull("Null key", key);
         Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID,
-                        GotoTable.class, null), key);
+                        GotoTableCase.class, null), key);
     }
 
     /**
@@ -115,11 +114,16 @@ public class TypeKeyMakerFactoryTest {
         Assert.assertNotNull("Null keyMaker", keyMaker);
 
         InstructionBuilder builder = new InstructionBuilder();
-        builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
-                .common.instruction.rev130731.Experimenter.class);
-        ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder();
-        expIdBuilder.setExperimenter(new ExperimenterId(42L));
-        builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build());
+        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container
+        .instruction.choice.ExperimenterIdCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn
+        .opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCaseBuilder();
+        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container
+        .instruction.choice.experimenter.id._case.ExperimenterBuilder expIdBuilder = new org.opendaylight.yang.gen
+        .v1.urn.opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.experimenter.id
+        ._case.ExperimenterBuilder();
+        expIdBuilder.setExperimenterId(new ExperimenterId(42L));
+        caseBuilder.setExperimenter(expIdBuilder.build());
+        builder.setInstructionChoice(caseBuilder.build());
         Instruction instruction = builder.build();
         MessageTypeKey<?> key = keyMaker.make(instruction);