Skip to content

Commit

Permalink
Ensure indices are sorted in reverse order before removing columns
Browse files Browse the repository at this point in the history
  • Loading branch information
ppouchin committed May 23, 2024
1 parent 39b0fa2 commit b1e1768
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/fr/igred/omero/annotations/TableWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -516,7 +517,7 @@ private void createColumn(int column, String columnName, Class<?> type) {
*/
private Collection<Integer> getEmptyStringColumns() {
Collection<Integer> emptyColumns = new ArrayList<>(0);
for (int j = 0; j < columns.length; j++) {
for (int j = columns.length - 1; j >= 0; j--) {
TableDataColumn column = columns[j];
if (column.getType().equals(String.class)) {
boolean empty = true;
Expand Down Expand Up @@ -881,10 +882,9 @@ public TableData createTable() {
truncateRow();
}

ArrayList<Integer> emptyColumns = new ArrayList<>(getEmptyStringColumns());
for(int i = 0; i <emptyColumns.size(); i++){
removeColumn(emptyColumns.get(i)-i);
}
List<Integer> emptyColumns = new ArrayList<>(getEmptyStringColumns());
emptyColumns.sort(Collections.reverseOrder());
emptyColumns.forEach(this::removeColumn);

return new TableData(columns, data);
}
Expand Down

0 comments on commit b1e1768

Please sign in to comment.