@Test void testConvertTableColumnOrdering() { final String json = "[{\"identifier\":\"column1\",\"position\":0},{\"identifier\":\"column2\",\"position\":1},{\"identifier\":\"column3\",\"position\":2},{\"identifier\":\"column4\",\"position\":3},{\"identifier\":\"column5\",\"position\":4}]"; final String tableIdentifier = "tableIdentifier"; final TableColumnOrdering ordering = new JsonToModelConverter().convertTableColumnOrdering(tableIdentifier, json); assertThat(ordering.getTableIdentifier()).isEqualTo(tableIdentifier); assertThat(ordering.getOrderedColumnIdentifiers()) .containsExactly("column1", "column2", "column3", "column4", "column5"); }
public TableColumnOrdering convertTableColumnOrdering(final String tableIdentifier, final String json) { final String[] split = this.splitColumns(json); final List<Ordering> orderings = new ArrayList<>(); for (String column : split) { final String[] attribute = this.splitAttributes(column); final String identifier = attribute[0].split(":")[1]; final String position = attribute[1].split(":")[1]; orderings.add(new Ordering(identifier, Integer.valueOf(position))); } Collections.sort(orderings, new Comparator<Ordering>() { @Override public int compare(Ordering o1, Ordering o2) { return o1.getIndex().compareTo(o2.getIndex()); } }); final List<String> columnIdentifier = new ArrayList<>(); for (Ordering ordering : orderings) { columnIdentifier.add(ordering.getIdentifier()); } return new TableColumnOrdering(tableIdentifier, columnIdentifier); }
JsonToModelConverter { public TableColumnOrdering convertTableColumnOrdering(final String tableIdentifier, final String json) { final String[] split = this.splitColumns(json); final List<Ordering> orderings = new ArrayList<>(); for (String column : split) { final String[] attribute = this.splitAttributes(column); final String identifier = attribute[0].split(":")[1]; final String position = attribute[1].split(":")[1]; orderings.add(new Ordering(identifier, Integer.valueOf(position))); } Collections.sort(orderings, new Comparator<Ordering>() { @Override public int compare(Ordering o1, Ordering o2) { return o1.getIndex().compareTo(o2.getIndex()); } }); final List<String> columnIdentifier = new ArrayList<>(); for (Ordering ordering : orderings) { columnIdentifier.add(ordering.getIdentifier()); } return new TableColumnOrdering(tableIdentifier, columnIdentifier); } }
JsonToModelConverter { public TableColumnOrdering convertTableColumnOrdering(final String tableIdentifier, final String json) { final String[] split = this.splitColumns(json); final List<Ordering> orderings = new ArrayList<>(); for (String column : split) { final String[] attribute = this.splitAttributes(column); final String identifier = attribute[0].split(":")[1]; final String position = attribute[1].split(":")[1]; orderings.add(new Ordering(identifier, Integer.valueOf(position))); } Collections.sort(orderings, new Comparator<Ordering>() { @Override public int compare(Ordering o1, Ordering o2) { return o1.getIndex().compareTo(o2.getIndex()); } }); final List<String> columnIdentifier = new ArrayList<>(); for (Ordering ordering : orderings) { columnIdentifier.add(ordering.getIdentifier()); } return new TableColumnOrdering(tableIdentifier, columnIdentifier); }  }
JsonToModelConverter { public TableColumnOrdering convertTableColumnOrdering(final String tableIdentifier, final String json) { final String[] split = this.splitColumns(json); final List<Ordering> orderings = new ArrayList<>(); for (String column : split) { final String[] attribute = this.splitAttributes(column); final String identifier = attribute[0].split(":")[1]; final String position = attribute[1].split(":")[1]; orderings.add(new Ordering(identifier, Integer.valueOf(position))); } Collections.sort(orderings, new Comparator<Ordering>() { @Override public int compare(Ordering o1, Ordering o2) { return o1.getIndex().compareTo(o2.getIndex()); } }); final List<String> columnIdentifier = new ArrayList<>(); for (Ordering ordering : orderings) { columnIdentifier.add(ordering.getIdentifier()); } return new TableColumnOrdering(tableIdentifier, columnIdentifier); }  TableColumnVisibility convertTableColumnVisibility(final String tableIdentifier, final String json); TableColumnOrdering convertTableColumnOrdering(final String tableIdentifier, final String json); }
JsonToModelConverter { public TableColumnOrdering convertTableColumnOrdering(final String tableIdentifier, final String json) { final String[] split = this.splitColumns(json); final List<Ordering> orderings = new ArrayList<>(); for (String column : split) { final String[] attribute = this.splitAttributes(column); final String identifier = attribute[0].split(":")[1]; final String position = attribute[1].split(":")[1]; orderings.add(new Ordering(identifier, Integer.valueOf(position))); } Collections.sort(orderings, new Comparator<Ordering>() { @Override public int compare(Ordering o1, Ordering o2) { return o1.getIndex().compareTo(o2.getIndex()); } }); final List<String> columnIdentifier = new ArrayList<>(); for (Ordering ordering : orderings) { columnIdentifier.add(ordering.getIdentifier()); } return new TableColumnOrdering(tableIdentifier, columnIdentifier); }  TableColumnVisibility convertTableColumnVisibility(final String tableIdentifier, final String json); TableColumnOrdering convertTableColumnOrdering(final String tableIdentifier, final String json);  }