Set<Column> sameNameColumns = findColumnsWithSameNames(this.columns);
// Find all the selector names ...
int selectorIndex = 0;
for (int i = 0, max = this.columns.size(); i != max; ++i) {
Column column = this.columns.get(i);
assert column != null;
String selectorName = column.selectorName().name();
if (selectors.add(selectorName)) {
selectorNames.add(selectorName);
int index = selectorIndex;
if (precedingColumns != null) {
index = precedingColumns.getSelectorIndex(selectorName);
if (index < 0) index = selectorIndex;
}
selectorIndexBySelectorName.put(selectorName, index);
++selectorIndex;
}
}
// Now, find all of the column names ...
for (int i = 0, max = this.columns.size(); i != max; ++i) {
Column column = this.columns.get(i);
assert column != null;
String selectorName = column.selectorName().name();
String columnName = columnNameFor(column, names, sameNameColumns, selectors);
assert columnName != null;
propertyNameByColumnName.put(columnName, column.getPropertyName());
selectorNameByColumnName.put(columnName, selectorName);
// Insert the entry by selector name and property name ...
Map<String, ColumnInfo> byPropertyName = columnIndexByPropertyNameBySelectorName.get(selectorName);
if (byPropertyName == null) {
byPropertyName = new HashMap<String, ColumnInfo>();
columnIndexByPropertyNameBySelectorName.put(selectorName, byPropertyName);
}
String columnType = this.columnTypes.get(i);
byPropertyName.put(column.getPropertyName(), new ColumnInfo(i, columnType));
}
if (columns != null && selectorNames.isEmpty()) {
String selectorName = DEFAULT_SELECTOR_NAME;
selectorNames.add(selectorName);
selectorIndexBySelectorName.put(selectorName, 0);