FindBugs - how to solve EQ_COMPARETO_USE_OBJECT_EQUALS

前端 未结 5 1736
后悔当初
后悔当初 2021-01-11 14:50

I am clueless here...

 1: private static class ForeignKeyConstraint implements Comparable {
 2: String tableName;
 3: String fkFi         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 15:20

    Have you tried overriding the equals method as well in SqlFixer.ForeignKeyConstraint?

    I believe the basis of the warning is that, as stated in the definition, strange things can happen if you override compareTo and not equals.

    For more information check out Joshua Bloch's Effective Java, 2nd Edition. Item 12 goes more in depth about the ins and outs of implementing Comparable and some of the things to look out for.

提交回复
热议问题