Fixup Augmentable and Identifiable methods changing
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / flow / FlowInstructionResponseConvertor.java
index edc10de00bf5838ec8cc33c541405b24f44245e0..6691d75d2d767b2a74fbdb229cad11c8b9b38b39 100644 (file)
@@ -42,11 +42,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
 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.yangtools.yang.binding.DataContainer;
 
 /**
- * Converts Openflow 1.3+ specific instructions to MD-SAL format flow instruction
+ * Converts Openflow 1.3+ specific instructions to MD-SAL format flow instruction.
  *
+ * <p>
  * Example usage:
  * <pre>
  * {@code
@@ -56,46 +56,52 @@ import org.opendaylight.yangtools.yang.binding.DataContainer;
  * </pre>
  */
 public final class FlowInstructionResponseConvertor extends Convertor<
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction>,
+        List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions
+            .grouping.Instruction>,
         Instructions,
         VersionConvertorData> {
 
-    private static final Set<Class<? extends DataContainer>> TYPES = Collections.singleton(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction.class);
+    private static final Set<Class<?>> TYPES = Collections.singleton(org.opendaylight.yang.gen.v1.urn.opendaylight
+            .openflow.common.instruction.rev130731.instructions.grouping.Instruction.class);
 
     @Override
-    public Collection<Class<? extends DataContainer>> getTypes() {
+    public Collection<Class<?>> getTypes() {
         return TYPES;
     }
 
     @Override
-    public Instructions convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction> source, VersionConvertorData data) {
+    public Instructions convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction
+            .rev130731.instructions.grouping.Instruction> source, VersionConvertorData data) {
         InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
 
         List<Instruction> salInstructionList = new ArrayList<>();
         int instructionTreeNodekey = 0;
         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction salInstruction;
 
-        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.
-                Instruction switchInst : source) {
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping
+                .Instruction switchInst : source) {
             if (switchInst.getInstructionChoice() instanceof ApplyActionsCase) {
-                ApplyActionsCase actionsInstruction = ((ApplyActionsCase) switchInst.getInstructionChoice());
+                ApplyActionsCase actionsInstruction = (ApplyActionsCase) switchInst.getInstructionChoice();
                 ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
                 ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
 
-                final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(data.getVersion());
-                actionResponseConvertorData.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION);
+                final ActionResponseConvertorData actionResponseConvertorData =
+                        new ActionResponseConvertorData(data.getVersion());
+                actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
 
                 final Optional<List<Action>> actions = getConvertorExecutor().convert(
                         actionsInstruction.getApplyActions().getAction(), actionResponseConvertorData);
 
-                applyActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
+                applyActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(
+                        actions.orElse(Collections.emptyList())));
                 applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
                 salInstruction = applyActionsCaseBuilder.build();
-            } else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase) {
+            } else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight
+                    .openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase) {
                 ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
                 salInstruction = clearActionsCaseBuilder.build();
             } else if (switchInst.getInstructionChoice() instanceof GotoTableCase) {
-                GotoTableCase gotoTableCase = ((GotoTableCase) switchInst.getInstructionChoice());
+                GotoTableCase gotoTableCase = (GotoTableCase) switchInst.getInstructionChoice();
 
                 GoToTableCaseBuilder goToTableCaseBuilder = new GoToTableCaseBuilder();
                 GoToTableBuilder goToTableBuilder = new GoToTableBuilder();
@@ -104,7 +110,7 @@ public final class FlowInstructionResponseConvertor extends Convertor<
 
                 salInstruction = goToTableCaseBuilder.build();
             } else if (switchInst.getInstructionChoice() instanceof MeterCase) {
-                MeterCase meterIdInstruction = ((MeterCase) switchInst.getInstructionChoice());
+                MeterCase meterIdInstruction = (MeterCase) switchInst.getInstructionChoice();
 
                 MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
                 MeterBuilder meterBuilder = new MeterBuilder();
@@ -113,26 +119,34 @@ public final class FlowInstructionResponseConvertor extends Convertor<
 
                 salInstruction = meterCaseBuilder.build();
             } else if (switchInst.getInstructionChoice() instanceof WriteActionsCase) {
-                WriteActionsCase writeActionsCase = ((WriteActionsCase) switchInst.getInstructionChoice());
+                WriteActionsCase writeActionsCase = (WriteActionsCase) switchInst.getInstructionChoice();
                 WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
                 WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
 
-                final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(data.getVersion());
-                actionResponseConvertorData.setActionPath(ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION);
+                final ActionResponseConvertorData actionResponseConvertorData =
+                        new ActionResponseConvertorData(data.getVersion());
+                actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS);
 
                 final Optional<List<Action>> actions = getConvertorExecutor().convert(
                         writeActionsCase.getWriteActions().getAction(), actionResponseConvertorData);
 
-                writeActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
+                writeActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(
+                        actions.orElse(Collections.emptyList())));
                 writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
                 salInstruction = writeActionsCaseBuilder.build();
-            } else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase writeMetadataCase =
-                        ((org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) switchInst.getInstructionChoice());
+            } else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight
+                    .openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) {
+                org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction
+                    .grouping.instruction.choice.WriteMetadataCase writeMetadataCase =
+                        (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731
+                            .instruction.grouping.instruction.choice.WriteMetadataCase) switchInst
+                                .getInstructionChoice();
                 WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
                 WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
-                writeMetadataBuilder.setMetadata(new BigInteger(OFConstants.SIGNUM_UNSIGNED, writeMetadataCase.getWriteMetadata().getMetadata()));
-                writeMetadataBuilder.setMetadataMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, writeMetadataCase.getWriteMetadata().getMetadataMask()));
+                writeMetadataBuilder.setMetadata(new BigInteger(OFConstants.SIGNUM_UNSIGNED,
+                        writeMetadataCase.getWriteMetadata().getMetadata()));
+                writeMetadataBuilder.setMetadataMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED,
+                        writeMetadataCase.getWriteMetadata().getMetadataMask()));
                 writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
                 salInstruction = writeMetadataCaseBuilder.build();
             } else {
@@ -141,7 +155,7 @@ public final class FlowInstructionResponseConvertor extends Convertor<
 
             InstructionBuilder instBuilder = new InstructionBuilder();
             instBuilder.setInstruction(salInstruction);
-            instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
+            instBuilder.withKey(new InstructionKey(instructionTreeNodekey));
             instBuilder.setOrder(instructionTreeNodekey);
             instructionTreeNodekey++;
             salInstructionList.add(instBuilder.build());