i working on project related hash functions in java. user required override equals function , provide it. while overriding equals may use subset of instance fields of class considering important fields of object. how can extract names of fields user uses inside equals method?
i able names of fields using reflection api want fields have been used inside equals method compare objects.(using reflection not constraint, want way solve problem.)
there no way such thing reflection api know of.
the way i'm aware of read code.
if project depends on requirement, fear you'll have reconsider it.
the correct thing override equals
, hashcode
together, defined joshua bloch in effective java chapter 3. class designer should providing proper hashcode
using fields decided use.
perhaps scheme use hashcode
returned value start.
the problem have no control on developers of libraries depend on do.
if have kind of control, because care classes you write, it's discussion.
Comments
Post a Comment