diff --git a/common/src/main/java/org/astraea/common/metrics/BeanObject.java b/common/src/main/java/org/astraea/common/metrics/BeanObject.java index 158aafdc4d..df80eed7f7 100644 --- a/common/src/main/java/org/astraea/common/metrics/BeanObject.java +++ b/common/src/main/java/org/astraea/common/metrics/BeanObject.java @@ -23,11 +23,11 @@ import java.util.stream.Collectors; /** Snapshot of remote MBean value */ -public class BeanObject { - private final String domainName; - private final Map properties; - private final Map attributes; - private final long createdTimestamp; +public record BeanObject( + String domainName, + Map properties, + Map attributes, + long createdTimestamp) { /** * construct a {@link BeanObject} @@ -63,44 +63,4 @@ public BeanObject( .collect(Collectors.toUnmodifiableMap(Entry::getKey, Entry::getValue)); this.createdTimestamp = createdTimestamp; } - - public String domainName() { - return domainName; - } - - public Map properties() { - return properties; - } - - public Map attributes() { - return attributes; - } - - public long createdTimestamp() { - return createdTimestamp; - } - - @Override - public String toString() { - String propertyList = - properties.entrySet().stream() - .map((entry -> entry.getKey() + "=" + entry.getValue())) - .collect(Collectors.joining(",")); - return "[" + domainName + ":" + propertyList + "]\n" + attributes; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - BeanObject that = (BeanObject) o; - return domainName.equals(that.domainName) - && properties.equals(that.properties) - && attributes.equals(that.attributes); - } - - @Override - public int hashCode() { - return Objects.hash(domainName, properties, attributes); - } }