2 * Copyright (c) 2016 Intel corporation and others. All rights reserved.
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
9 package org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712;
11 import com.google.common.collect.ImmutableBiMap;
14 public final class NeutronUtils {
15 private NeutronUtils() {
16 throw new UnsupportedOperationException("Utility class should not be instantiated.");
20 public static class FwProtocolMapper {
21 private FwProtocolMapper() {
22 throw new UnsupportedOperationException("Utility class should not be instantiated.");
25 private static final ImmutableBiMap<String, Class<? extends FwProtocolBase>> MAPPER
26 = new ImmutableBiMap.Builder<String, Class<? extends FwProtocolBase>>()
27 .put("tcp", FwProtocolTcp.class)
28 .put("udp", FwProtocolUdp.class)
29 .put("icmp", FwProtocolIcmp.class)
32 public static Class<? extends FwProtocolBase> get(String key) {
33 return MAPPER.get(key);
36 public static String getName(Class<? extends FwProtocolBase> key) {
37 ImmutableBiMap<Class<? extends FwProtocolBase>, String> inverseMapper = MAPPER.inverse();
38 return inverseMapper.get(key);
43 public static class ProtocolMapper {
44 private ProtocolMapper() {
45 throw new UnsupportedOperationException("Utility class should not be instantiated.");
48 private static final ImmutableBiMap<String, Class<? extends ProtocolBase>> MAPPER
49 = new ImmutableBiMap.Builder<String, Class<? extends ProtocolBase>>()
50 .put("icmp", ProtocolIcmp.class)
51 .put("tcp", ProtocolTcp.class)
52 .put("udp", ProtocolUdp.class)
53 .put("icmpv6", ProtocolIcmpV6.class)
54 .put("igmp", ProtocolIgmp.class)
57 public static Class<? extends ProtocolBase> get(String key) {
58 return MAPPER.get(key);
61 public static String getName(Class<? extends ProtocolBase> key) {
62 ImmutableBiMap<Class<? extends ProtocolBase>, String> inverseMapper = MAPPER.inverse();
63 return inverseMapper.get(key);
67 // Direction of the Traffic
68 public static class DirectionMapper {
69 private DirectionMapper() {
70 throw new UnsupportedOperationException("Utility class should not be instantiated.");
73 private static final ImmutableBiMap<String, Class<? extends DirectionBase>> MAPPER
74 = new ImmutableBiMap.Builder<String, Class<? extends DirectionBase>>()
75 .put("egress", DirectionEgress.class)
76 .put("ingress", DirectionIngress.class)
79 private static final ImmutableBiMap<Class<? extends DirectionBase>, String> MAPPER_INVERSE = MAPPER.inverse();
81 public static Class<? extends DirectionBase> get(String key) {
82 return MAPPER.get(key);
85 public static String getDirectionString(Class<? extends DirectionBase> direction) {
86 return MAPPER_INVERSE.get(direction);