---
title: "lombok的canEqual/equals"
author: "keating"
date: "2011-11-22T17:22:30Z"
tags: []
categories: ["编程语言"]
slug: "lombok-canequal-equals"
draft: false
lastmod: "2011-11-22T17:22:30Z"
id: 1273026
url: "https://keating.iteye.com/blog/1273026"
---

```java

  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: