oodt-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Starch, Michael D (388L)" <Michael.D.Sta...@jpl.nasa.gov>
Subject Overriding equals/hashCode for the Product class
Date Tue, 11 Oct 2011 23:46:20 GMT
Chris et all,

Do you see any problems overriding the default equals, and hashCode methods in the Product
class (checking by memory address/reference) to something that checks to see if the products
logically represent the same thing (same id, name, etc)?

My issue is the following, I receive data back from the database, with multiple lines representing
a single product (this is a database thing, and the desired behavior).  Thus if I iterate
across the results, I will get multiple Product objects that represent one real Product (and
contain equivalent member variables).  In essence they are the same "Product".  I can write
cleaner, faster, code to combine the results, if I can test them for equality and hash them
directly, without first pulling out the productName, or Id.

This will be a problem if there is some code that expects two "Products" that have identical
member variables to fail the equality test if they are distinct objects.



View raw message