I think your method is of good architecture and extensible capability. But I
(same column names and same column type).
I can understand that your method works. But I still need to implement
various comparison functions for each type of columns. Are there any way to
implement a comparison function independent of column type?
You have to write code for each type (or use some existing method),
but then polymorphism selects the correct method for you. You just
use the interface.
I felt that polymorphism does not help much here, because much of the
work of comparing a pair of columns is doing the extraction from RowSet
and field number to Java primitive or object.
For example, in my compare function for doubles:
public int compare(RowSet row1, int field1,
RowSet row2, int field2){
double val1 = row1.getDouble(field1);
double val2 = row2.getDouble(field2);
return Double.compare(val1,val2);
}
one third of the method body does the actual comparison, two thirds do
extraction.
Patricia