小编Bre*_*ent的帖子

如何让checkstyle跳过eclipse生成的equals()和hashcode()方法?

我们的项目包含几个类,我们有Eclipse生成的equals()和hashCode()方法(右键单击 - >源代码 - >生成hashCode()和equals()).

例:

@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    final MyTO other = (MyTO) obj;
    if (num != other.num)
        return false;
    if (name == null) {
        if (other.name != null)
            return false;
    } else if (!name.equals(other.name))
        return false;
    if (table == null) {
        if (other.table != null)
            return false;
    } else if (!table.equals(other.table))
        return false;
    return true;
}
Run Code Online (Sandbox Code Playgroud)

这些方法适用于我们的应用程序,但遗憾的是没有通过Checkstyle的圈复杂度检查.由于这些方法是自动生成的,因此我们不关心它们的复杂性.我们可以从Checkstyle中抑制整个类,但我们希望能够排除这两种方法. …

java eclipse equals hashcode checkstyle

18
推荐指数
1
解决办法
5009
查看次数

标签 统计

checkstyle ×1

eclipse ×1

equals ×1

hashcode ×1

java ×1