X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fopenflow%2Fmd%2Fcore%2Fsal%2Fconvertor%2FTableFeaturesConvertor.java;h=5ab27a60d484c9e551a94f2b20a81312451d17eb;hb=59bf5b768c4bcc0a7d25101e8b25d82e5af4be38;hp=9ca8b5011ec83ea802668d7f8a8cd89cc21786d7;hpb=cd8d0c216c60b97e24430d16bf9ec836c3aaf3c1;p=openflowplugin.git diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java index 9ca8b5011e..5ab27a60d4 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/TableFeaturesConvertor.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor; import com.google.common.collect.ImmutableMap; @@ -43,17 +42,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; @@ -130,6 +126,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; @@ -148,12 +146,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.match.MatchSetfield; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.miss.TablesMiss; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfield; +import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Converts a MD-SAL table features into the OF library table features. * + *
* Example usage: *
* {@code @@ -168,13 +168,17 @@ public class TableFeaturesConvertor extends Convertor< VersionConvertorData> { private static final Logger LOG = LoggerFactory.getLogger(TableFeaturesConvertor.class); - private static final OrderingTABLE_FEATURE_PROPS_ORDERING = - Ordering.from(OrderComparator. build()); - private static final Map , Class extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> SAL_TO_OF_TABLE_FEATURES; - private static final List > TYPES = Arrays.asList(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures.class, UpdatedTable.class); + private static final Ordering TABLE_FEATURE_PROPS_ORDERING = + Ordering.from(OrderComparator.build()); + private static final Map , Class extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm + .rev150225.MatchField>> SAL_TO_OF_TABLE_FEATURES; + private static final List > TYPES = Arrays.asList(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types + .rev131026.TableFeatures.class, UpdatedTable.class); static { - Builder , Class extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField>> builder = ImmutableMap.builder(); + Builder , Class extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm + .rev150225.MatchField>> builder = ImmutableMap.builder(); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class, ArpOp.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class, ArpSha.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class, ArpSpa.class); @@ -183,11 +187,16 @@ public class TableFeaturesConvertor extends Convertor< builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class, EthDst.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class, EthSrc.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class, EthType.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class, Icmpv4Code.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class, Icmpv4Type.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class, Icmpv6Code.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class, Icmpv6Type.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class, InPhyPort.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class, + Icmpv4Code.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class, + Icmpv4Type.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class, + Icmpv6Code.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class, + Icmpv6Type.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class, + InPhyPort.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class, InPort.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class, IpDscp.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class, IpEcn.class); @@ -195,15 +204,21 @@ public class TableFeaturesConvertor extends Convertor< builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class, Ipv4Dst.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class, Ipv4Src.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class, Ipv6Dst.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class, Ipv6Exthdr.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class, Ipv6Flabel.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class, Ipv6NdSll.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class, Ipv6NdTarget.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class, Ipv6NdTll.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class, + Ipv6Exthdr.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class, + Ipv6Flabel.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class, + Ipv6NdSll.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class, + Ipv6NdTarget.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class, + Ipv6NdTll.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class, Ipv6Src.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class, Metadata.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class, MplsBos.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class, MplsLabel.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class, + MplsLabel.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class, MplsTc.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class, PbbIsid.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class, SctpDst.class); @@ -215,29 +230,33 @@ public class TableFeaturesConvertor extends Convertor< builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc.class, UdpSrc.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class, VlanPcp.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class, VlanVid.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class, Ipv4Dst.class); - builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class, Ipv4Src.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class, + Ipv4Dst.class); + builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class, + Ipv4Src.class); builder.put(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags.class, TcpFlags.class); SAL_TO_OF_TABLE_FEATURES = builder.build(); } private static List toTableProperties( - final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties tableProperties) { + final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features + .TableProperties tableProperties) { if (tableProperties == null) { return Collections.emptyList(); } List ofTablePropertiesList = new ArrayList<>(); - List - sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy(tableProperties.getTableFeatureProperties()); + List sortedTableProperties = TABLE_FEATURE_PROPS_ORDERING.sortedCopy( + tableProperties.nonnullTableFeatureProperties().values()); - for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties - property : sortedTableProperties) { + for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table + .properties.TableFeatureProperties property : sortedTableProperties) { TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); - org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.TableFeaturePropType propType = property - .getTableFeaturePropType(); + org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type + .TableFeaturePropType propType = property.getTableFeaturePropType(); setTableFeatureProperty(propType); @@ -282,170 +301,180 @@ public class TableFeaturesConvertor extends Convertor< LOG.debug("Unknown TableFeaturePropType [{}]", propType.getClass()); } - private static void setTableFeatureProperty(final ApplySetfieldMiss propType, final TableFeaturePropertiesBuilder propBuilder) { - List 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(); + private static void setTableFeatureProperty(final ApplySetfieldMiss propType, + final TableFeaturePropertiesBuilder propBuilder) { + Map 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 ? Collections.emptyMap() : setFieldMatch); } - private static void setTableFeatureProperty(final ApplySetfield propType, final TableFeaturePropertiesBuilder propBuilder) { - List 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(); + private static void setTableFeatureProperty(final ApplySetfield propType, + final TableFeaturePropertiesBuilder propBuilder) { + Map 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 ? Collections.emptyMap() : setFieldMatch); } - private static void setTableFeatureProperty(final WriteSetfieldMiss propType, final TableFeaturePropertiesBuilder propBuilder) { - List 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(); + private static void setTableFeatureProperty(final WriteSetfieldMiss propType, + final TableFeaturePropertiesBuilder propBuilder) { + Map 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 ? Collections.emptyMap() : setFieldMatch); } - private static void setTableFeatureProperty(final WriteSetfield propType, final TableFeaturePropertiesBuilder propBuilder) { - List 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(); + private static void setTableFeatureProperty(final WriteSetfield propType, + final TableFeaturePropertiesBuilder propBuilder) { + Map 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 ? Collections.emptyMap() : setFieldMatch); } - private static void setTableFeatureProperty(final Wildcards propType, final TableFeaturePropertiesBuilder propBuilder) { - List setFieldMatch = null; + private static void setTableFeatureProperty(final Wildcards propType, + final TableFeaturePropertiesBuilder propBuilder) { + Map 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 ? Collections.emptyMap() : setFieldMatch); } private static void setTableFeatureProperty(final Match propType, final TableFeaturePropertiesBuilder propBuilder) { MatchSetfield matchSetField = propType.getMatchSetfield(); - List setFieldMatch = null; + Map setFieldMatch = null; if (null != matchSetField) { - setFieldMatch = matchSetField.getSetFieldMatch(); + setFieldMatch = matchSetField.nonnullSetFieldMatch(); } setSetFieldTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTMATCH, - ((setFieldMatch == null) ? new ArrayList<>() - : setFieldMatch)); + setFieldMatch == null ? Collections.emptyMap() : setFieldMatch); } - private static void setTableFeatureProperty(final ApplyActionsMiss propType, final TableFeaturePropertiesBuilder propBuilder) { - org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMiss applyActionsMiss = propType - .getApplyActionsMiss(); + private static void setTableFeatureProperty(final ApplyActionsMiss propType, + final TableFeaturePropertiesBuilder propBuilder) { + org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop + .type.apply.actions.miss.ApplyActionsMiss applyActionsMiss = propType.getApplyActionsMiss(); setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, - ((applyActionsMiss == null) ? new ArrayList<>() - : applyActionsMiss.getAction())); + applyActionsMiss == null ? Collections.emptyMap() : applyActionsMiss.nonnullAction()); } - private static void setTableFeatureProperty(final ApplyActions propType, final TableFeaturePropertiesBuilder propBuilder) { - org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActions applyActions = propType.getApplyActions(); + private static void setTableFeatureProperty(final ApplyActions propType, + final TableFeaturePropertiesBuilder propBuilder) { + org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop + .type.apply.actions.ApplyActions applyActions = propType.getApplyActions(); setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTAPPLYACTIONS, - ((applyActions == null) ? new ArrayList<>() - : applyActions.getAction())); + applyActions == null ? Collections.emptyMap() : applyActions.nonnullAction()); } - private static void setTableFeatureProperty(final WriteActionsMiss propType, final TableFeaturePropertiesBuilder propBuilder) { - org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMiss writeActionsMiss = propType.getWriteActionsMiss(); + private static void setTableFeatureProperty(final WriteActionsMiss propType, + final TableFeaturePropertiesBuilder propBuilder) { + org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop + .type.write.actions.miss.WriteActionsMiss writeActionsMiss = propType.getWriteActionsMiss(); setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, - ((writeActionsMiss == null) ? new ArrayList<>() - : writeActionsMiss.getAction())); + writeActionsMiss == null ? Collections.emptyMap() : writeActionsMiss.nonnullAction()); } - private static void setTableFeatureProperty(final WriteActions propType, final TableFeaturePropertiesBuilder propBuilder) { - org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActions writeActions = propType.getWriteActions(); + private static void setTableFeatureProperty(final WriteActions propType, + final TableFeaturePropertiesBuilder propBuilder) { + org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop + .type.write.actions.WriteActions writeActions = propType.getWriteActions(); setActionTableFeatureProperty( propBuilder, TableFeaturesPropType.OFPTFPTWRITEACTIONS, - ((writeActions == null) ? new ArrayList<>() - : writeActions.getAction())); + writeActions == null ? Collections.emptyMap() : writeActions.nonnullAction()); } - private static void setTableFeatureProperty(final NextTableMiss propType, final TableFeaturePropertiesBuilder propBuilder) { - TablesMiss tables = propType - .getTablesMiss(); + private static void setTableFeatureProperty(final NextTableMiss propType, + final TableFeaturePropertiesBuilder propBuilder) { + TablesMiss tables = propType.getTablesMiss(); setNextTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, - (tables == null) ? new ArrayList<>() : tables.getTableIds()); + tables == null ? new ArrayList<>() : tables.getTableIds()); } - private static void setTableFeatureProperty(final NextTable propType, final TableFeaturePropertiesBuilder propBuilder) { - org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.Tables tables = propType - .getTables(); + private static void setTableFeatureProperty(final NextTable propType, + final TableFeaturePropertiesBuilder propBuilder) { + org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop + .type.next.table.Tables tables = propType.getTables(); setNextTableFeatureProperty(propBuilder, TableFeaturesPropType.OFPTFPTNEXTTABLES, - (tables == null) ? new ArrayList<>() : tables.getTableIds()); + tables == null ? new ArrayList<>() : tables.getTableIds()); } - private static void setTableFeatureProperty(final InstructionsMiss propType, final TableFeaturePropertiesBuilder propBuilder) { - org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMiss instructions = propType - .getInstructionsMiss(); + private static void setTableFeatureProperty(final InstructionsMiss propType, + final TableFeaturePropertiesBuilder propBuilder) { + 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 ? Collections.emptyMap() : instructions.nonnullInstruction()); } - private static void setTableFeatureProperty(final Instructions propType, final TableFeaturePropertiesBuilder propBuilder) { - org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.Instructions instructions = propType - .getInstructions(); + private static void setTableFeatureProperty(final Instructions propType, + final TableFeaturePropertiesBuilder propBuilder) { + 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 ? Collections.emptyMap() : instructions.nonnullInstruction()); } private static void setInstructionTableFeatureProperty(final TableFeaturePropertiesBuilder builder, - final TableFeaturesPropType type, final List instructionList) { - List instructionTypeList = new ArrayList<>(); + final TableFeaturesPropType type, final Map instructionList) { + List 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 = currInstruction - .getInstruction(); + org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction instruction = + currInstruction.getInstruction(); if (instruction instanceof GoToTableCase) { GotoTableCaseBuilder goToTableCaseBuilder = new GotoTableCaseBuilder(); @@ -474,32 +503,34 @@ 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, final TableFeaturesPropType type, - final List tableIds) { + private static void setNextTableFeatureProperty(final TableFeaturePropertiesBuilder builder, + final TableFeaturesPropType type, final List tableIds) { List nextTableIdsList = new ArrayList<>(); - for (Short tableId : tableIds) { + for (Uint8 tableId : tableIds) { NextTableIdsBuilder nextTableId = new NextTableIdsBuilder(); nextTableId.setTableId(tableId); nextTableIdsList.add(nextTableId.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 salActions) { + final TableFeaturesPropType type, + final Map + salActions) { - List actionList = new ArrayList<>(); + List actionList = new ArrayList<>(salActions.size()); - for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action currAction : salActions) { + for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action currAction : + salActions.values()) { org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionType = currAction .getAction(); ActionBuilder actionBuilder = new ActionBuilder(); @@ -561,35 +592,34 @@ 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 setFields) { + final Map setFields) { List matchEntriesList = new ArrayList<>(); - for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch currMatch : setFields) { - Class extends org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField> currMatchType = currMatch - .getMatchType(); + 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()); + 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.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, - final Class extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField> field, - final Boolean hasMask) { - if(field == TcpFlags.class) { + final Class extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225 + .MatchField> field, final Boolean hasMask) { + if (field == TcpFlags.class) { builder.setOxmClass(ExperimenterClass.class); } else { builder.setOxmClass(OpenflowBasicClass.class); @@ -604,12 +634,14 @@ public class TableFeaturesConvertor extends Convertor< } @Override - public List convert(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures source, VersionConvertorData data) { + public List convert( + final org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures source, + final VersionConvertorData data) { List ofTableFeaturesList = new ArrayList<>(); TableFeaturesBuilder ofTableFeatures = new TableFeaturesBuilder(); - for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures salTableFeatures : source - .getTableFeatures()) { + for (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures + salTableFeatures : source.nonnullTableFeatures().values()) { ofTableFeatures.setTableId(salTableFeatures.getTableId()); ofTableFeatures.setName(salTableFeatures.getName()); ofTableFeatures.setMetadataMatch(salTableFeatures.getMetadataMatch()); @@ -617,7 +649,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()));