@Test void asMaps_returns_maps_of_raw() { DataTable table = createSimpleNumberTable(); Map<String, String> expected = new HashMap<String, String>() {{ put("1", "2"); put("100", "1000"); }}; assertEquals(singletonList(expected), table.asMaps()); }
public List<Map<String, String>> asMaps() { if (raw.isEmpty()) return emptyList(); List<String> headers = raw.get(0); List<Map<String, String>> headersAndRows = new ArrayList<>(); for (int i = 1; i < raw.size(); i++) { List<String> row = raw.get(i); LinkedHashMap<String, String> headersAndRow = new LinkedHashMap<>(); for (int j = 0; j < headers.size(); j++) { String key = headers.get(j); String value = row.get(j); if (headersAndRow.containsKey(key)) { String wouldBeReplaced = headersAndRow.get(key); throw duplicateKeyException(String.class, String.class, key, value, wouldBeReplaced); } headersAndRow.put(key, value); } headersAndRows.add(unmodifiableMap(headersAndRow)); } return unmodifiableList(headersAndRows); }
DataTable { public List<Map<String, String>> asMaps() { if (raw.isEmpty()) return emptyList(); List<String> headers = raw.get(0); List<Map<String, String>> headersAndRows = new ArrayList<>(); for (int i = 1; i < raw.size(); i++) { List<String> row = raw.get(i); LinkedHashMap<String, String> headersAndRow = new LinkedHashMap<>(); for (int j = 0; j < headers.size(); j++) { String key = headers.get(j); String value = row.get(j); if (headersAndRow.containsKey(key)) { String wouldBeReplaced = headersAndRow.get(key); throw duplicateKeyException(String.class, String.class, key, value, wouldBeReplaced); } headersAndRow.put(key, value); } headersAndRows.add(unmodifiableMap(headersAndRow)); } return unmodifiableList(headersAndRows); } }
DataTable { public List<Map<String, String>> asMaps() { if (raw.isEmpty()) return emptyList(); List<String> headers = raw.get(0); List<Map<String, String>> headersAndRows = new ArrayList<>(); for (int i = 1; i < raw.size(); i++) { List<String> row = raw.get(i); LinkedHashMap<String, String> headersAndRow = new LinkedHashMap<>(); for (int j = 0; j < headers.size(); j++) { String key = headers.get(j); String value = row.get(j); if (headersAndRow.containsKey(key)) { String wouldBeReplaced = headersAndRow.get(key); throw duplicateKeyException(String.class, String.class, key, value, wouldBeReplaced); } headersAndRow.put(key, value); } headersAndRows.add(unmodifiableMap(headersAndRow)); } return unmodifiableList(headersAndRows); } private  DataTable(List<List<String>> raw, TableConverter tableConverter); }
DataTable { public List<Map<String, String>> asMaps() { if (raw.isEmpty()) return emptyList(); List<String> headers = raw.get(0); List<Map<String, String>> headersAndRows = new ArrayList<>(); for (int i = 1; i < raw.size(); i++) { List<String> row = raw.get(i); LinkedHashMap<String, String> headersAndRow = new LinkedHashMap<>(); for (int j = 0; j < headers.size(); j++) { String key = headers.get(j); String value = row.get(j); if (headersAndRow.containsKey(key)) { String wouldBeReplaced = headersAndRow.get(key); throw duplicateKeyException(String.class, String.class, key, value, wouldBeReplaced); } headersAndRow.put(key, value); } headersAndRows.add(unmodifiableMap(headersAndRow)); } return unmodifiableList(headersAndRows); } private  DataTable(List<List<String>> raw, TableConverter tableConverter); static DataTable create(List<List<String>> raw); static DataTable create(List<List<String>> raw, TableConverter tableConverter); static DataTable emptyDataTable(); TableConverter getTableConverter(); void diff(DataTable actual); void unorderedDiff(DataTable actual); List<String> asList(); List<T> asList(Type itemType); List<List<String>> asLists(); List<List<String>> cells(); List<List<T>> asLists(Type itemType); Map<K, V> asMap(Type keyType, Type valueType); List<Map<String, String>> asMaps(); List<Map<K, V>> asMaps(Type keyType, Type valueType); String cell(int row, int column); List<String> column(final int column); DataTable columns(final int fromColumn); DataTable columns(final int fromColumn, final int toColumn); T convert(Type type, boolean transposed); @Override boolean equals(Object o); @Override int hashCode(); boolean isEmpty(); List<String> row(int row); DataTable rows(int fromRow); DataTable rows(int fromRow, int toRow); DataTable subTable(int fromRow, int fromColumn); DataTable subTable(int fromRow, int fromColumn, int toRow, int toColumn); int height(); int width(); @Override String toString(); void print(Appendable appendable); void print(StringBuilder appendable); DataTable transpose(); }
DataTable { public List<Map<String, String>> asMaps() { if (raw.isEmpty()) return emptyList(); List<String> headers = raw.get(0); List<Map<String, String>> headersAndRows = new ArrayList<>(); for (int i = 1; i < raw.size(); i++) { List<String> row = raw.get(i); LinkedHashMap<String, String> headersAndRow = new LinkedHashMap<>(); for (int j = 0; j < headers.size(); j++) { String key = headers.get(j); String value = row.get(j); if (headersAndRow.containsKey(key)) { String wouldBeReplaced = headersAndRow.get(key); throw duplicateKeyException(String.class, String.class, key, value, wouldBeReplaced); } headersAndRow.put(key, value); } headersAndRows.add(unmodifiableMap(headersAndRow)); } return unmodifiableList(headersAndRows); } private  DataTable(List<List<String>> raw, TableConverter tableConverter); static DataTable create(List<List<String>> raw); static DataTable create(List<List<String>> raw, TableConverter tableConverter); static DataTable emptyDataTable(); TableConverter getTableConverter(); void diff(DataTable actual); void unorderedDiff(DataTable actual); List<String> asList(); List<T> asList(Type itemType); List<List<String>> asLists(); List<List<String>> cells(); List<List<T>> asLists(Type itemType); Map<K, V> asMap(Type keyType, Type valueType); List<Map<String, String>> asMaps(); List<Map<K, V>> asMaps(Type keyType, Type valueType); String cell(int row, int column); List<String> column(final int column); DataTable columns(final int fromColumn); DataTable columns(final int fromColumn, final int toColumn); T convert(Type type, boolean transposed); @Override boolean equals(Object o); @Override int hashCode(); boolean isEmpty(); List<String> row(int row); DataTable rows(int fromRow); DataTable rows(int fromRow, int toRow); DataTable subTable(int fromRow, int fromColumn); DataTable subTable(int fromRow, int fromColumn, int toRow, int toColumn); int height(); int width(); @Override String toString(); void print(Appendable appendable); void print(StringBuilder appendable); DataTable transpose();  }