com.rethinkdb.response.GroupedResponseConverter Maven / Gradle / Ivy
The newest version!
package com.rethinkdb.response;
import com.rethinkdb.RethinkDBException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class GroupedResponseConverter {
public static Map convert(Map map) {
if (!"GROUPED_DATA".equals(map.get("$reql_type$"))) {
throw new RethinkDBException("Expected grouped data but found something else");
}
Map result = new HashMap();
List data = (List) map.get("data");
for (List group : data) {
result.put((K)group.get(0), (V)group.get(1));
}
return result;
}
}