Make methods static
[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 package org.opendaylight.openflowplugin.impl.translator;
9
10 import java.util.Optional;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
12 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
13 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved;
16 import org.opendaylight.yangtools.yang.common.Uint8;
17
18 /**
19  * Translate {@link FlowRemoved} message to FlowRemoved notification (omit instructions).
20  */
21 public class FlowRemovedV10Translator extends FlowRemovedTranslator {
22
23     public FlowRemovedV10Translator(final ConvertorExecutor convertorExecutor) {
24         super(convertorExecutor);
25     }
26
27     @Override
28     protected MatchBuilder translateMatch(final FlowRemoved flowRemoved, final DeviceInfo deviceInfo) {
29         final VersionDatapathIdConvertorData datapathIdConvertorData =
30                 new VersionDatapathIdConvertorData(deviceInfo.getVersion());
31         datapathIdConvertorData.setDatapathId(deviceInfo.getDatapathId());
32
33         final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(
34                 flowRemoved.getMatchV10(),
35                 datapathIdConvertorData);
36
37         return matchBuilderOptional.orElse(new MatchBuilder());
38     }
39
40     /**
41      * Always returns zero because OF10 FLOW_REMOVED doesn't contain table ID.
42      *
43      * @param flowRemoved  FLOW_REMOVED message.
44      * @return  Zero.
45      */
46     @Override
47     protected Uint8 translateTableId(final FlowRemoved flowRemoved) {
48         return Uint8.ZERO;
49     }
50 }