Bug 868: Replaced use of toInstance() for build().
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / util / PacketInUtil.java
1 /**
2  * Copyright (c) 2014 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.openflow.md.util;
10
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.InvalidTtl;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.NoMatch;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController;
15
16 /**
17  *
18  */
19 public final class PacketInUtil {
20
21     private PacketInUtil(){
22         throw new AssertionError("PacketInUtil is not expected to be instantiated.");
23     }
24
25     /**
26      * @param reason
27      * @return corresponding MD-SAL reason class for given OF-API reason
28      */
29     public static Class<? extends PacketInReason> getMdSalPacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason reason) {
30         Class<? extends PacketInReason> resultReason = PacketInReason.class;
31
32         if (reason.equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason.OFPRNOMATCH)) {
33             resultReason = NoMatch.class;
34         } else if (reason.equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason.OFPRINVALIDTTL)) {
35             resultReason = InvalidTtl.class;
36         } else if (reason.equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PacketInReason.OFPRACTION)) {
37             resultReason = SendToController.class;
38         }
39
40         return resultReason;
41     }
42
43 }