QueryResults { public Map<String, List<Object>> copyData() { Map<String, List<Object>> newMap = new TreeMap<>(); resultsMap.entrySet().stream() .forEach(entry -> newMap.put(entry.getKey(), new ArrayList<>(entry.getValue()))); return newMap; } QueryResults(Map<String, List<Object>> data); List getValues(String columnName); Tuple2<List<String>, List<String[]>> toRowOrientedData(); String[][] toRowOrientedArray(); Set<String> getColumnNames(); int getRows(); int getColumns(); Map<String, List<Object>> copyData(); static QueryResults fromResultSet(ResultSet resultSet);  }
@Test public void testCopyData() { Map<String, List<Object>> data = new HashMap<>(); data.put("Foo", Lists.newArrayList(1, 2, 3, 4)); data.put("Bar", Lists.newArrayList("a", "b", "c", "d")); QueryResults queryResults = new QueryResults(data); QueryResults copy = new QueryResults(queryResults.copyData()); assertEquals(queryResults.getColumns(), copy.getColumns()); assertEquals(queryResults.getRows(), copy.getRows()); }