chia7712 commented on code in PR #20393:
URL: https://github.com/apache/kafka/pull/20393#discussion_r2319705983


##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/entities/PluginInfo.java:
##########
@@ -19,85 +19,30 @@
 import org.apache.kafka.connect.runtime.isolation.PluginDesc;
 import org.apache.kafka.connect.runtime.isolation.PluginType;
 
-import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
-import java.util.Objects;
-
-public class PluginInfo {
-    private final String className;
-    private final PluginType type;
-    private final String version;
-
-    @JsonCreator
-    public PluginInfo(
-        @JsonProperty("class") String className,
-        @JsonProperty("type") PluginType type,
-        @JsonProperty("version") String version
-    ) {
-        this.className = className;
-        this.type = type;
-        this.version = version;
-    }
-
-    public PluginInfo(PluginDesc<?> plugin) {
-        this(plugin.className(), plugin.type(), plugin.version());
-    }
-
-    @JsonProperty("class")
-    public String className() {
-        return className;
-    }
-
-    @JsonProperty("type")
-    public String type() {
-        return type.toString();
-    }
-
+public record PluginInfo(
+    @JsonProperty("class") String className,
+    @JsonProperty("type") PluginType type,
     @JsonProperty("version")
     @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = 
NoVersionFilter.class)
-    public String version() {
-        return version;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        PluginInfo that = (PluginInfo) o;
-        return Objects.equals(className, that.className) &&
-               Objects.equals(type, that.type) &&
-               Objects.equals(version, that.version);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(className, type, version);
-    }
-
-    @Override
-    public String toString() {
-        return "PluginInfo{" + "className='" + className + '\'' +
-                ", type=" + type.toString() +
-                ", version='" + version + '\'' +
-                '}';
+    String version
+) {
+    public PluginInfo(PluginDesc<?> plugin) {
+        this(plugin.className(), plugin.type(), plugin.version());
     }
 
     public static final class NoVersionFilter {
-        // This method is used by Jackson to filter the version field for 
plugins that don't have a version
+        // Used by Jackson to filter out undefined versions
+        @Override
         public boolean equals(Object obj) {
             return PluginDesc.UNDEFINED_VERSION.equals(obj);
         }
 
-        // Dummy hashCode method to not fail compilation because of equals() 
method

Review Comment:
   Could you please keep this comment? Otherwise, the implementation `return 
super.hashCode();` look odd to me, since it's essentially identical to the 
default implementation 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to