problem with class comparison:
I am currently writing a program that consists of taking 2 data sets ( one from a switch dump and the other from the database ) and identifying which data from set1 is not in set2 and vice versa. Each class ( basically a data structure ) is as follows:
and
to test if a SwitchLine is equal to a DatabaseLine, the following must be true:
esn = esn
telno = telno
SwitchLine.option is one of MANY DatabaseLine.features ( example option "CFW" can be one of ( "100", "400", "115" )
or "CFB" can be one of ( "100", "400", "600" ) )
to test if a DatabaseLine is equal to a Switchline, the reverse is true:
esn = esn
telno = telno
DatabaseLine.feature can be one of MANY SwitchLine.options ( example feature "100" can be one of ( "CFB", "CFW" ) as illustrated above )
I've tried to implement the equals method that worked when I called DatabaseLine.equals( SwitchLine ) and vice versa. The problem arose when I added all the switch lines to a HashSet and tried to utilize the HashSet.contains( DatabaseLIne ), it did not invoke my overridden .equals() method ( which worked when explicitly called ) but used the Object's default .equals() method
To summarize, the pseudo code is something like:
create a set of database data
create a set of switch data
generate a list of switch data that does not have an equal match in the database data
generate a list of database data that does not have an equal match in the switch data
Any suggestions on how to implement the equals ( I've got the hashCode already done as well ) method would be appreciated,
Jamie
[ July 29, 2003: Message edited by: Jamie Robertson ]
I am currently writing a program that consists of taking 2 data sets ( one from a switch dump and the other from the database ) and identifying which data from set1 is not in set2 and vice versa. Each class ( basically a data structure ) is as follows:
and
to test if a SwitchLine is equal to a DatabaseLine, the following must be true:
esn = esn
telno = telno
SwitchLine.option is one of MANY DatabaseLine.features ( example option "CFW" can be one of ( "100", "400", "115" )
or "CFB" can be one of ( "100", "400", "600" ) )
to test if a DatabaseLine is equal to a Switchline, the reverse is true:
esn = esn
telno = telno
DatabaseLine.feature can be one of MANY SwitchLine.options ( example feature "100" can be one of ( "CFB", "CFW" ) as illustrated above )
I've tried to implement the equals method that worked when I called DatabaseLine.equals( SwitchLine ) and vice versa. The problem arose when I added all the switch lines to a HashSet and tried to utilize the HashSet.contains( DatabaseLIne ), it did not invoke my overridden .equals() method ( which worked when explicitly called ) but used the Object's default .equals() method
To summarize, the pseudo code is something like:
create a set of database data
create a set of switch data
generate a list of switch data that does not have an equal match in the database data
generate a list of database data that does not have an equal match in the switch data
Any suggestions on how to implement the equals ( I've got the hashCode already done as well ) method would be appreciated,
Jamie
[ July 29, 2003: Message edited by: Jamie Robertson ]