Bug 5540 - TableFeaturesResponseConvertor 68/40868/22
authorTomas Slusny <tomas.slusny@pantheon.sk>
Mon, 27 Jun 2016 12:52:17 +0000 (14:52 +0200)
committerTomas Slusny <tomas.slusny@pantheon.sk>
Wed, 3 Aug 2016 15:51:47 +0000 (17:51 +0200)
- Reworked TableFeaturesReplyConvertor (renamed to TableFeaturesResponseConvertor) to
  use new ConvertorManager desing
- Updated tests and usage of TableFeaturesReplyConvertor/TableFeaturesResponseConvertor

Change-Id: Ifc48f3228ba09d6ee8cf87d902178957c3a67f7d
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.sk>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/NodeStaticReplyTranslatorUtil.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/SalTableServiceImpl.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ConvertorManager.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertor.java [moved from openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesReplyConvertor.java with 72% similarity]
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/translator/MultipartReplyTableFeaturesToTableUpdatedTranslator.java
openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesResponseConvertorTest.java [moved from openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesReplyConvertorTest.java with 95% similarity]

index 449c24cfe2deb67e81a7ac3aca0fd2a886376162..8a2284c3d9f56e8f18a24d2c3ae909b8483372cb 100644 (file)
@@ -12,9 +12,10 @@ import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import javax.annotation.CheckForNull;
 import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
@@ -221,7 +222,8 @@ public class NodeStaticReplyTranslatorUtil {
      */
     public static List<TableFeatures> nodeTableFeatureTranslator(@CheckForNull final MultipartReplyTableFeatures reply) {
         Preconditions.checkArgument(reply != null);
-        return TableFeaturesReplyConvertor.toTableFeaturesReply(reply);
+        final Optional<List<TableFeatures>> tableFeaturesList = ConvertorManager.getInstance().convert(reply);
+        return tableFeaturesList.orElse(Collections.emptyList());
     }
 
     /**
index 86d1e7892228ac1d337708366ee9f1255c366742..7282896ea765f68dba5552f1f17ec668d2ac7399 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
 import org.opendaylight.openflowplugin.api.openflow.device.TxFacade;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -145,9 +144,14 @@ public final class SalTableServiceImpl extends AbstractMultipartService<UpdateTa
                     final MultipartReplyTableFeaturesCase tableFeaturesCase = ((MultipartReplyTableFeaturesCase) multipartReplyBody);
                     final MultipartReplyTableFeatures salTableFeatures = tableFeaturesCase
                             .getMultipartReplyTableFeatures();
-                    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesPartial = TableFeaturesReplyConvertor
-                            .toTableFeaturesReply(salTableFeatures);
-                    salTableFeaturesAll.addAll(salTableFeaturesPartial);
+
+                    final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures>> salTableFeaturesPartial =
+                            ConvertorManager.getInstance().convert(salTableFeatures);
+
+                    if (salTableFeaturesPartial.isPresent()) {
+                        salTableFeaturesAll.addAll(salTableFeaturesPartial.get());
+                    }
+
                     LOG.debug("TableFeature {} for xid {}.", salTableFeatures, multipartReply.getXid());
                 }
             }
index ef84bd6807057ff1af6be4131214ee4158debade..e7ff5c4aaa3458bc4620c81a2b255418723f4ca0 100644 (file)
@@ -33,6 +33,7 @@ public class ConvertorManager {
         INSTANCE = new ConvertorManager();
         // All convertors are registered here
         INSTANCE.registerConvertor(new TableFeaturesConvertor());
+        INSTANCE.registerConvertor(new TableFeaturesResponseConvertor());
     }
 
     // Actual convertor keys
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright (c) 2013 Ericsson. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -15,7 +15,9 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
@@ -70,7 +72,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.instruction.container.instruction.choice.ExperimenterIdCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds;
 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.action.grouping.action.choice.CopyTtlInCase;
@@ -165,243 +166,219 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Utility class for converting a OF library table features to MD-SAL table
- * features.
+ * Converts a OF library table features into the MD-SAL library table features.
+ *
+ * Example usage:
+ * <pre>
+ * {@code
+ * Optional<List<TableFeatures>> salFeatures = ConvertorManager.getInstance().convert(ofTableFeatures);
+ * }
+ * </pre>
  */
-public class TableFeaturesReplyConvertor {
-    private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesReplyConvertor.class);
-
-    private TableFeaturesReplyConvertor() {
-        //hiding implicit constructor
-    }
-
-    private interface ActionExecutor {
-        public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder);
-    }
-
-    public static List<TableFeatures> toTableFeaturesReply(
-            final MultipartReplyTableFeatures ofTableFeaturesList) {
-        if (ofTableFeaturesList == null || ofTableFeaturesList.getTableFeatures() == null) {
-            return Collections.<TableFeatures>emptyList();
-        }
-        List<TableFeatures> salTableFeaturesList = new ArrayList<>();
-        TableFeaturesBuilder salTableFeatures = new TableFeaturesBuilder();
-        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.
-                multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures ofTableFeatures : ofTableFeaturesList
-                .getTableFeatures()) {
-            salTableFeatures.setTableId(ofTableFeatures.getTableId());
-            salTableFeatures.setName(ofTableFeatures.getName());
-            if (ofTableFeatures.getMetadataMatch() != null) {
-                salTableFeatures.setMetadataMatch(new BigInteger(OFConstants.SIGNUM_UNSIGNED, ofTableFeatures.getMetadataMatch()));
-            }
-            if (ofTableFeatures.getMetadataWrite() != null) {
-                salTableFeatures.setMetadataWrite(new BigInteger(OFConstants.SIGNUM_UNSIGNED, ofTableFeatures.getMetadataWrite()));
-            }
-            if (ofTableFeatures.getConfig() != null) {
-                salTableFeatures.setConfig(new TableConfig(ofTableFeatures.getConfig().isOFPTCDEPRECATEDMASK()));
-            }
-            salTableFeatures.setMaxEntries(ofTableFeatures.getMaxEntries());
-            salTableFeatures.setTableProperties(toTableProperties(ofTableFeatures.getTableFeatureProperties()));
-            salTableFeaturesList.add(salTableFeatures.build());
-        }
-        return salTableFeaturesList;
-    }
-
+public class TableFeaturesResponseConvertor implements Convertor<MultipartReplyTableFeatures, List<TableFeatures>> {
+    private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesResponseConvertor.class);
     private static final Map<TableFeaturesPropType, ActionExecutor> TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION;
