ccfb336bb012663304c47835729de499c336e8a2
[openflowplugin.git] / applications / forwardingrules-manager / src / main / java / org / opendaylight / openflowplugin / applications / frm / ForwardingRulesProperty.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.applications.frm;
10
11 import com.google.common.collect.ImmutableMap;
12 import java.util.Map;
13
14 public enum ForwardingRulesProperty {
15     DISABLE_RECONCILIATION,
16     STALE_MARKING_ENABLED,
17     RECONCILIATION_RETRY_COUNT,
18     BUNDLE_BASED_RECONCILIATION_ENABLED;
19
20
21     private static final Map<String, ForwardingRulesProperty> KEY_VALUE_MAP;
22
23     /**
24      * Get property type from property key
25      *
26      * @param key the property key
27      * @return the property type
28      */
29     public static ForwardingRulesProperty forValue(final String key) {
30         return KEY_VALUE_MAP.get(key);
31     }
32
33     static {
34         final ForwardingRulesProperty[] values = values();
35         final ImmutableMap.Builder<String, ForwardingRulesProperty> builder = ImmutableMap.builder();
36
37         for (final ForwardingRulesProperty value : values) {
38             builder.put(value.toString(), value);
39         }
40
41         KEY_VALUE_MAP = builder.build();
42     }
43
44     /**
45      * Converts enum name to property key
46      *
47      * @return the property key
48      */
49     @Override
50     public String toString() {
51         return this.name().toLowerCase().replace('_', '-');
52     }
53 }