List<Column> newColumns = new LinkedList<Column>(this.getColumns());
List<Column> selectStarColumns = new LinkedList<Column>(this.selectStarColumns);
Map<String, Column> selectStarColumnMap = new HashMap<String, Column>(this.selectStarColumnsByName);
Map<String, Column> columnMap = new HashMap<String, Column>(columnsByName);
for (Column column : columns) {
Column newColumn = new ImmutableColumn(column.getName(), column.getPropertyTypeName(), column.getRequiredType(),
column.isFullTextSearchable(), column.isOrderable(), column.getMinimum(),
column.getMaximum(), column.getOperators());
newColumns.add(newColumn);
Column existing = columnMap.put(newColumn.getName(), newColumn);
if (existing != null) {
newColumns.remove(existing);
if (selectStarColumnMap.containsKey(existing.getName())) {
// The old column was in the SELECT * list, so the new one should be, too...
selectStarColumnMap.put(newColumn.getName(), newColumn);
selectStarColumns.add(newColumn);
}
}