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

@@ -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);
}
}