From 71ee8401119e058e49aebec40a9517cb12d0b46d Mon Sep 17 00:00:00 2001 From: Nicholas2015 <799327210@qq.com> Date: Sat, 29 Jun 2019 12:59:35 +0800 Subject: [PATCH] Collective data de-duplication --- .../alibaba/nacos/naming/pojo/Subscriber.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/naming/src/main/java/com/alibaba/nacos/naming/pojo/Subscriber.java b/naming/src/main/java/com/alibaba/nacos/naming/pojo/Subscriber.java index 6cea0ee38..ee2f81acb 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/pojo/Subscriber.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/pojo/Subscriber.java @@ -16,6 +16,7 @@ package com.alibaba.nacos.naming.pojo; import java.io.Serializable; +import java.util.Objects; /** * @author nicholas @@ -91,4 +92,38 @@ public class Subscriber implements Serializable { public void setServiceName(String serviceName) { this.serviceName = serviceName; } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Subscriber that = (Subscriber) o; + return Objects.equals(addrStr, that.addrStr) && + Objects.equals(agent, that.agent) && + Objects.equals(app, that.app) && + Objects.equals(ip, that.ip) && + Objects.equals(namespaceId, that.namespaceId) && + Objects.equals(serviceName, that.serviceName); + } + + @Override + public int hashCode() { + return Objects.hash(addrStr, agent, app, ip, namespaceId, serviceName); + } + + @Override + public String toString() { + return "Subscriber{" + + "addrStr='" + addrStr + '\'' + + ", agent='" + agent + '\'' + + ", app='" + app + '\'' + + ", ip='" + ip + '\'' + + ", namespaceId='" + namespaceId + '\'' + + ", serviceName='" + serviceName + '\'' + + '}'; + } }