+    private static final Map<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> OF_TO_SAL_ACTION;
+    private static final Map<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> OF_TO_SAL_TABLE_FEATURE_PROPERTIES;
 
     static {
         final Builder<TableFeaturesPropType, ActionExecutor> builder = ImmutableMap.builder();
 
-        builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder instructionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder();
-                instructionBuilder
-                        .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder()
-                                .setInstruction(setInstructionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(instructionBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder instructionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsBuilder();
+            instructionBuilder
+                    .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder()
+                            .setInstruction(setInstructionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(instructionBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder instructionMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder();
-                instructionMissBuilder
-                        .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder()
-                                .setInstruction(setInstructionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(instructionMissBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder instructionMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMissBuilder();
+            instructionMissBuilder
+                    .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder()
+                            .setInstruction(setInstructionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(instructionMissBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLES, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder nextTableBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder();
-                nextTableBuilder
-                        .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder()
-                                .setTableIds(setNextTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(nextTableBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLES, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder nextTableBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder();
+            nextTableBuilder
+                    .setTables(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder()
+                            .setTableIds(setNextTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(nextTableBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder nextTableMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder();
-                nextTableMissBuilder
-                        .setTablesMiss(new TablesMissBuilder()
-                                .setTableIds(setNextTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(nextTableMissBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder nextTableMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMissBuilder();
+            nextTableMissBuilder
+                    .setTablesMiss(new TablesMissBuilder()
+                            .setTableIds(setNextTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(nextTableMissBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder writeActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder();
-                writeActionsBuilder
-                        .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder()
-                                .setAction(setActionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(writeActionsBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder writeActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsBuilder();
+            writeActionsBuilder
+                    .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder()
+                            .setAction(setActionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(writeActionsBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder writeActionsMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder();
-                writeActionsMissBuilder
-                        .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder()
-                                .setAction(setActionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(writeActionsMissBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder writeActionsMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMissBuilder();
+            writeActionsMissBuilder
+                    .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder()
+                            .setAction(setActionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(writeActionsMissBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder applyActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder();
-                applyActionsBuilder
-                        .setApplyActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder()
-                                .setAction(setActionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(applyActionsBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder applyActionsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsBuilder();
+            applyActionsBuilder
+                    .setApplyActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder()
+                            .setAction(setActionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(applyActionsBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder applyActionsMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder();
-                applyActionsMissBuilder
-                        .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder()
-                                .setAction(setActionTableFeatureProperty(property)).build());
-                propBuilder.setTableFeaturePropType(applyActionsMissBuilder.build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, (property, propBuilder) -> {
+            org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder applyActionsMissBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMissBuilder();
+            applyActionsMissBuilder
+                    .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder()
+                            .setAction(setActionTableFeatureProperty(property)).build());
+            propBuilder.setTableFeaturePropType(applyActionsMissBuilder.build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTMATCH, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTMATCH, (property, propBuilder) -> {
+            MatchSetfieldBuilder matchBuilder = new MatchSetfieldBuilder();
 
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                MatchSetfieldBuilder matchBuilder = new MatchSetfieldBuilder();
-
-                matchBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, true));
-                propBuilder.setTableFeaturePropType(new MatchBuilder().setMatchSetfield(matchBuilder.build()).build());
-            }
+            matchBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, true));
+            propBuilder.setTableFeaturePropType(new MatchBuilder().setMatchSetfield(matchBuilder.build()).build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTWILDCARDS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                WildcardSetfieldBuilder wildcardsBuilder = new WildcardSetfieldBuilder();
-                wildcardsBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
-                propBuilder.setTableFeaturePropType(new WildcardsBuilder().setWildcardSetfield(wildcardsBuilder.build()).build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTWILDCARDS, (property, propBuilder) -> {
+            WildcardSetfieldBuilder wildcardsBuilder = new WildcardSetfieldBuilder();
+            wildcardsBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
+            propBuilder.setTableFeaturePropType(new WildcardsBuilder().setWildcardSetfield(wildcardsBuilder.build()).build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELD, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                WriteSetfieldBuilder writeSetfieldBuilder = new WriteSetfieldBuilder();
-                writeSetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
-                propBuilder.setTableFeaturePropType(new
-                        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder().setWriteSetfield(writeSetfieldBuilder.build()).build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELD, (property, propBuilder) -> {
+            WriteSetfieldBuilder writeSetfieldBuilder = new WriteSetfieldBuilder();
+            writeSetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
+            propBuilder.setTableFeaturePropType(new
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldBuilder().setWriteSetfield(writeSetfieldBuilder.build()).build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                WriteSetfieldMissBuilder writeSetfieldMissBuilder = new WriteSetfieldMissBuilder();
-                writeSetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
-                propBuilder.setTableFeaturePropType(new
-                        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder().setWriteSetfieldMiss(writeSetfieldMissBuilder.build()).build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, (property, propBuilder) -> {
+            WriteSetfieldMissBuilder writeSetfieldMissBuilder = new WriteSetfieldMissBuilder();
+            writeSetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
+            propBuilder.setTableFeaturePropType(new
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMissBuilder().setWriteSetfieldMiss(writeSetfieldMissBuilder.build()).build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                ApplySetfieldBuilder applySetfieldBuilder = new ApplySetfieldBuilder();
-                applySetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
-                propBuilder.setTableFeaturePropType(new
-                        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder().setApplySetfield(applySetfieldBuilder.build()).build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, (property, propBuilder) -> {
+            ApplySetfieldBuilder applySetfieldBuilder = new ApplySetfieldBuilder();
+            applySetfieldBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
+            propBuilder.setTableFeaturePropType(new
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder().setApplySetfield(applySetfieldBuilder.build()).build());
         });
-        builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, new ActionExecutor() {
-
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                ApplySetfieldMissBuilder applySetfieldMissBuilder = new ApplySetfieldMissBuilder();
-                applySetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
-                propBuilder.setTableFeaturePropType(new
-                        org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder().setApplySetfieldMiss(applySetfieldMissBuilder.build()).build());
-            }
+        builder.put(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, (property, propBuilder) -> {
+            ApplySetfieldMissBuilder applySetfieldMissBuilder = new ApplySetfieldMissBuilder();
+            applySetfieldMissBuilder.setSetFieldMatch(setSetFieldTableFeatureProperty(property, false));
+            propBuilder.setTableFeaturePropType(new
+                    org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMissBuilder().setApplySetfieldMiss(applySetfieldMissBuilder.build()).build());
         });
 
-        builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTER, new ActionExecutor() {
+        builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTER, (property, propBuilder) -> LOG.debug("Experimenter Table features is unhandled"));
 
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                LOG.debug("Experimenter Table features is unhandled");
-            }
-        });
+        builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, (property, propBuilder) -> LOG.debug("Experimenter miss Table features is unhandled"));
 
-        builder.put(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS, new ActionExecutor() {
+        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION = builder.build();
 
-            @Override
-            public void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder) {
-                LOG.debug("Experimenter miss Table features is unhandled");
-            }
-        });
+    }
 
-        TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION = builder.build();
+    static {
+        Builder<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> builder = ImmutableMap.builder();
 
+        builder.put(OutputActionCase.class, new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().build()).build());
+        builder.put(GroupCase.class, new GroupActionCaseBuilder().setGroupAction(new GroupActionBuilder().build()).build());
+        builder.put(CopyTtlOutCase.class, new CopyTtlOutCaseBuilder().setCopyTtlOut(new CopyTtlOutBuilder().build()).build());
+        builder.put(CopyTtlInCase.class, new CopyTtlInCaseBuilder().setCopyTtlIn(new CopyTtlInBuilder().build()).build());
+        builder.put(SetMplsTtlCase.class, new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(new SetMplsTtlActionBuilder().build()).build());
+        builder.put(DecMplsTtlCase.class, new DecMplsTtlCaseBuilder().setDecMplsTtl(new DecMplsTtlBuilder().build()).build());
+        builder.put(PushVlanCase.class, new PushVlanActionCaseBuilder().setPushVlanAction(new PushVlanActionBuilder().build()).build());
+        builder.put(PopVlanCase.class, new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build());
+        builder.put(PushMplsCase.class, new PushMplsActionCaseBuilder().setPushMplsAction(new PushMplsActionBuilder().build()).build());
+        builder.put(PopMplsCase.class, new PopMplsActionCaseBuilder().setPopMplsAction(new PopMplsActionBuilder().build()).build());
+        builder.put(SetQueueCase.class, new SetQueueActionCaseBuilder().setSetQueueAction(new SetQueueActionBuilder().build()).build());
+        builder.put(SetNwTtlCase.class, new SetNwTtlActionCaseBuilder().setSetNwTtlAction(new SetNwTtlActionBuilder().build()).build());
+        builder.put(DecNwTtlCase.class, new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build());
+        builder.put(SetFieldCase.class, new SetFieldCaseBuilder().setSetField(new SetFieldBuilder().build()).build());
+        builder.put(PushPbbCase.class, new PushPbbActionCaseBuilder().setPushPbbAction(new PushPbbActionBuilder().build()).build());
+        builder.put(PopPbbCase.class, new PopPbbActionCaseBuilder().setPopPbbAction(new PopPbbActionBuilder().build()).build());
+        builder.put(SetNwSrcCase.class, new SetNwSrcActionCaseBuilder().setSetNwSrcAction(new SetNwSrcActionBuilder().build()).build());
+        builder.put(SetNwDstCase.class, new SetNwDstActionCaseBuilder().setSetNwDstAction(new SetNwDstActionBuilder().build()).build());
+
+        OF_TO_SAL_ACTION = builder.build();
+    }
+
+    static {
+        final Builder<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> builder = ImmutableMap.builder();
+
+        builder.put(ArpOp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
+        builder.put(ArpSha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class);
+        builder.put(ArpSpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class);
+        builder.put(ArpTha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class);
+        builder.put(ArpTpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class);
+        builder.put(EthDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class);
+        builder.put(EthSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class);
+        builder.put(EthType.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class);
+        builder.put(Icmpv4Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class);
+        builder.put(Icmpv4Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class);
+        builder.put(Icmpv6Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class);
+        builder.put(Icmpv6Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class);
+        builder.put(InPhyPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class);
+        builder.put(InPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class);
+        builder.put(IpDscp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class);
+        builder.put(IpEcn.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class);
+        builder.put(IpProto.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class);
+        builder.put(Ipv4Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class);
+        builder.put(Ipv4Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class);
+        builder.put(Ipv6Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class);
+        builder.put(Ipv6Exthdr.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class);
+        builder.put(Ipv6Flabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class);
+        builder.put(Ipv6NdSll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class);
+        builder.put(Ipv6NdTarget.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class);
+        builder.put(Ipv6NdTll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class);
+        builder.put(Ipv6Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class);
+        builder.put(Metadata.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class);
+        builder.put(MplsBos.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class);
+        builder.put(MplsLabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class);
+        builder.put(MplsTc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class);
+        builder.put(PbbIsid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class);
+        builder.put(SctpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class);
+        builder.put(SctpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class);
+        builder.put(TcpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class);
+        builder.put(TcpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class);
+        builder.put(TunnelId.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class);
+        builder.put(UdpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
+        builder.put(UdpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class);
+        builder.put(VlanPcp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
+        builder.put(VlanVid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
+        builder.put(TcpFlags.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags.class);
+
+        OF_TO_SAL_TABLE_FEATURE_PROPERTIES = builder.build();
     }
 
     private static TableProperties toTableProperties(final List<TableFeatureProperties> ofTablePropertiesList) {
         if (ofTablePropertiesList == null) {
             return new TablePropertiesBuilder()
-                    .setTableFeatureProperties(
-                            Collections
-                                    .<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties>emptyList())
+                    .setTableFeatureProperties(Collections.emptyList())
                     .build();
         }
+
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties> salTablePropertiesList = new ArrayList<>();
         TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
         int index = 0;
+
         for (TableFeatureProperties property : ofTablePropertiesList) {
             TableFeaturesPropType propType = property.getType();
-
             ActionExecutor actionExecutor = TABLE_FEATURE_PROPERTY_TYPE_TO_ACTION.get(propType);
+
             if (actionExecutor != null) {
                 actionExecutor.execute(property, propBuilder);
             } else {
                 LOG.error("Unsupported table feature property : " + propType);
             }
-            propBuilder.setOrder(index);
 
+            propBuilder.setOrder(index);
             salTablePropertiesList.add(propBuilder.build());
             index += 1;
         }
@@ -412,8 +389,8 @@ public class TableFeaturesReplyConvertor {
     private static List<Instruction> setInstructionTableFeatureProperty(final TableFeatureProperties properties) {
         List<Instruction> instructionList = new ArrayList<>();
         org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder();
-
         int index = 0;
+
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731
                 .instructions.grouping.Instruction currInstruction : properties
                 .getAugmentation(InstructionRelatedTableFeatureProperty.class).getInstruction()) {
@@ -443,58 +420,28 @@ public class TableFeaturesReplyConvertor {
                 builder.setInstruction((new MeterCaseBuilder()
                         .setMeter(new MeterBuilder().build())
                         .build()));
-            } else if (currInstructionType instanceof ExperimenterIdCase) {
-                // TODO: Experimenter instructions are unhandled
             }
 
+            // TODO: Experimenter instructions are unhandled
             builder.setOrder(index);
             index += 1;
 
             instructionList.add(builder.build());
         }
+
         return instructionList;
     }
 
     private static List<Short> setNextTableFeatureProperty(final TableFeatureProperties properties) {
-        List<Short> nextTableIdsList = new ArrayList<>();
-        for (NextTableIds tableId : properties.getAugmentation(NextTableRelatedTableFeatureProperty.class)
-                .getNextTableIds()) {
-            nextTableIdsList.add(tableId.getTableId());
-        }
-        return nextTableIdsList;
-    }
-
-    private static final Map<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> OF_TO_SAL_ACTION;
-
-    static {
-        Builder<Class<?>, org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> builder = ImmutableMap.builder();
-
-        builder.put(OutputActionCase.class, new OutputActionCaseBuilder().setOutputAction(new OutputActionBuilder().build()).build());
-        builder.put(GroupCase.class, new GroupActionCaseBuilder().setGroupAction(new GroupActionBuilder().build()).build());
-        builder.put(CopyTtlOutCase.class, new CopyTtlOutCaseBuilder().setCopyTtlOut(new CopyTtlOutBuilder().build()).build());
-        builder.put(CopyTtlInCase.class, new CopyTtlInCaseBuilder().setCopyTtlIn(new CopyTtlInBuilder().build()).build());
-        builder.put(SetMplsTtlCase.class, new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(new SetMplsTtlActionBuilder().build()).build());
-        builder.put(DecMplsTtlCase.class, new DecMplsTtlCaseBuilder().setDecMplsTtl(new DecMplsTtlBuilder().build()).build());
-        builder.put(PushVlanCase.class, new PushVlanActionCaseBuilder().setPushVlanAction(new PushVlanActionBuilder().build()).build());
-        builder.put(PopVlanCase.class, new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build());
-        builder.put(PushMplsCase.class, new PushMplsActionCaseBuilder().setPushMplsAction(new PushMplsActionBuilder().build()).build());
-        builder.put(PopMplsCase.class, new PopMplsActionCaseBuilder().setPopMplsAction(new PopMplsActionBuilder().build()).build());
-        builder.put(SetQueueCase.class, new SetQueueActionCaseBuilder().setSetQueueAction(new SetQueueActionBuilder().build()).build());
-        builder.put(SetNwTtlCase.class, new SetNwTtlActionCaseBuilder().setSetNwTtlAction(new SetNwTtlActionBuilder().build()).build());
-        builder.put(DecNwTtlCase.class, new DecNwTtlCaseBuilder().setDecNwTtl(new DecNwTtlBuilder().build()).build());
-        builder.put(SetFieldCase.class, new SetFieldCaseBuilder().setSetField(new SetFieldBuilder().build()).build());
-        builder.put(PushPbbCase.class, new PushPbbActionCaseBuilder().setPushPbbAction(new PushPbbActionBuilder().build()).build());
-        builder.put(PopPbbCase.class, new PopPbbActionCaseBuilder().setPopPbbAction(new PopPbbActionBuilder().build()).build());
-        builder.put(SetNwSrcCase.class, new SetNwSrcActionCaseBuilder().setSetNwSrcAction(new SetNwSrcActionBuilder().build()).build());
-        builder.put(SetNwDstCase.class, new SetNwDstActionCaseBuilder().setSetNwDstAction(new SetNwDstActionBuilder().build()).build());
-
-        OF_TO_SAL_ACTION = builder.build();
+        return properties.getAugmentation(NextTableRelatedTableFeatureProperty.class)
+                .getNextTableIds().stream().map(NextTableIds::getTableId).collect(Collectors.toList());
     }
 
     private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> setActionTableFeatureProperty(
             final TableFeatureProperties properties) {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList = new ArrayList<>();
         int order = 0;
+
         for (Action action : properties
                 .getAugmentation(ActionRelatedTableFeatureProperty.class).getAction()) {
             if (action != null && null != action.getActionChoice()) {
@@ -508,57 +455,8 @@ public class TableFeaturesReplyConvertor {
                 actionList.add(actionBuilder.build());
             }
         }
-        return actionList;
-    }
 
-    private static final Map<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> OF_TO_SAL_TABLE_FEATURE_PROPERTIES;
-
-    static {
-        final Builder<Class<? extends MatchField>, Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>> builder = ImmutableMap.builder();
-
-        builder.put(ArpOp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
-        builder.put(ArpSha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class);
-        builder.put(ArpSpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class);
-        builder.put(ArpTha.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class);
-        builder.put(ArpTpa.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class);
-        builder.put(EthDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class);
-        builder.put(EthSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class);
-        builder.put(EthType.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class);
-        builder.put(Icmpv4Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class);
-        builder.put(Icmpv4Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class);
-        builder.put(Icmpv6Code.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class);
-        builder.put(Icmpv6Type.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class);
-        builder.put(InPhyPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class);
-        builder.put(InPort.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class);
-        builder.put(IpDscp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class);
-        builder.put(IpEcn.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class);
-        builder.put(IpProto.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class);
-        builder.put(Ipv4Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class);
-        builder.put(Ipv4Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class);
-        builder.put(Ipv6Dst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class);
-        builder.put(Ipv6Exthdr.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class);
-        builder.put(Ipv6Flabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class);
-        builder.put(Ipv6NdSll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class);
-        builder.put(Ipv6NdTarget.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class);
-        builder.put(Ipv6NdTll.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class);
-        builder.put(Ipv6Src.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class);
-        builder.put(Metadata.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class);
-        builder.put(MplsBos.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class);
-        builder.put(MplsLabel.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class);
-        builder.put(MplsTc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class);
-        builder.put(PbbIsid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class);
-        builder.put(SctpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class);
-        builder.put(SctpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class);
-        builder.put(TcpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class);
-        builder.put(TcpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class);
-        builder.put(TunnelId.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class);
-        builder.put(UdpDst.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
-        builder.put(UdpSrc.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class);
-        builder.put(VlanPcp.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
-        builder.put(VlanVid.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
-        builder.put(TcpFlags.class, org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags.class);
-
-        OF_TO_SAL_TABLE_FEATURE_PROPERTIES = builder.build();
+        return actionList;
     }
 
     private static List<SetFieldMatch> setSetFieldTableFeatureProperty(final TableFeatureProperties properties,
@@ -566,21 +464,63 @@ public class TableFeaturesReplyConvertor {
         List<SetFieldMatch> setFieldMatchList = new ArrayList<>();
         SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder();
 
-        Class<? extends MatchField> ofMatchField = null;
-
         // This handles only OpenflowBasicClass oxm class.
         for (MatchEntry currMatch : properties.getAugmentation(OxmRelatedTableFeatureProperty.class)
                 .getMatchEntry()) {
-            ofMatchField = currMatch.getOxmMatchField();
-            Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField> salMatchField = null;
-            setFieldMatchBuilder.setMatchType(salMatchField);
+            Class<? extends MatchField> ofMatchField = currMatch.getOxmMatchField();
+
             if (setHasMask) {
                 setFieldMatchBuilder.setHasMask(currMatch.isHasMask());
             }
+
             setFieldMatchBuilder.setMatchType(OF_TO_SAL_TABLE_FEATURE_PROPERTIES.get(ofMatchField));
             setFieldMatchList.add(setFieldMatchBuilder.build());
         }
+
         return setFieldMatchList;
     }
 
+    @Override
+    public Class<?> getType() {
+        return MultipartReplyTableFeatures.class;
+    }
+
+    @Override
+    public List<TableFeatures> convert(MultipartReplyTableFeatures source) {
+        if (source == null || source.getTableFeatures() == null) {
+            return Collections.emptyList();
+        }
+
+        List<TableFeatures> salTableFeaturesList = new ArrayList<>();
+        TableFeaturesBuilder salTableFeatures = new TableFeaturesBuilder();
+
+        for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.
+                multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures ofTableFeatures : source
+                .getTableFeatures()) {
+            salTableFeatures.setTableId(ofTableFeatures.getTableId());
+            salTableFeatures.setName(ofTableFeatures.getName());
+
+            if (ofTableFeatures.getMetadataMatch() != null) {
+                salTableFeatures.setMetadataMatch(new BigInteger(OFConstants.SIGNUM_UNSIGNED, ofTableFeatures.getMetadataMatch()));
+            }
+
+            if (ofTableFeatures.getMetadataWrite() != null) {
+                salTableFeatures.setMetadataWrite(new BigInteger(OFConstants.SIGNUM_UNSIGNED, ofTableFeatures.getMetadataWrite()));
+            }
+
+            if (ofTableFeatures.getConfig() != null) {
+                salTableFeatures.setConfig(new TableConfig(ofTableFeatures.getConfig().isOFPTCDEPRECATEDMASK()));
+            }
+
+            salTableFeatures.setMaxEntries(ofTableFeatures.getMaxEntries());
+            salTableFeatures.setTableProperties(toTableProperties(ofTableFeatures.getTableFeatureProperties()));
+            salTableFeaturesList.add(salTableFeatures.build());
+        }
+
+        return salTableFeaturesList;
+    }
+
+    private interface ActionExecutor {
+        void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder);
+    }
 }
index 820cc73efc487ffbc11ec1df01f49eb34cbc6492..6ffe053519af534b38bab6aa5832b97e3457832a 100644 (file)
@@ -11,11 +11,12 @@ package org.opendaylight.openflowplugin.openflow.md.core.translator;
 import java.math.BigInteger;
 import java.util.Collections;
 import java.util.List;
+import java.util.Optional;
 import java.util.concurrent.CopyOnWriteArrayList;
 import org.opendaylight.openflowplugin.api.openflow.md.core.IMDMessageTranslator;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.TableFeaturesReplyConvertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
@@ -26,26 +27,24 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.TableUpdatedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class MultipartReplyTableFeaturesToTableUpdatedTranslator implements
-               IMDMessageTranslator<OfHeader, List<DataObject>> {
+        IMDMessageTranslator<OfHeader, List<DataObject>> {
 
     private static final Logger LOG = LoggerFactory
             .getLogger(MultipartReplyTableFeaturesToTableUpdatedTranslator.class);
 
-       @Override
-       public List<DataObject> translate(SwitchConnectionDistinguisher cookie,
-                       SessionContext sc, OfHeader msg) {
-
-
+    @Override
+    public List<DataObject> translate(SwitchConnectionDistinguisher cookie, SessionContext sc, OfHeader msg) {
         if (msg instanceof MultipartReply && ((MultipartReply) msg).getType() == MultipartType.OFPMPTABLEFEATURES) {
             LOG.debug("MultipartReply Being translated to TableUpdated ");
             MultipartReplyMessage mpReply = (MultipartReplyMessage) msg;
 
-            List<DataObject> listDataObject = new CopyOnWriteArrayList<DataObject>();
+            List<DataObject> listDataObject = new CopyOnWriteArrayList<>();
 
             TableUpdatedBuilder message = new TableUpdatedBuilder() ;
             message.setNode((new NodeRef(InventoryDataServiceUtil.identifierFromDatapathId(sc.getFeatures()
@@ -54,7 +53,9 @@ public class MultipartReplyTableFeaturesToTableUpdatedTranslator implements
             message.setTransactionId(new TransactionId(BigInteger.valueOf(mpReply.getXid())));
             MultipartReplyTableFeaturesCase caseBody = (MultipartReplyTableFeaturesCase) mpReply.getMultipartReplyBody();
             MultipartReplyTableFeatures body = caseBody.getMultipartReplyTableFeatures();
-            message.setTableFeatures(TableFeaturesReplyConvertor.toTableFeaturesReply(body)) ;
+
+            final Optional<List<TableFeatures>> tableFeaturesList = ConvertorManager.getInstance().convert(body);
+            message.setTableFeatures(tableFeaturesList.orElse(Collections.emptyList()));
             listDataObject.add( message.build()) ;
 
             return listDataObject ;
@@ -64,5 +65,4 @@ public class MultipartReplyTableFeaturesToTableUpdatedTranslator implements
 
     }
 
-}
-
+}
\ No newline at end of file
@@ -10,7 +10,9 @@ package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
 \r
 import java.math.BigInteger;\r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
 import java.util.List;\r
+import java.util.Optional;\r
 import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
@@ -83,6 +85,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Vlan
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;\r
@@ -103,14 +106,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 /**\r
  * @author michal.polkorab\r
  */\r
-public class TableFeaturesReplyConvertorTest {\r
+public class TableFeaturesResponseConvertorTest {\r
 \r
     /**\r
      * Incorrect / empty input test\r
      */\r
     @Test\r
     public void test() {\r
-        List<TableFeatures> list = TableFeaturesReplyConvertor.toTableFeaturesReply(null);\r
+        List<TableFeatures> list = convert(null);\r
         Assert.assertEquals("Returned list is not empty", 0, list.size());\r
     }\r
 \r
@@ -120,7 +123,7 @@ public class TableFeaturesReplyConvertorTest {
     @Test\r
     public void test2() {\r
         MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();\r
-        List<TableFeatures> list = TableFeaturesReplyConvertor.toTableFeaturesReply(builder.build());\r
+        List<TableFeatures> list = convert(builder.build());\r
         Assert.assertEquals("Returned list is not empty", 0, list.size());\r
     }\r
 \r
@@ -144,7 +147,7 @@ public class TableFeaturesReplyConvertorTest {
         featuresBuilder.setMaxEntries(42L);\r
         features.add(featuresBuilder.build());\r
         builder.setTableFeatures(features);\r
-        List<TableFeatures> list = TableFeaturesReplyConvertor.toTableFeaturesReply(builder.build());\r
+        List<TableFeatures> list = convert(builder.build());\r
         Assert.assertEquals("Returned empty list", 1, list.size());\r
         TableFeatures feature = list.get(0);\r
         Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue());\r
@@ -500,11 +503,30 @@ public class TableFeaturesReplyConvertorTest {
 \r
         propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());\r
         properties.add(propBuilder.build());\r
+\r
+        /* -------------------------------------------------- */\r
+\r
+        propBuilder = new TableFeaturePropertiesBuilder();\r
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);\r
+        oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
+        propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
+        properties.add(propBuilder.build());\r
+\r
+        /* -------------------------------------------------- */\r
+\r
+        propBuilder = new TableFeaturePropertiesBuilder();\r
+        propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);\r
+        oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
+        propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
+        properties.add(propBuilder.build());\r
+\r
+        /* -------------------------------------------------- */\r
+\r
         featuresBuilder.setTableFeatureProperties(properties);\r
         features.add(featuresBuilder.build());\r
         builder.setTableFeatures(features);\r
 \r
-        List<TableFeatures> list = TableFeaturesReplyConvertor.toTableFeaturesReply(builder.build());\r
+        List<TableFeatures> list = convert(builder.build());\r
 \r
         Assert.assertEquals("Returned empty list", 2, list.size());\r
         TableFeatures feature = list.get(0);\r
@@ -567,7 +589,7 @@ public class TableFeaturesReplyConvertorTest {
         Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite2), feature.getMetadataWrite());\r
         Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());\r
         Assert.assertEquals("Wrong max-entries", 24, feature.getMaxEntries().intValue());\r
-        Assert.assertEquals("Wrong properties", 10, feature.getTableProperties().getTableFeatureProperties().size());\r
+        Assert.assertEquals("Wrong properties", 12, feature.getTableProperties().getTableFeatureProperties().size());\r
         property = feature.getTableProperties().getTableFeatureProperties().get(0);\r
         Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match",\r
                 property.getTableFeaturePropType().getImplementedInterface().getName());\r
@@ -763,4 +785,9 @@ public class TableFeaturesReplyConvertorTest {
         return setFieldCaseBuilder.build();\r
     }\r
 \r
-}
+\r
+    private List<TableFeatures> convert(MultipartReplyTableFeatures features) {\r
+        Optional<List<TableFeatures>> listOptional = ConvertorManager.getInstance().convert(features);\r
+        return listOptional.orElse(Collections.emptyList());\r
+    }\r
+}
\ No newline at end of file