@Test void testGetOrderPosition() { final DefaultTableOrderingModel model = new DefaultTableOrderingModel(); assertThat(model.getOrderPosition("dtoIsNull", "dtoIsNull")).isNull(); model.update(new TableColumnOrdering("tableIdentifier", Arrays.asList("column1", "column2", "column3", "column4"))); assertThat(model.getOrderPosition("tableIdentifierIsNotMatching", "column1")).isNull(); assertThat(model.getOrderPosition("tableIdentifier", "columnIdentifierIsNotMatching")).isNull(); assertThat(model.getOrderPosition("tableIdentifier", "column1")).isEqualTo(new Integer(0)); assertThat(model.getOrderPosition("tableIdentifier", "column2")).isEqualTo(new Integer(1)); assertThat(model.getOrderPosition("tableIdentifier", "column3")).isEqualTo(new Integer(2)); assertThat(model.getOrderPosition("tableIdentifier", "column4")).isEqualTo(new Integer(3)); }
@Override public Integer getOrderPosition(final String tableUniqueIdentifier, final String columnUniqueIdentifier) { if (ordering == null || !ordering.getTableIdentifier().equalsIgnoreCase(tableUniqueIdentifier) || !ordering.getOrderedColumnIdentifiers().contains(columnUniqueIdentifier)) { return null; } int index = 0; for (String uniqueIdentifier : ordering.getOrderedColumnIdentifiers()) { if (columnUniqueIdentifier.equals(uniqueIdentifier)) { return index; } index++; } throw new RuntimeException("Could not get order position of table " + tableUniqueIdentifier + " and column " + columnUniqueIdentifier); }
DefaultTableOrderingModel implements TableColumnOrderingModel { @Override public Integer getOrderPosition(final String tableUniqueIdentifier, final String columnUniqueIdentifier) { if (ordering == null || !ordering.getTableIdentifier().equalsIgnoreCase(tableUniqueIdentifier) || !ordering.getOrderedColumnIdentifiers().contains(columnUniqueIdentifier)) { return null; } int index = 0; for (String uniqueIdentifier : ordering.getOrderedColumnIdentifiers()) { if (columnUniqueIdentifier.equals(uniqueIdentifier)) { return index; } index++; } throw new RuntimeException("Could not get order position of table " + tableUniqueIdentifier + " and column " + columnUniqueIdentifier); } }
DefaultTableOrderingModel implements TableColumnOrderingModel { @Override public Integer getOrderPosition(final String tableUniqueIdentifier, final String columnUniqueIdentifier) { if (ordering == null || !ordering.getTableIdentifier().equalsIgnoreCase(tableUniqueIdentifier) || !ordering.getOrderedColumnIdentifiers().contains(columnUniqueIdentifier)) { return null; } int index = 0; for (String uniqueIdentifier : ordering.getOrderedColumnIdentifiers()) { if (columnUniqueIdentifier.equals(uniqueIdentifier)) { return index; } index++; } throw new RuntimeException("Could not get order position of table " + tableUniqueIdentifier + " and column " + columnUniqueIdentifier); }  }
DefaultTableOrderingModel implements TableColumnOrderingModel { @Override public Integer getOrderPosition(final String tableUniqueIdentifier, final String columnUniqueIdentifier) { if (ordering == null || !ordering.getTableIdentifier().equalsIgnoreCase(tableUniqueIdentifier) || !ordering.getOrderedColumnIdentifiers().contains(columnUniqueIdentifier)) { return null; } int index = 0; for (String uniqueIdentifier : ordering.getOrderedColumnIdentifiers()) { if (columnUniqueIdentifier.equals(uniqueIdentifier)) { return index; } index++; } throw new RuntimeException("Could not get order position of table " + tableUniqueIdentifier + " and column " + columnUniqueIdentifier); }  @Override void update(final TableColumnOrdering ordering); @Override Integer getOrderPosition(final String tableUniqueIdentifier, final String columnUniqueIdentifier); }
DefaultTableOrderingModel implements TableColumnOrderingModel { @Override public Integer getOrderPosition(final String tableUniqueIdentifier, final String columnUniqueIdentifier) { if (ordering == null || !ordering.getTableIdentifier().equalsIgnoreCase(tableUniqueIdentifier) || !ordering.getOrderedColumnIdentifiers().contains(columnUniqueIdentifier)) { return null; } int index = 0; for (String uniqueIdentifier : ordering.getOrderedColumnIdentifiers()) { if (columnUniqueIdentifier.equals(uniqueIdentifier)) { return index; } index++; } throw new RuntimeException("Could not get order position of table " + tableUniqueIdentifier + " and column " + columnUniqueIdentifier); }  @Override void update(final TableColumnOrdering ordering); @Override Integer getOrderPosition(final String tableUniqueIdentifier, final String columnUniqueIdentifier);  }