From d5d25a2f9099529f25108cf4d79398653f3827a4 Mon Sep 17 00:00:00 2001 From: Chia-Ping Tsai Date: Fri, 12 May 2023 21:08:26 +0800 Subject: [PATCH] [COMMON] rewrite admin.Member by java 17 record --- .../java/org/astraea/common/admin/Member.java | 81 ++----------------- 1 file changed, 6 insertions(+), 75 deletions(-) diff --git a/common/src/main/java/org/astraea/common/admin/Member.java b/common/src/main/java/org/astraea/common/admin/Member.java index 824e983cf2..f03fbca4b4 100644 --- a/common/src/main/java/org/astraea/common/admin/Member.java +++ b/common/src/main/java/org/astraea/common/admin/Member.java @@ -16,80 +16,11 @@ */ package org.astraea.common.admin; -import java.util.Objects; import java.util.Optional; -public final class Member { - private final String groupId; - private final String memberId; - private final Optional groupInstanceId; - private final String clientId; - private final String host; - - Member( - String groupId, - String memberId, - Optional groupInstanceId, - String clientId, - String host) { - this.groupId = groupId; - this.memberId = memberId; - this.groupInstanceId = groupInstanceId; - this.clientId = clientId; - this.host = host; - } - - @Override - public String toString() { - return "Member{" - + "memberId='" - + memberId - + '\'' - + ", groupInstanceId=" - + groupInstanceId - + ", clientId='" - + clientId - + '\'' - + ", host='" - + host - + '\'' - + '}'; - } - - public String groupId() { - return groupId; - } - - public String memberId() { - return memberId; - } - - public Optional groupInstanceId() { - return groupInstanceId; - } - - public String clientId() { - return clientId; - } - - public String host() { - return host; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Member member = (Member) o; - return Objects.equals(groupId, member.groupId) - && Objects.equals(memberId, member.memberId) - && Objects.equals(groupInstanceId, member.groupInstanceId) - && Objects.equals(clientId, member.clientId) - && Objects.equals(host, member.host); - } - - @Override - public int hashCode() { - return Objects.hash(groupId, memberId, groupInstanceId, clientId, host); - } -} +public record Member( + String groupId, + String memberId, + Optional groupInstanceId, + String clientId, + String host) {}