FindBugs - how to solve EQ_COMPARETO_USE_OBJECT_EQUALS

Posted by Trick on Stack Overflow See other posts from Stack Overflow or by Trick
Published on 2010-04-09T16:15:25Z Indexed on 2010/04/09 16:33 UTC
Read the original article Hit count: 657

Filed under:
|
|

I am clueless here...

 1: private static class ForeignKeyConstraint implements Comparable<ForeignKeyConstraint> {
 2: String tableName;
 3: String fkFieldName;
 4: 
 5: public int compareTo(ForeignKeyConstraint o) {
 6:    if (this.tableName.compareTo(o.tableName) == 0) {
 7:            return this.fkFieldName.compareTo(o.fkFieldName);
 8:        }
 9:        return this.tableName.compareTo(o.tableName);
10:    }
11: }

In line 6 I get from FindBugs: Bug: net.blabla.SqlFixer$ForeignKeyConstraint defines compareTo(SqlFixer$ForeignKeyConstraint) and uses Object.equals()

Link to definition

I don't know how to correct this :S

© Stack Overflow or respective owner

Related posts about java

Related posts about compareto