Override hashCode and equals to avoid repeated item (#8207)

This commit is contained in:
Oliver 2022-04-20 10:00:39 +08:00 committed by GitHub
parent 8401b8c836
commit 8838ae1417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,8 @@
package com.alibaba.nacos.client.naming.remote.gprc.redo.data;
import java.util.Objects;
/**
* Nacos naming redo data.
*
@ -127,4 +129,22 @@ public abstract class RedoData<T> {
*/
REMOVE;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
RedoData<?> redoData = (RedoData<?>) o;
return registered == redoData.registered && unregistering == redoData.unregistering
&& serviceName.equals(redoData.serviceName) && groupName.equals(redoData.groupName) && data.equals(redoData.data);
}
@Override
public int hashCode() {
return Objects.hash(serviceName, groupName, registered, unregistering, data);
}
}