Repository: apache/kafka
File: connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ConnectorConfig.java (Java)

Code before:
         * Get the ConfigDef from the given entity.
         * This is necessary because there's no abstraction across {@link Transformation#config()} and
         * {@link Predicate#config()}.
         */
        protected abstract ConfigDef config(T t);

        /**
         * The transformation or predicate plugins (as appropriate for T) to be used
         * for the {@link ClassRecommender}.
         */
        protected abstract Set<PluginDesc<T>> plugins();

        protected abstract ConfigDef.Recommender versionRecommender(String typeConfig);

        /**
         * Recommend bundled transformations or predicates.
         */
        final class ClassRecommender implements ConfigDef.Recommender {

            @Override
            public List<Object> validValues(String name, Map<String, Object> parsedConfig) {
                List<Object> result = new ArrayList<>();
                for (PluginDesc<T> plugin : plugins()) {
                    result.add(plugin.pluginClass());
                }
                return List.copyOf(result);
            }

            @Override
            public boolean visible(String name, Map<String, Object> parsedConfig) {
                return true;
            }
        }
    }

    private record ConverterDefaults(String type, String version) {
    }

    public static class PluginVersionValidator implements ConfigDef.Validator {

        @Override
        public void ensureValid(String name, Object value) {

            try {
                PluginUtils.connectorVersionRequirement((String) value);
            } catch (InvalidVersionSpecificationException e) {
                throw new VersionedPluginLoadingException(e.getMessage());
            }
        }
    }
}

Review comment (suggestion):
```java
            public List<Object> validValues(String name, Map<String, Object> parsedConfig) {
                return plugins().stream().map(p -> (Object) p.pluginClass()).toList();
            }
```

Code after:
         * Get the ConfigDef from the given entity.
         * This is necessary because there's no abstraction across {@link Transformation#config()} and
         * {@link Predicate#config()}.
         */
        protected abstract ConfigDef config(T t);

        /**
         * The transformation or predicate plugins (as appropriate for T) to be used
         * for the {@link ClassRecommender}.
         */
        protected abstract Set<PluginDesc<T>> plugins();

        protected abstract ConfigDef.Recommender versionRecommender(String typeConfig);

        /**
         * Recommend bundled transformations or predicates.
         */
        final class ClassRecommender implements ConfigDef.Recommender {

            @Override
            public List<Object> validValues(String name, Map<String, Object> parsedConfig) {
                return plugins().stream().map(p -> (Object) p.pluginClass()).toList();
            }

            @Override
            public boolean visible(String name, Map<String, Object> parsedConfig) {
                return true;
            }
        }
    }

    private record ConverterDefaults(String type, String version) {
    }

    public static class PluginVersionValidator implements ConfigDef.Validator {

        @Override
        public void ensureValid(String name, Object value) {

            try {
                PluginUtils.connectorVersionRequirement((String) value);
            } catch (InvalidVersionSpecificationException e) {
                throw new VersionedPluginLoadingException(e.getMessage());
            }
        }
    }
}