Bug 5540 - ConvertorManager base
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / common / IPProtocols.java
1 /*
2  * Copyright (c) 2016 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.core.sal.convertor.common;
10
11 import com.google.common.collect.ImmutableMap;
12 import com.google.common.collect.ImmutableMap.Builder;
13 import java.util.Map;
14
15 /**
16  * @author tkubas
17  *
18  */
19 //TODO make a model in YANG for protocols 
20 public enum IPProtocols {
21     ICMP((short) 1), 
22     TCP((short) 6), 
23     UDP((short) 17), 
24     ICMPV6((short) 58);
25
26     private short protocol;
27     
28     private static final Map<Short, IPProtocols> VALUE_MAP;
29     static {
30         Builder<Short, IPProtocols> builder = ImmutableMap.builder();
31         for(IPProtocols protocols : IPProtocols.values()) {
32             builder.put(protocols.protocol, protocols);
33         }
34         VALUE_MAP = builder.build();
35     }
36     
37     private IPProtocols(short value) {
38         this.protocol = value;
39     }
40
41     public static IPProtocols fromProtocolNum(Short protocolNum) {
42         return VALUE_MAP.get(protocolNum);
43     }
44 }