Problem with Generics

I've read the Sun article on Generics and I still can't get the syntax right to get rid of the " unchecked call to compare(T,T) as a member of the raw type java.util.Comparator" warning from my Java 5 compile of the standard TableSorter thanks to this snippet:

privateclass Rowimplements Comparable{

privateint modelIndex;

public Row(int index){

this.modelIndex = index;

}

publicint compareTo(Object o){

int row1 = modelIndex;

int row2 = ((Row) o).modelIndex;

for (Iterator it = sortingColumns.iterator(); it.hasNext();){

Directive directive = (Directive) it.next();

int column = directive.column;

Object o1 = tableModel.getValueAt(row1, column);

Object o2 = tableModel.getValueAt(row2, column);

int comparison = 0;

// Define null less than everything, except null.

if (o1 ==null && o2 ==null){

comparison = 0;

}elseif (o1 ==null){

comparison = -1;

}elseif (o2 ==null){

comparison = 1;

}else{

comparison = getComparator(column).compare(o1, o2);]

}

if (comparison != 0){

return directive.direction == DESCENDING ? -comparison : comparison;

}

}

return 0;

}

[2637 byte] By [tecomana] at [2007-10-2 21:32:15]
# 1
I don't see any use of the generics syntax. I'm not really sure what you are expecting.
dubwaia at 2007-7-14 0:45:45 > top of Java-index,Core,Core APIs...
# 2

Try:private class Row implements Comparable<Row> {

private int modelIndex;

public Row(int index) {

this.modelIndex = index;

}

public int compareTo(Row r) {

int row1 = modelIndex;

int row2 = r.modelIndex;

for (Iterator it = sortingColumns.iterator(); it.hasNext();) {

Directive directive = (Directive) it.next();

int column = directive.column;

Object o1 = tableModel.getValueAt(row1, column);

Object o2 = tableModel.getValueAt(row2, column);

int comparison = 0;

// Define null less than everything, except null.

if (o1 == null && o2 == null) {

comparison = 0;

} else if (o1 == null) {

comparison = -1;

} else if (o2 == null) {

comparison = 1;

} else {

comparison = getComparator(column).compare(o1, o2);]

}

if (comparison != 0) {

return directive.direction == DESCENDING ? -comparison : comparison;

}

}

return 0;

}

}

dwga at 2007-7-14 0:45:45 > top of Java-index,Core,Core APIs...