Bump MRI upstreams
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / TableFeaturesConvertor.java
index f508f02d9fe1562f3bd5fab3c5eccfc5d38858fb..397f86149c6537564d716d9414b62ee89331381a 100644 (file)
@@ -13,7 +13,6 @@ import com.google.common.collect.Ordering;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
@@ -42,17 +41,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.approved.extensions.rev160802.TcpFlags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder;
-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.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.next.table.related.table.feature.property.NextTableIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.next.table.related.table.feature.property.NextTableIdsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder;
@@ -129,6 +125,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss;
@@ -243,14 +241,14 @@ public class TableFeaturesConvertor extends Convertor<
             final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features
                 .TableProperties tableProperties) {
         if (tableProperties == null) {
-            return Collections.emptyList();
+            return List.of();
         }
 
         List<TableFeatureProperties> ofTablePropertiesList = new ArrayList<>();
 
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table
             .properties.TableFeatureProperties> sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(
-                    tableProperties.getTableFeatureProperties());
+                    tableProperties.nonnullTableFeatureProperties().values());
 
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table
                 .properties.TableFeatureProperties property : sortedTableProperties) {
@@ -304,107 +302,95 @@ public class TableFeaturesConvertor extends Convertor<
 
     private static void setTableFeatureProperty(final ApplySetfieldMiss propType,
             final TableFeaturePropertiesBuilder propBuilder) {
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
-            setFieldMatch = null;
+        Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
             .type.apply.setfield.miss.ApplySetfieldMiss applySetfieldMiss = propType.getApplySetfieldMiss();
 
         if (null != applySetfieldMiss) {
-            setFieldMatch = applySetfieldMiss.getSetFieldMatch();
+            setFieldMatch = applySetfieldMiss.nonnullSetFieldMatch();
         }
 
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS,
-                setFieldMatch == null ? new ArrayList<>()
-                        : setFieldMatch);
+                setFieldMatch == null ? Map.of() : setFieldMatch);
     }
 
     private static void setTableFeatureProperty(final ApplySetfield propType,
             final TableFeaturePropertiesBuilder propBuilder) {
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
-            setFieldMatch = null;
+        Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
             .type.apply.setfield.ApplySetfield applySetfield = propType.getApplySetfield();
 
         if (null != applySetfield) {
-            setFieldMatch = applySetfield.getSetFieldMatch();
+            setFieldMatch = applySetfield.nonnullSetFieldMatch();
         }
 
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTAPPLYSETFIELD,
-                setFieldMatch == null ? new ArrayList<>()
-                        : setFieldMatch);
+                setFieldMatch == null ? Map.of() : setFieldMatch);
     }
 
     private static void setTableFeatureProperty(final WriteSetfieldMiss propType,
             final TableFeaturePropertiesBuilder propBuilder) {
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
-            setFieldMatch = null;
+        Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
             .type.write.setfield.miss.WriteSetfieldMiss writeSetfieldMiss = propType.getWriteSetfieldMiss();
 
         if (null != writeSetfieldMiss) {
-            setFieldMatch = writeSetfieldMiss.getSetFieldMatch();
+            setFieldMatch = writeSetfieldMiss.nonnullSetFieldMatch();
         }
 
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS,
-                setFieldMatch == null ? new ArrayList<>()
-                        : setFieldMatch);
+                setFieldMatch == null ? Map.of() : setFieldMatch);
     }
 
     private static void setTableFeatureProperty(final WriteSetfield propType,
             final TableFeaturePropertiesBuilder propBuilder) {
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
-            setFieldMatch = null;
+        Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
             .type.write.setfield.WriteSetfield writeSetField = propType.getWriteSetfield();
 
         if (null != writeSetField) {
-            setFieldMatch = writeSetField.getSetFieldMatch();
+            setFieldMatch = writeSetField.nonnullSetFieldMatch();
         }
 
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTWRITESETFIELD,
-                setFieldMatch == null ? new ArrayList<>()
-                        : setFieldMatch);
+                setFieldMatch == null ? Map.of() : setFieldMatch);
     }
 
     private static void setTableFeatureProperty(final Wildcards propType,
             final TableFeaturePropertiesBuilder propBuilder) {
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
-            setFieldMatch = null;
+        Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
         WildcardSetfield wildcardSetField = propType.getWildcardSetfield();
 
         if (null != wildcardSetField) {
-            setFieldMatch = wildcardSetField.getSetFieldMatch();
+            setFieldMatch = wildcardSetField.nonnullSetFieldMatch();
         }
 
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTWILDCARDS,
-                setFieldMatch == null ? new ArrayList<>()
-                        : setFieldMatch);
+                setFieldMatch == null ? Map.of() : setFieldMatch);
     }
 
     private static void setTableFeatureProperty(final Match propType, final TableFeaturePropertiesBuilder propBuilder) {
         MatchSetfield matchSetField = propType.getMatchSetfield();
-        List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch>
-            setFieldMatch = null;
+        Map<SetFieldMatchKey, SetFieldMatch> setFieldMatch = null;
 
         if (null != matchSetField) {
-            setFieldMatch = matchSetField.getSetFieldMatch();
+            setFieldMatch = matchSetField.nonnullSetFieldMatch();
         }
 
         setSetFieldTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTMATCH,
-                setFieldMatch == null ? new ArrayList<>()
-                        : setFieldMatch);
+                setFieldMatch == null ? Map.of() : setFieldMatch);
     }
 
     private static void setTableFeatureProperty(final ApplyActionsMiss propType,
@@ -414,8 +400,7 @@ public class TableFeaturesConvertor extends Convertor<
         setActionTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS,
-                applyActionsMiss == null ? new ArrayList<>()
-                        : applyActionsMiss.getAction());
+                applyActionsMiss == null ? Map.of() : applyActionsMiss.nonnullAction());
     }
 
     private static void setTableFeatureProperty(final ApplyActions propType,
@@ -425,8 +410,7 @@ public class TableFeaturesConvertor extends Convertor<
         setActionTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTAPPLYACTIONS,
-                applyActions == null ? new ArrayList<>()
-                        : applyActions.getAction());
+                applyActions == null ? Map.of() : applyActions.nonnullAction());
     }
 
     private static void setTableFeatureProperty(final WriteActionsMiss propType,
@@ -436,8 +420,7 @@ public class TableFeaturesConvertor extends Convertor<
         setActionTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS,
-                writeActionsMiss == null ? new ArrayList<>()
-                        : writeActionsMiss.getAction());
+                writeActionsMiss == null ? Map.of() : writeActionsMiss.nonnullAction());
     }
 
     private static void setTableFeatureProperty(final WriteActions propType,
@@ -447,8 +430,7 @@ public class TableFeaturesConvertor extends Convertor<
         setActionTableFeatureProperty(
                 propBuilder,
                 TableFeaturesPropType.OFPTFPTWRITEACTIONS,
-                writeActions == null ? new ArrayList<>()
-                        : writeActions.getAction());
+                writeActions == null ? Map.of() : writeActions.nonnullAction());
     }
 
     private static void setTableFeatureProperty(final NextTableMiss propType,
@@ -471,7 +453,7 @@ public class TableFeaturesConvertor extends Convertor<
         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
             .type.instructions.miss.InstructionsMiss instructions = propType.getInstructionsMiss();
         setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS,
-                instructions == null ? new ArrayList<>() : instructions.getInstruction());
+                instructions == null ? Map.of() : instructions.nonnullInstruction());
     }
 
     private static void setTableFeatureProperty(final Instructions propType,
@@ -479,15 +461,15 @@ public class TableFeaturesConvertor extends Convertor<
         org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
             .type.instructions.Instructions instructions = propType.getInstructions();
         setInstructionTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTINSTRUCTIONS,
-                instructions == null ? new ArrayList<>() : instructions.getInstruction());
+                instructions == null ? Map.of() : instructions.nonnullInstruction());
     }
 
     private static void setInstructionTableFeatureProperty(final TableFeaturePropertiesBuilder builder,
-            final TableFeaturesPropType type, final List<Instruction> instructionList) {
+            final TableFeaturesPropType type, final Map<InstructionKey, Instruction> instructionList) {
         List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping
-            .Instruction> instructionTypeList = new ArrayList<>();
+            .Instruction> instructionTypeList = new ArrayList<>(instructionList.size());
 
-        for (Instruction currInstruction : instructionList) {
+        for (Instruction currInstruction : instructionList.values()) {
             InstructionBuilder instructionType = new InstructionBuilder();
 
             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction instruction =
@@ -520,7 +502,7 @@ public class TableFeaturesConvertor extends Convertor<
         InstructionRelatedTableFeaturePropertyBuilder propBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
         propBuilder.setInstruction(instructionTypeList);
         builder.setType(type);
-        builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, propBuilder.build());
+        builder.addAugmentation(propBuilder.build());
     }
 
     private static void setNextTableFeatureProperty(final TableFeaturePropertiesBuilder builder,
@@ -528,26 +510,24 @@ public class TableFeaturesConvertor extends Convertor<
         List<NextTableIds> nextTableIdsList = new ArrayList<>();
 
         for (Uint8 tableId : tableIds) {
-            NextTableIdsBuilder nextTableId = new NextTableIdsBuilder();
-            nextTableId.setTableId(tableId);
-            nextTableIdsList.add(nextTableId.build());
+            nextTableIdsList.add(new NextTableIdsBuilder().setTableId(tableId).build());
         }
 
-        NextTableRelatedTableFeaturePropertyBuilder propBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
-        propBuilder.setNextTableIds(nextTableIdsList);
-        builder.setType(type);
-        builder.addAugmentation(NextTableRelatedTableFeatureProperty.class, propBuilder.build());
+        builder.setType(type).addAugmentation(new NextTableRelatedTableFeaturePropertyBuilder()
+            .setNextTableIds(nextTableIdsList)
+            .build());
     }
 
     private static void setActionTableFeatureProperty(final TableFeaturePropertiesBuilder builder,
             final TableFeaturesPropType type,
-            final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
-                salActions) {
+            final Map<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey,
+                      org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
+                  salActions) {
 
-        List<Action> actionList = new ArrayList<>();
+        List<Action> actionList = new ArrayList<>(salActions.size());
 
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action currAction :
-                salActions) {
+                salActions.values()) {
             org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionType = currAction
                     .getAction();
             ActionBuilder actionBuilder = new ActionBuilder();
@@ -609,31 +589,28 @@ public class TableFeaturesConvertor extends Convertor<
         ActionRelatedTableFeaturePropertyBuilder propBuilder = new ActionRelatedTableFeaturePropertyBuilder();
         propBuilder.setAction(actionList);
         builder.setType(type);
-        builder.addAugmentation(ActionRelatedTableFeatureProperty.class, propBuilder.build());
+        builder.addAugmentation(propBuilder.build());
     }
 
     private static void setSetFieldTableFeatureProperty(
             final TableFeaturePropertiesBuilder builder,
             final TableFeaturesPropType type,
-            final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match
-                .SetFieldMatch> setFields) {
+            final Map<SetFieldMatchKey, SetFieldMatch> setFields) {
         List<MatchEntry> matchEntriesList = new ArrayList<>();
 
-        for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch
-                currMatch : setFields) {
+        for (SetFieldMatch currMatch : setFields.values()) {
             Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField>
                 currMatchType = currMatch.getMatchType();
             MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
             Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>
                 ofTableFeatureClass = SAL_TO_OF_TABLE_FEATURES.get(currMatchType);
-            setMatchEntry(matchEntryBuilder, ofTableFeatureClass, currMatch.isHasMask());
+            setMatchEntry(matchEntryBuilder, ofTableFeatureClass, currMatch.getHasMask());
             matchEntriesList.add(matchEntryBuilder.build());
         }
 
-        OxmRelatedTableFeaturePropertyBuilder propBuilder = new OxmRelatedTableFeaturePropertyBuilder();
-        propBuilder.setMatchEntry(matchEntriesList);
-        builder.setType(type);
-        builder.addAugmentation(OxmRelatedTableFeatureProperty.class, propBuilder.build());
+        builder.setType(type).addAugmentation(new OxmRelatedTableFeaturePropertyBuilder()
+            .setMatchEntry(matchEntriesList)
+            .build());
     }
 
     private static void setMatchEntry(final MatchEntryBuilder builder,
@@ -661,7 +638,7 @@ public class TableFeaturesConvertor extends Convertor<
         TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder();
 
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures
-                salTableFeatures : source.getTableFeatures()) {
+                salTableFeatures : source.nonnullTableFeatures().values()) {
             ofTableFeatures.setTableId(salTableFeatures.getTableId());
             ofTableFeatures.setName(salTableFeatures.getName());
             ofTableFeatures.setMetadataMatch(salTableFeatures.getMetadataMatch());
@@ -669,7 +646,7 @@ public class TableFeaturesConvertor extends Convertor<
             ofTableFeatures.setMaxEntries(salTableFeatures.getMaxEntries());
 
             if (salTableFeatures.getConfig() != null) {
-                ofTableFeatures.setConfig(new TableConfig(salTableFeatures.getConfig().isDEPRECATEDMASK()));
+                ofTableFeatures.setConfig(new TableConfig(salTableFeatures.getConfig().getDEPRECATEDMASK()));
             }
 
             ofTableFeatures.setTableFeatureProperties(toTableProperties(salTableFeatures.getTableProperties()));