Skip to content

Commit

Permalink
Merge pull request #198 from shiyindaxiaojie/feature
Browse files Browse the repository at this point in the history
update
  • Loading branch information
shiyindaxiaojie authored Jul 26, 2024
2 parents 64bab48 + 703bbb4 commit f92c6e5
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,13 @@ public static boolean isEmpty(final Map<?, ?> map) {
public static boolean isNotEmpty(final Map<?, ?> map) {
return org.apache.commons.collections4.MapUtils.isNotEmpty(map);
}

public static <K, V> K findKey(final Map<K, V> map, V value) {
for (Map.Entry<?, ?> entry : map.entrySet()) {
if (value == null ? entry.getValue() == null : value.equals(entry.getValue())) {
return (K) entry.getKey();
}
}
return null;
}
}

0 comments on commit f92c6e5

Please sign in to comment.