提交 | 用户 | age
|
736fa6
|
1 |
package com.hx.util; |
G |
2 |
|
|
3 |
import java.util.Map; |
|
4 |
|
|
5 |
/** |
|
6 |
* map工具类 |
|
7 |
* |
|
8 |
* @author cmg |
|
9 |
* @date 2023-03-16 |
|
10 |
*/ |
|
11 |
public class MapUtil { |
|
12 |
|
|
13 |
/** |
|
14 |
* 从map中获取 |
|
15 |
* @param map |
|
16 |
* @param key |
|
17 |
* @return |
|
18 |
*/ |
|
19 |
public static String getString(Map<String, Object> map, String key) |
|
20 |
{ |
|
21 |
if(map == null || StringUtils.isEmpty(key)) |
|
22 |
{ |
|
23 |
return null; |
|
24 |
} |
|
25 |
|
|
26 |
return null == map.get(key) ? null : map.get(key).toString(); |
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* 从map中获取整数,如果没有,则返回-1 |
|
31 |
* @param map |
|
32 |
* @param key |
|
33 |
* @return |
|
34 |
*/ |
|
35 |
public static int getInt(Map<String, Object> map, String key) |
|
36 |
{ |
|
37 |
if(map == null || StringUtils.isEmpty(key)) |
|
38 |
{ |
|
39 |
return -1; |
|
40 |
} |
|
41 |
|
|
42 |
return null == map.get(key) ? -1 : Integer.parseInt(map.get(key).toString()); |
|
43 |
} |
|
44 |
} |