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


##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/entities/PluginInfo.java:
##########
@@ -23,12 +23,13 @@
 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;
+public record PluginInfo(
+    @JsonProperty("class") String className,
+    @JsonProperty("type") PluginType type,
+    @JsonProperty("version")
+    @JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = 
NoVersionFilter.class)
+    String version
+) {
 
     @JsonCreator
     public PluginInfo(

Review Comment:
   what is the purpose of this constructor?



##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/entities/ConfigValueInfo.java:
##########
@@ -16,88 +16,25 @@
  */
 package org.apache.kafka.connect.runtime.rest.entities;
 
-import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
 import java.util.List;
-import java.util.Objects;
-
-public class ConfigValueInfo {
-    private final String name;
-    private final String value;
-    private final List<String> recommendedValues;
-    private final List<String> errors;
-    private final boolean visible;
-
-    @JsonCreator
-    public ConfigValueInfo(
-        @JsonProperty("name") String name,
-        @JsonProperty("value") String value,
-        @JsonProperty("recommended_values") List<String> recommendedValues,
-        @JsonProperty("errors") List<String> errors,
-        @JsonProperty("visible") boolean visible) {
-        this.name = name;
-        this.value = value;
-        this.recommendedValues = recommendedValues;
-        this.errors = errors;
-        this.visible = visible;
-    }
-
-    @JsonProperty
-    public String name() {
-        return name;
-    }
-
-    @JsonProperty
-    public String value() {
-        return value;
-    }
-
-    @JsonProperty("recommended_values")
-    public List<String> recommendedValues() {
-        return recommendedValues;
-    }
-
-    @JsonProperty
-    public List<String> errors() {
-        return errors;
-    }
-
-    @JsonProperty
-    public boolean visible() {
-        return visible;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        ConfigValueInfo that = (ConfigValueInfo) o;
-        return Objects.equals(name, that.name) &&
-               Objects.equals(value, that.value) &&
-               Objects.equals(recommendedValues, that.recommendedValues) &&
-               Objects.equals(errors, that.errors) &&
-               Objects.equals(visible, that.visible);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(name, value, recommendedValues, errors, visible);
-    }
 
+public record ConfigValueInfo(
+    @JsonProperty("name") String name,
+    @JsonProperty("value") String value,
+    @JsonProperty("recommended_values") List<String> recommendedValues,
+    @JsonProperty("errors") List<String> errors,
+    @JsonProperty("visible") boolean visible
+) {
     @Override
     public String toString() {

Review Comment:
   ditto



##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/entities/ConfigKeyInfo.java:
##########
@@ -16,153 +16,39 @@
  */
 package org.apache.kafka.connect.runtime.rest.entities;
 
-import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
 import java.util.List;
-import java.util.Objects;
-
-public class ConfigKeyInfo {
-
-    private final String name;
-    private final String type;
-    private final boolean required;
-    private final String defaultValue;
-    private final String importance;
-    private final String documentation;
-    private final String group;
-    private final int orderInGroup;
-    private final String width;
-    private final String displayName;
-    private final List<String> dependents;
-
-    @JsonCreator
-    public ConfigKeyInfo(@JsonProperty("name") String name,
-                         @JsonProperty("type") String type,
-                         @JsonProperty("required") boolean required,
-                         @JsonProperty("default_value") String defaultValue,
-                         @JsonProperty("importance") String importance,
-                         @JsonProperty("documentation") String documentation,
-                         @JsonProperty("group") String group,
-                         @JsonProperty("order_in_group") int orderInGroup,
-                         @JsonProperty("width") String width,
-                         @JsonProperty("display_name") String displayName,
-                         @JsonProperty("dependents") List<String> dependents) {
-        this.name = name;
-        this.type = type;
-        this.required = required;
-        this.defaultValue = defaultValue;
-        this.importance = importance;
-        this.documentation = documentation;
-        this.group = group;
-        this.orderInGroup = orderInGroup;
-        this.width = width;
-        this.displayName = displayName;
-        this.dependents = dependents;
-    }
-
-    @JsonProperty
-    public String name() {
-        return name;
-    }
-
-    @JsonProperty
-    public String type() {
-        return type;
-    }
-
-    @JsonProperty
-    public boolean required() {
-        return required;
-    }
-
-    @JsonProperty("default_value")
-    public String defaultValue() {
-        return defaultValue;
-    }
-
-    @JsonProperty
-    public String documentation() {
-        return documentation;
-    }
-
-    @JsonProperty
-    public String group() {
-        return group;
-    }
-
-    @JsonProperty("order")
-    public int orderInGroup() {
-        return orderInGroup;
-    }
-
-    @JsonProperty
-    public String width() {
-        return width;
-    }
-
-    @JsonProperty
-    public String importance() {
-        return importance;
-    }
-
-    @JsonProperty("display_name")
-    public String displayName() {
-        return displayName;
-    }
-
-    @JsonProperty
-    public List<String> dependents() {
-        return dependents;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        ConfigKeyInfo that = (ConfigKeyInfo) o;
-        return Objects.equals(name, that.name) &&
-               Objects.equals(type, that.type) &&
-               Objects.equals(required, that.required) &&
-               Objects.equals(defaultValue, that.defaultValue) &&
-               Objects.equals(importance, that.importance) &&
-               Objects.equals(documentation, that.documentation) &&
-               Objects.equals(group, that.group) &&
-               Objects.equals(orderInGroup, that.orderInGroup) &&
-               Objects.equals(width, that.width) &&
-               Objects.equals(displayName, that.displayName) &&
-               Objects.equals(dependents, that.dependents);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(name, type, required, defaultValue, importance, 
documentation, group, orderInGroup, width, displayName, dependents);
-    }
 
+public record ConfigKeyInfo(
+    @JsonProperty("name") String name,
+    @JsonProperty("type") String type,
+    @JsonProperty("required") boolean required,
+    @JsonProperty("default_value") String defaultValue,
+    @JsonProperty("importance") String importance,
+    @JsonProperty("documentation") String documentation,
+    @JsonProperty("group") String group,
+    @JsonProperty("order_in_group") int orderInGroup,
+    @JsonProperty("width") String width,
+    @JsonProperty("display_name") String displayName,
+    @JsonProperty("dependents") List<String> dependents
+) {
     @Override
     public String toString() {

Review Comment:
   ditto



##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/entities/ConfigInfos.java:
##########
@@ -16,84 +16,23 @@
  */
 package org.apache.kafka.connect.runtime.rest.entities;
 
-import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
 
 import java.util.List;
-import java.util.Objects;
-
-public class ConfigInfos {
-
-    @JsonProperty("name")
-    private final String name;
-
-    @JsonProperty("error_count")
-    private final int errorCount;
-
-    @JsonProperty("groups")
-    private final List<String> groups;
-
-    @JsonProperty("configs")
-    private final List<ConfigInfo> configs;
-
-    @JsonCreator
-    public ConfigInfos(@JsonProperty("name") String name,
-                       @JsonProperty("error_count") int errorCount,
-                       @JsonProperty("groups") List<String> groups,
-                       @JsonProperty("configs") List<ConfigInfo> configs) {
-        this.name = name;
-        this.groups = groups;
-        this.errorCount = errorCount;
-        this.configs = configs;
-    }
-
-    @JsonProperty
-    public String name() {
-        return name;
-    }
-
-    @JsonProperty
-    public List<String> groups() {
-        return groups;
-    }
-
-    @JsonProperty("error_count")
-    public int errorCount() {
-        return errorCount;
-    }
-
-    @JsonProperty("configs")
-    public List<ConfigInfo> values() {
-        return configs;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-        ConfigInfos that = (ConfigInfos) o;
-        return Objects.equals(name, that.name) &&
-               Objects.equals(errorCount, that.errorCount) &&
-               Objects.equals(groups, that.groups) &&
-               Objects.equals(configs, that.configs);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(name, errorCount, groups, configs);
-    }
 
+public record ConfigInfos(
+    @JsonProperty("name") String name,
+    @JsonProperty("error_count") int errorCount,
+    @JsonProperty("groups") List<String> groups,
+    @JsonProperty("configs") List<ConfigInfo> configs
+) {
     @Override
     public String toString() {

Review Comment:
   I guess this implementation could be replaced by auto-generated code?



##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/entities/PluginInfo.java:
##########
@@ -45,59 +46,23 @@ 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();
-    }
-
-    @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 accessor for `type` to serialize as string
     @Override
-    public int hashCode() {
-        return Objects.hash(className, type, version);
-    }
-
-    @Override
-    public String toString() {
-        return "PluginInfo{" + "className='" + className + '\'' +
-                ", type=" + type.toString() +
-                ", version='" + version + '\'' +
-                '}';
+    @JsonProperty("type")
+    public PluginType type() {

Review Comment:
   Should it change the type from `PluginType` to `String`?



-- 
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