21211c7ff265a6b94b0ba2ec49e11de46ced45db
[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             .put("igmp", ProtocolIgmp.class)
55             .build();
56
57         public static Class<? extends ProtocolBase> get(String key) {
58             return MAPPER.get(key);
59         }
60
61         public static String getName(Class<? extends ProtocolBase> key) {
62             ImmutableBiMap<Class<? extends ProtocolBase>, String> inverseMapper = MAPPER.inverse();
63             return inverseMapper.get(key);
64         }
65     }
66
67     // Direction of the Traffic
68     public static class DirectionMapper {
69         private DirectionMapper() {
70             throw new UnsupportedOperationException("Utility class should not be instantiated.");
71         }
72
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)
77             .build();
78
79         public static Class<? extends DirectionBase> get(String key) {
80             return MAPPER.get(key);
81         }
82
83         public static String getName(Class<? extends DirectionBase> key) {
84             ImmutableBiMap<Class<? extends DirectionBase>, String> inverseMapper = MAPPER.inverse();
85             return inverseMapper.get(key);
86         }
87
88         private static final ImmutableBiMap<String, Class<? extends DirectionMinimumBandwidthRule>>
89             MINIMUMBANDWIDTHRULE_MAPPER = new ImmutableBiMap.Builder<String, Class<? extends
90             DirectionMinimumBandwidthRule>>()
91             .put("egress", DirectionMinimumBandwidthRule.class)
92             .build();
93
94         public static Class<? extends DirectionMinimumBandwidthRule>
95             getMinimumBandwidthRuleDirection(String minimumBandwidthKey) {
96             return MINIMUMBANDWIDTHRULE_MAPPER.get(minimumBandwidthKey);
97         }
98
99         public static String getMinimumBandwidthRuleDirectionString(Class<? extends DirectionMinimumBandwidthRule>
100             minimumBandwidthKey) {
101             ImmutableBiMap<Class<? extends DirectionMinimumBandwidthRule>, String>
102             inverseMinimBandwidthRuleDirectionMapper = MINIMUMBANDWIDTHRULE_MAPPER.inverse();
103             return inverseMinimBandwidthRuleDirectionMapper.get(minimumBandwidthKey);
104         }
105     }
106 }