I am purposefully violating the hashCode contract that says that if we override equals() in our class, we must override hashCode() as well, and I am making sure that no Hash related data structures (like HashMap, HashSet, etc) are using it. The problem is that I fear methods like removeAll() and containsAll() of Lists might use HashMaps internally, and in that case, since I am not overriding hashCode() in my classes, their functionality might break.
Can anyone please conform whether my doubt is valid ? The classes contain a lot of fields that are being used for equality comparison, and I will have to come up with an efficient technique to get a hashCode using all of them. I really don’t require them in any hash-related operations, and as such, I am trying to avoid implementing hashCode()
I think a simple way to test if hashCode() is being used anywhere is to override hashCode() for your class, make it print a statement to the console (or a file if you prefer) and then return some random value (won’t matter since you said you don’t want to use any hash-based classes anyway).
However, i think the best would be to just override it, i’m sure some IDE’s even can do it for you (Eclipse can, for example). If you never expect it to get called, it can’t hurt.