This is where I'm at:
public final Comparator<Object> ID_IGN_CASE_COMP = new Comparator<Object>() {
public int compare(Object o1, Object o2) {
String s1 = null;
String s2 = null;
try {
Class c = o1.getClass();
IO.println(c.getName()); //java.lang.string instead of Animal
Method method = c.getMethod("getId");
s1 = (String)method.invoke(o1);
s2 = (String)method.invoke(o2);
} catch (NoSuchMethodException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {}
return s1.compareToIgnoreCase(s2);
}
};
private Map< String, Animal> _animals = new TreeMap< String, Animal>(ID_IGN_CASE_COMP);
I'm getting java.lang.string
instead of Animal
class. Any idea on how can I solve this issue?