ITeye博客

lombok的canEqual/equals

keating · 2011-11-22 17:22 · Java · 编程语言 · Markdown


  public boolean equals(Object o)
  {
    if (o == this)
      return true;
    if (!(o instanceof PayType))
      return false;
    PayType other = (PayType)o;
    return other.canEqual(this);
  }

  public boolean canEqual(Object other)
  {
    return other instanceof PayType;
  }

要是一个类没有属性,那么equals方法就悲剧了。

恰巧,我在一个子类总使用了@Data,覆盖了父类的equlas,然后如上说是。结果这个子类的JcomboBox的下拉框怎么拉,都是第一个item!现在才知道问题在equals啊。。。

重来我的博客,算温锅了 :evil:

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。