public ControllerRegistration build() {
            if (incarnationId == null) throw new RuntimeException("You must set incarnationId.");
            if (listeners == null) throw new RuntimeException("You must set listeners.");
            if (supportedFeatures == null) {
                supportedFeatures = new HashMap<>();
                supportedFeatures.put(MetadataVersion.FEATURE_NAME, VersionRange.of(
                        MetadataVersion.MINIMUM_KRAFT_VERSION.featureLevel(),
                        MetadataVersion.latestProduction().featureLevel()));
            }
            return new ControllerRegistration(id,
                incarnationId,
                zkMigrationReady,
                listeners,
                supportedFeatures);
        }
An immutable class which represents controller registrations.
metadata/src/main/java/org/apache/kafka/metadata/ControllerRegistration.java