Generics: Comparator type safety and unchecked conversion
807569Jun 26 2006 — edited Jul 7 2006Hi,
I'm new to generics and I'm getting the following unchecked warning when using TableSorter in java 1.5
protected Comparator<Object> getComparator(int column) {
Class columnType = tableModel.getColumnClass(column);
Comparator comparator= columnComparators.get(columnType);
if (comparator!= null) {
return comparator; // warning here
}
if (Comparable.class.isAssignableFrom(columnType)) {
return COMPARABLE_COMAPRATOR;
}
return LEXICAL_COMPARATOR;
}
warning is : Type safety: The expression of type comparator needs unchecked conversion to conform to Comparator<Object>.
Any ideas on how to fix this?
Thanks for your help