|
@@ -1,8 +1,5 @@
|
|
|
package com.keao.edu.util.collection;
|
|
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.poi.ss.formula.functions.T;
|
|
|
-
|
|
|
import java.beans.BeanInfo;
|
|
|
import java.beans.IntrospectionException;
|
|
|
import java.beans.Introspector;
|
|
@@ -12,8 +9,11 @@ import java.lang.reflect.Method;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Map.Entry;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+
|
|
|
public class MapUtil {
|
|
|
|
|
|
private static final Object[] EMPTY_ARRAY = {};
|
|
@@ -128,24 +128,25 @@ public class MapUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * @param <K>
|
|
|
* @Author: Joburgess
|
|
|
* @Date: 2019/10/12
|
|
|
* @params [maps]
|
|
|
* @return java.util.Map
|
|
|
* @describe mybatis返回结果转换为Map
|
|
|
*/
|
|
|
- public static Map convertIntegerMap(List<Map> maps){
|
|
|
+ public static <K, V> Map<K, V> convertIntegerMap(List<Map<K, V>> maps) {
|
|
|
int size = 0;
|
|
|
- if(maps != null){
|
|
|
+ if (maps != null) {
|
|
|
size = maps.size();
|
|
|
}
|
|
|
- Map result=new HashMap(size);
|
|
|
- maps.forEach(stringIntegerMap -> {
|
|
|
- if(Objects.isNull(stringIntegerMap)){
|
|
|
- return;
|
|
|
+ Map<K, V> result = new HashMap<K, V>(size);
|
|
|
+
|
|
|
+ for (Map<K, V> map : maps) {
|
|
|
+ for (Entry<K, V> entry : map.entrySet()) {
|
|
|
+ result.put(entry.getKey(), entry.getValue());
|
|
|
}
|
|
|
- result.put(stringIntegerMap.get("key"),stringIntegerMap.get("value"));
|
|
|
- });
|
|
|
+ }
|
|
|
return result;
|
|
|
}
|
|
|
|