I have this method that prepares a data table for rendering with all visible columns:
private SearchResultDataCell[] prepareTable(Object[] result) {
int rowIndex = 0;
final SearchResultDataCell row[] = new SearchResultDataCell[COUNT];
row[rowIndex++] = dataCell(notNull(String.valueOf(result[0])));
row[rowIndex++] = dataCell(notNull(String.valueOf(result[1])));
row[rowIndex++] = dataCell(notNull(String.valueOf(result[2])));
row[rowIndex++] = dataCell(notNull(String.valueOf(result[3])));
row[rowIndex++] = dataCell(notNull(String.valueOf(result[4])));
row[rowIndex++] = dataCell(notNull(String.valueOf(result[5])));
row[rowIndex++] = dataCell(notNull(String.valueOf(result[6])));
return row;
}
Now I need to implement a function that allows only special columns to be displayed. As far as I understand, I should pass to the method some collection with visible indices that should be displayed, so the method signature should look like this:
private SearchResultDataCell[] prepareTable(Object[] test, List<Integer> visibleIndexes)
But how could I return a structure with visible columns? How do I rewrite this method to make the code more manageable?
source
share