add equals

This commit is contained in:
Looly 2021-03-10 11:35:48 +08:00
parent 2aae44e569
commit f7cf53455f
2 changed files with 20 additions and 1 deletions

View File

@ -3,7 +3,7 @@
-------------------------------------------------------------------------------------------------------------
# 5.6.0 (2021-03-07)
# 5.6.0 (2021-03-10)
### 新特性
* 【poi 】 重要不再兼容POI-3.x增加兼容POI-5.xissue#I35J6B@Gitee
@ -13,6 +13,7 @@
* 【core 】 增加FuncKeyMapissue#1402@Github
* 【core 】 增加StrMatcherissue#1379@Github
* 【core 】 NumberUtil增加factorial针对BigInterger方法issue#1379@Github
* 【core 】 TreeNode增加equals方法issue#1467@Github
### Bug修复
* 【socket 】 修复Client创建失败资源未释放问题。

View File

@ -2,6 +2,7 @@ package cn.hutool.core.lang.tree;
import java.util.Map;
import java.util.Objects;
/**
* 树节点 每个属性都可以在{@link TreeNodeConfig}中被重命名<br>
@ -129,4 +130,21 @@ public class TreeNode<T> implements Node<T> {
this.extra = extra;
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TreeNode<?> treeNode = (TreeNode<?>) o;
return Objects.equals(id, treeNode.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}