Commit bafd2fc1 authored by yanzg's avatar yanzg

接口文档的支持

parent 90d10abb
package com.yanzuoguang.util.helper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MapHelper {
/**
* 将一个对象列表转换为HashMap
*
* @param list 需要转换的列表
* @param proxy 获取主键的函数
* @param <T>
* @return
*/
public static <T extends Object> Map<String, T> getMap(List<T> list, MapKey<T> proxy) {
Map<String, T> map = new HashMap<>();
for (T item : list) {
String key = proxy.getKey(item);
map.put(key, item);
}
return map;
}
/**
* 一个获取对象关键字的处理函数
*
* @param <T>
*/
public interface MapKey<T> {
String getKey(T from);
}
}
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