phax / jcodemodel

A heavily extended fork of the com.sun.codemodel (from 2013/09)
Other
92 stars 34 forks source link

Implemented equals() and hashCode() for IJExpressions #21

Closed leventov closed 10 years ago

phax commented 10 years ago

Thanks for implementing this. As far as I noticed, you did not implement equals/hashCode the way it way intended, but you implemented it in a "semantic" way, meaning is the content of an expression equal to the content of another expression. What do you think about therefore renaming the functions to "isContentEqual" so that users expecting real equals behaviour are not confused???

leventov commented 10 years ago

I don't think anyone already use Expressions' equality, because so far it was a default object equality, i. e. for example new JVar("x") was unequal to another new JVar("x"), that is not really usable.

Currently I'm working on analysis algorithm, actively using HashSets and HashMaps with Expression keys. renaming these equals and hashCode would require to introduce a library dependency with hash tables supporting custom equality (there is no in JDK), or make additional wrappers over Expressions, both ways are undesirable.

phax commented 10 years ago

Alrighty - I was just wondering :)