I have inner (private) class, and I need to make it Comparable
, so I can create a TreeSet
of it.
When I add compareTo
method, Sonar wants me to add also equals
, than hashcode
… And even if I was willing to add them, it results in Eclipse warning - that they are not used.
Maybe this rule should have an exception for inner classes?
Hi, I would add a doubt on the value of the Eclipse warning here : if you want to create a collection and more specifically a TreeSet
out of any class (inner class or not) you should implement equals and hashcode and respect the comparable contract with it.