Remove dependency of impl on onf-extensions
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / match / MatchConvertorImpl.java
index 9f273ed729971749c0fb07bf7242a9d10622abcd..56c7d5056248f797a4c98bbdf4c118837d939983 100644 (file)
@@ -9,17 +9,17 @@
 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
 
 
-import com.google.common.base.Optional;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
 import org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava;
 import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionResolvers;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.OFApprovedExperimenterIds;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.OFApprovedExperimenterIds;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.cases.SalToOfArpMatchCase;
@@ -332,7 +332,7 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
                     vidEntryValue = vlanId.getVlanId().getValue();
                 }
 
-                hasmask = (vidEntryValue == 0);
+                hasmask = vidEntryValue == 0;
                 if (hasmask) {
                     vlanVidBuilder.setMask(VLAN_VID_MASK);
                 }
@@ -604,14 +604,17 @@ public class MatchConvertorImpl implements MatchConvertor<List<MatchEntry>> {
         /**
          * TODO: EXTENSION PROPOSAL (match, MD-SAL to OFJava)
          * - we might need version for conversion and for key
-         * - sanitize NPE
          */
         Optional<GeneralExtensionListGrouping> extensionListOpt = ExtensionResolvers.getMatchExtensionResolver().getExtension(match);
         if (extensionListOpt.isPresent()) {
-            for (ExtensionList extensionItem : extensionListOpt.get().getExtensionList()) {
+            List<ExtensionList> extensionListList = extensionListOpt.get().getExtensionList();
+            for (ExtensionList extensionItem : extensionListList) {
                 // TODO: get real version
                 ConverterExtensionKey<? extends ExtensionKey> key = new ConverterExtensionKey<>(extensionItem.getExtensionKey(), OFConstants.OFP_VERSION_1_3);
                 ConvertorToOFJava<MatchEntry> convertor = OFSessionUtil.getExtensionConvertorProvider().getConverter(key);
+                if (convertor == null) {
+                    throw new IllegalStateException("No converter found for key: " + key.toString());
+                }
                 MatchEntry ofMatch = convertor.convert(extensionItem.getExtension());
                 result.add(ofMatch);
             }