add Long parsing to Map helper

This commit is contained in:
Jörg Prante 2023-08-21 18:29:25 +02:00
parent 1947336f63
commit 336cebca9d
2 changed files with 14 additions and 4 deletions

View file

@ -6,9 +6,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
*
*/
public class Maps {
private Maps() {
@ -55,6 +52,19 @@ public class Maps {
return (String) object;
}
public static Long getLong(Map<?, ?> map, String key, Long defaultValue) {
if (map.containsKey(key)) {
try {
Object o = get(map, key);
return o == null ? null : o instanceof Long ? (Long) o : Long.parseLong(o.toString());
} catch (NumberFormatException e) {
return defaultValue;
}
} else {
return defaultValue;
}
}
public static Integer getInteger(Map<?, ?> map, String key, Integer defaultValue) {
if (map.containsKey(key)) {
try {

View file

@ -1,5 +1,5 @@
group = org.xbib
name = datastructures
version = 2.3.0
version = 2.3.1
org.gradle.warning.mode = all