377f3908f3d35467e60dde1ad1e5e8d97ec8c3b1
[neutron.git] / model / src / main / java / org / opendaylight / yang / gen / v1 / urn / opendaylight / neutron / constants / rev150712 / NeutronUtils.java
1 /*
2  * Copyright (c) 2016 Intel corporation 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.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712;
10
11 import com.google.common.collect.ImmutableBiMap;
12
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.FwProtocolBase;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.FwProtocolIcmp;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.FwProtocolTcp;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.FwProtocolUdp;
17
18
19 public final class NeutronUtils {
20     private NeutronUtils() {
21         throw new UnsupportedOperationException("Utility class should not be instantiated.");
22     }
23
24     // For FWaaS
25     public static class FwProtocolMapper {
26         private FwProtocolMapper() {
27             throw new UnsupportedOperationException("Utility class should not be instantiated.");
28         }
29
30         private static final ImmutableBiMap<String, Class<? extends FwProtocolBase>> MAPPER
31             = new ImmutableBiMap.Builder<String, Class<? extends FwProtocolBase>>()
32             .put("tcp", FwProtocolTcp.class)
33             .put("udp", FwProtocolUdp.class)
34             .put("icmp", FwProtocolIcmp.class)
35             .build();
36
37         public static Class<? extends FwProtocolBase> get(String key) {
38             return MAPPER.get(key);
39         }
40
41         public static String getName(Class<? extends FwProtocolBase> key) {
42             ImmutableBiMap<Class<? extends FwProtocolBase>, String> inverseMapper = MAPPER.inverse();
43             return inverseMapper.get(key);
44         }
45     }
46 }