Algorithm - 一种从properties中依据value找key的方法

Algorithm - 一种从properties中根据value找key的方法Constraints:?1. relation of key and value is one-

Algorithm - 一种从properties中根据value找key的方法

Constraints:

?1. relation of key and value is one-to-one, and both unique.

?2. key and value is both String.

?

?

public String getKey(String value) {if (ht == null)ht = new Hashtable<String, String>();if (Checker.isNotNull(entrySet())&& Checker.isNotNull(entrySet().iterator())) {Set<Map.Entry<Object, Object>> set = this.entrySet();Iterator<Map.Entry<Object, Object>> iter = set.iterator();while (iter.hasNext()) {Map.Entry<Object, Object> entry = iter.next();if (entry.getKey() instanceof String&& entry.getValue() instanceof String) {String k = (String) entry.getKey();String v = (String) entry.getValue();ht.put(v, k);}}}return ht.get(value);}