Merge "OPNFLWPLUG-929 : Remove deprecated guava library"
[openflowplugin.git] / applications / topology-lldp-discovery / src / main / java / org / opendaylight / openflowplugin / applications / topology / lldp / TopologyLLDPDiscoveryProperty.java
1 /**
2  * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. 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 package org.opendaylight.openflowplugin.applications.topology.lldp;
9
10 import com.google.common.collect.ImmutableMap;
11
12 import java.util.Map;
13
14 public enum TopologyLLDPDiscoveryProperty {
15     LLDP_SECURE_KEY,
16     TOPOLOGY_LLDP_INTERVAL,
17     TOPOLOGY_LLDP_EXPIRATION_INTERVAL;
18
19     private static final Map<String, TopologyLLDPDiscoveryProperty> KEY_VALUE_MAP;
20
21     /**
22      * Get property type from property key.
23      *
24      * @param key the property key
25      * @return the property type
26      */
27     public static TopologyLLDPDiscoveryProperty forValue(final String key) {
28         return KEY_VALUE_MAP.get(key);
29     }
30
31     static {
32         final TopologyLLDPDiscoveryProperty[] values = values();
33         final ImmutableMap.Builder<String, TopologyLLDPDiscoveryProperty> builder = ImmutableMap.builder();
34
35         for (final TopologyLLDPDiscoveryProperty value : values) {
36             builder.put(value.toString(), value);
37         }
38
39         KEY_VALUE_MAP = builder.build();
40     }
41
42     /**
43      * Converts enum name to property key.
44      *
45      * @return the property key
46      */
47     @Override
48     public String toString() {
49         return this.name().toLowerCase().replace('_', '-');
50     }
51 }