Bug 5540 - PortConvertor, MatchConvertor
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / translator / FlowRemovedV10Translator.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowplugin.impl.translator;
10
11 import java.util.Optional;
12 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
13 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
14 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
17
18 /**
19  * translate {@link FlowRemoved} message to FlowRemoved notification (omit instructions)
20  */
21 public class FlowRemovedV10Translator extends FlowRemovedTranslator {
22
23     @Override
24     protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) {
25         final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(deviceInfo.getVersion());
26         datapathIdConvertorData.setDatapathId(deviceInfo.getDatapathId());
27
28         final Optional<MatchBuilder> matchBuilderOptional = ConvertorManager.getInstance().convert(
29                 flowRemoved.getMatchV10(),
30                 datapathIdConvertorData);
31
32         return matchBuilderOptional.orElse(new MatchBuilder());
33     }
34
35     /**
36      * Always returns zero because OF10 FLOW_REMOVED doesn't contain table ID.
37      *
38      * @param flowRemoved  FLOW_REMOVED message.
39      * @return  Zero.
40      */
41     @Override
42     protected Short translateTableId(FlowRemoved flowRemoved) {
43         return (short) 0;
44     }
45 }