views:

248

answers:

2

Hi, I'm looking for a very specific eclipse plugin that will tell me if a class in my project is not implementing hashCode or/and equals methods.

Does anyone know of such a plugin?

Thanks

+2  A: 

Can you not use the Checkstyle plugin and write your own Checkstyle rule? (There's a Checkstyle rule for overriding equals but not hashCode, but nothing to make sure that both are implemented for all classes, AFAIK.)

Jon Skeet
In the end I used Checkstyle plugin and I did write my own rule. I'll be configuring it so that it gives me not quite so much information (don't want certain classes implementing both, etc). Thanks
PintSizedCat
+4  A: 

Or you can use findbugs

The rule HE_EQUALS_NO_HASHCODE does what you want, and there is a plugin for eclipse

VonC
Does HE_EQUALS_NO_HASHCODE really do what's required? From the question, it sounds like he wants *every* class to implement equals/hashCode - it's not just checking for the presence of one and the absence of the other. It could be that the question isn't well-phrased though.
Jon Skeet
If you are right... I vote for the last part of your comment ("not well phrased" question) ;)
VonC
I would have thought the 'or/and' bit makes it clear enough, maybe you'd be happier if it said 'and/or'? Thanks for the reply though I'm looking into both the Checkstyle and the findbugs to see which is best.
PintSizedCat
I hope he does not want every class to implement both. That's a stupid coding standard (which sadly a few companies do use) that forces useless code to be duplicated all over the place.
finnw
and by a stupid coding standard, you mean, good practice? There are obviously times when you don't need it, but then you can pick and choose them, if you have complex classes then you should be implementing all of the above.
PintSizedCat