Create generic groupBy method
I'm trying to create generic groupBy method from the list of objects that
I have so I though my method could have signature something like this :
private Map<String, List<T>> groupBy(List<T> list, String fieldName) {
But it's not compiling. Type T is missing, how can I fix it to compile? I
though of calling the field name(getter) via java reflection and grouping
it and returning a map.
No comments:
Post a Comment