提交 | 用户 | 时间
|
1ac2bc
|
1 |
package cn.stylefeng.guns.workflow.core.util; |
懒 |
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
/** |
|
7 |
* map工具类 |
|
8 |
* |
|
9 |
* @author fengshuonan |
|
10 |
* @Date 2019-08-27 18:39 |
|
11 |
*/ |
|
12 |
public class UtilMisc { |
|
13 |
|
|
14 |
public static <V, V1 extends V, V2 extends V> Map<String, V> toMap(String name1, V1 value1, String name2, V2 value2) { |
|
15 |
return populateMap(new HashMap<String, V>(), name1, value1, name2, value2); |
|
16 |
} |
|
17 |
|
|
18 |
@SuppressWarnings("unchecked") |
|
19 |
private static <K, V> Map<String, V> populateMap(Map<String, V> map, Object... data) { |
|
20 |
for (int i = 0; i < data.length; ) { |
|
21 |
map.put((String) data[i++], (V) data[i++]); |
|
22 |
} |
|
23 |
return map; |
|
24 |
} |
|
25 |
|
|
26 |
} |