Fix findbugs violations in applications
[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.Locale;
13 import java.util.Map;
14
15 public enum ForwardingRulesProperty {
16     DISABLE_RECONCILIATION,
17     STALE_MARKING_ENABLED,
18     RECONCILIATION_RETRY_COUNT,
19     BUNDLE_BASED_RECONCILIATION_ENABLED;
20
21
22     private static final Map<String, ForwardingRulesProperty> KEY_VALUE_MAP;
23
24     /**
25      * Get property type from property key.
26      *
27      * @param key the property key
28      * @return the property type
29      */
30     public static ForwardingRulesProperty forValue(final String key) {
31         return KEY_VALUE_MAP.get(key);
32     }
33
34     static {
35         final ForwardingRulesProperty[] values = values();
36         final ImmutableMap.Builder<String, ForwardingRulesProperty> builder = ImmutableMap.builder();
37
38         for (final ForwardingRulesProperty value : values) {
39             builder.put(value.toString(), value);
40         }
41
42         KEY_VALUE_MAP = builder.build();
43     }
44
45     /**
46      * Converts enum name to property key.
47      *
48      * @return the property key
49      */
50     @Override
51     public String toString() {
52         return this.name().toLowerCase(Locale.ROOT).replace('_', '-');
53     }
54 }