Commit a605865f by guojuxing

引入json包

parent 4bc2f1ca
......@@ -213,31 +213,26 @@ public class MarketServiceDTO implements Serializable{
return (String) json.get("200");
}
@SuppressWarnings("unchecked")
public static <K, V> Map<K, List<V>> group(List<V> list, String field) {
Map<K, List<V>> map = new HashMap();
if (list != null && !list.isEmpty()) {
Object v;
Object sublist;
for(Iterator var3 = list.iterator(); var3.hasNext(); ((List)sublist).add(v)) {
v = var3.next();
Object p = null;
Map<K, List<V>> map = new HashMap<K, List<V>>();
if (list == null || list.isEmpty()) {
return map;
}
for (V v : list) {
K p = null;
try {
p = PropertyUtils.getProperty(v, field);
} catch (Exception var7) {
throw new RuntimeException(var7.getMessage(), var7);
p = (K) PropertyUtils.getProperty(v, field);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
sublist = (List)map.get(p);
List<V> sublist = map.get(p);
if (sublist == null) {
sublist = new ArrayList();
sublist = new ArrayList<V>();
map.put(p, sublist);
}
sublist.add(v);
}
return map;
} else {
return map;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment