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)
56 public static Class<? extends ProtocolBase> get(String key) {
57 return MAPPER.get(key);
60 public static String getName(Class<? extends ProtocolBase> key) {
61 ImmutableBiMap<Class<? extends ProtocolBase>, String> inverseMapper = MAPPER.inverse();
62 return inverseMapper.get(key);
66 // Direction of the Traffic
67 public static class DirectionMapper {
68 private DirectionMapper() {
69 throw new UnsupportedOperationException("Utility class should not be instantiated.");
72 private static final ImmutableBiMap<String, Class<? extends DirectionBase>> MAPPER
73 = new ImmutableBiMap.Builder<String, Class<? extends DirectionBase>>()
74 .put("egress", DirectionEgress.class)
75 .put("ingress", DirectionIngress.class)
78 public static Class<? extends DirectionBase> get(String key) {
79 return MAPPER.get(key);
82 public static String getName(Class<? extends DirectionBase> key) {
83 ImmutableBiMap<Class<? extends DirectionBase>, String> inverseMapper = MAPPER.inverse();
84 return inverseMapper.get(key);
87 private static final ImmutableBiMap<String, Class<? extends DirectionMinimumBandwidthRule>>
88 MINIMUMBANDWIDTHRULE_MAPPER = new ImmutableBiMap.Builder<String, Class<? extends
89 DirectionMinimumBandwidthRule>>()
90 .put("egress", DirectionMinimumBandwidthRule.class)
93 public static Class<? extends DirectionMinimumBandwidthRule>
94 getMinimumBandwidthRuleDirection(String minimumBandwidthKey) {
95 return MINIMUMBANDWIDTHRULE_MAPPER.get(minimumBandwidthKey);
98 public static String getMinimumBandwidthRuleDirectionString(Class<? extends DirectionMinimumBandwidthRule>
99 minimumBandwidthKey) {
100 ImmutableBiMap<Class<? extends DirectionMinimumBandwidthRule>, String>
101 inverseMinimBandwidthRuleDirectionMapper = MINIMUMBANDWIDTHRULE_MAPPER.inverse();
102 return inverseMinimBandwidthRuleDirectionMapper.get(minimumBandwidthKey);