85f50734221b60142759250b5ee3f1e15055f6c0
[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
14 public final class NeutronUtils {
15     private NeutronUtils() {
16         throw new UnsupportedOperationException("Utility class should not be instantiated.");
17     }
18
19     // For FWaaS
20     public static class FwProtocolMapper {
21         private FwProtocolMapper() {
22             throw new UnsupportedOperationException("Utility class should not be instantiated.");
23         }
24
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)
30             .build();
31
32         public static Class<? extends FwProtocolBase> get(String key) {
33             return MAPPER.get(key);
34         }
35
36         public static String getName(Class<? extends FwProtocolBase> key) {
37             ImmutableBiMap<Class<? extends FwProtocolBase>, String> inverseMapper = MAPPER.inverse();
38             return inverseMapper.get(key);
39         }
40     }
41
42     // For security group
43     public static class ProtocolMapper {
44         private ProtocolMapper() {
45             throw new UnsupportedOperationException("Utility class should not be instantiated.");
46         }
47
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             .build();
55
56         public static Class<? extends ProtocolBase> get(String key) {
57             return MAPPER.get(key);
58         }
59
60         public static String getName(Class<? extends ProtocolBase> key) {
61             ImmutableBiMap<Class<? extends ProtocolBase>, String> inverseMapper = MAPPER.inverse();
62             return inverseMapper.get(key);
63         }
64     }
65
66     // Direction of the Traffic
67     public static class DirectionMapper {
68         private DirectionMapper() {
69             throw new UnsupportedOperationException("Utility class should not be instantiated.");
70         }
71
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)
76             .build();
77
78         public static Class<? extends DirectionBase> get(String key) {
79             return MAPPER.get(key);
80         }
81
82         public static String getName(Class<? extends DirectionBase> key) {
83             ImmutableBiMap<Class<? extends DirectionBase>, String> inverseMapper = MAPPER.inverse();
84             return inverseMapper.get(key);
85         }
86
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)
91             .build();
92
93         public static Class<? extends DirectionMinimumBandwidthRule>
94             getMinimumBandwidthRuleDirection(String minimumBandwidthKey) {
95             return MINIMUMBANDWIDTHRULE_MAPPER.get(minimumBandwidthKey);
96         }
97
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);
103         }
104     }
105 }