Using reflection and generics:
public static Map MapMe(Class clz, Collection list, String methodName)
throws Exception{
Map map = new HashMap();
Method method = clz.getMethod(methodName);
for (T el : list){
map.put((String)method.invoke(el), el);
}
return map;
}
In your documentation, make sure you mention that the return type of the method must be a String. Otherwise, it will throw a ClassCastException when it tries to cast the return value.