`
收藏列表
标题 标签 来源
List to Map List to Map
/**
* <p>将List变为Map</p>
* @param list
* @param <V> list的项目
* @param keyField 作为Map的项目
* @return 变换成的Map
* @throws Exception keyField项目没有找到的话,抛出异常
*/
private <V> Map<String, V> c(List<V> list, String keyField) throws Exception {

Map<String, V> map = new HashMap<String, V>();

for (V obj : list) {
String key = BeanUtils.getProperty(obj, keyField);
map.put(key, obj);
}
return map;
}
Global site tag (gtag.js) - Google Analytics