Bug 5596 Initial commit failed
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / translator / FlowRemovedV10Translator.java
index b09b8fe13564d5388239f11dd3332ed5ee2d51f6..997321dfac858abe94f6898d68eaf64017e94f6b 100644 (file)
@@ -8,9 +8,10 @@
 
 package org.opendaylight.openflowplugin.impl.translator;
 
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchConvertorImpl;
+import java.util.Optional;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
 
@@ -19,8 +20,30 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  */
 public class FlowRemovedV10Translator extends FlowRemovedTranslator {
 
-    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceContext deviceContext) {
-        return MatchConvertorImpl.fromOFMatchV10ToSALMatch(flowRemoved.getMatchV10(),
-                deviceContext.getDeviceState().getFeatures().getDatapathId(), OpenflowVersion.OF10);
+    public FlowRemovedV10Translator(ConvertorExecutor convertorExecutor) {
+        super(convertorExecutor);
+    }
+
+    @Override
+    protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) {
+        final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(deviceInfo.getVersion());
+        datapathIdConvertorData.setDatapathId(deviceInfo.getDatapathId());
+
+        final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(
+                flowRemoved.getMatchV10(),
+                datapathIdConvertorData);
+
+        return matchBuilderOptional.orElse(new MatchBuilder());
+    }
+
+    /**
+     * Always returns zero because OF10 FLOW_REMOVED doesn't contain table ID.
+     *
+     * @param flowRemoved  FLOW_REMOVED message.
+     * @return  Zero.
+     */
+    @Override
+    protected Short translateTableId(FlowRemoved flowRemoved) {
+        return (short) 0;
     }
 }