add Long parsing to Map helper
This commit is contained in:
parent
1947336f63
commit
336cebca9d
2 changed files with 14 additions and 4 deletions
|
@ -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 {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
group = org.xbib
|
||||
name = datastructures
|
||||
version = 2.3.0
|
||||
version = 2.3.1
|
||||
|
||||
org.gradle.warning.mode = all
|
||||
|
|
Loading…
Reference in a new issue