Reputation: 26597
The following code works fine with generic type parameter Column
but how do I make this work with type parameter Column<N>
where N
is type used for field columns
.
class Cols_Iterables2<Column> extends Iterable2<Column>{
ColumnList<N> columns;
public Cols_Iterables2(ColumnList<N> columnList) {
this.columns = columnList;
}
@Override
public Column get(int index) {
return columns.getColumnByIndex(index);
}
}
Upvotes: 0
Views: 54
Reputation: 10082
Assuming that your ColumnList<N>
has the getColumnByIndex
method defined roughly as follows
class ColumnList<N> {
public Column<N> getColumnByIndex(int index) {
just parametrise your Cols_Iterables2
class with N
:
class Cols_Iterables2<N> extends Iterable2<Column<N>> {
ColumnList<N> columns;
public Cols_Iterables2(ColumnList<N> columnList) {
this.columns = columnList;
}
@Override
public Column<N> get(int index) {
return columns.getColumnByIndex(index);
}
}
Upvotes: 2