Hello everybody,
I have an old personal project written in Java 1.4 that I am porting to 1.5 (in which I am a still newbie) for version 2. Besides adding new features to it and refactoring code, I am also migrating to generic collections, annotations etc.
There is a particular piece of code that I don't know how to change to 1.5 and don't want to add a @SupressWarnings on it. It goes like this:
if (value instanceof Comparable) {
isMatch = (((Comparable) value).compareTo(selectedValue) == 0);
} else {
//fallback to equals
isMatch = selectedValue.equals(value);
}
It is just a simple comparison with an extensive match in compareTo() or defaulting to plain equals() if not a Comparable type.
I am getting a : Comparable is a raw type. References to generic type Comparable<T> should be parameterized
warning.
How do I modify the above code to 1.5 and clear the warning. Or is there no choice but to add @SuppressWarnings?
Thanks!