public ApiMessageAndVersion toRecord(ImageWriterOptions options) {
        RegisterControllerRecord registrationRecord = new RegisterControllerRecord().
            setControllerId(id).
            setIncarnationId(incarnationId).
            setZkMigrationReady(zkMigrationReady);
        for (Entry<String, Endpoint> entry : listeners.entrySet()) {
            Endpoint endpoint = entry.getValue();
            registrationRecord.endPoints().add(new ControllerEndpoint().
                setName(entry.getKey()).
                setHost(endpoint.host()).
                setPort(endpoint.port()).
                setSecurityProtocol(endpoint.securityProtocol().id));
        }
        for (Entry<String, VersionRange> entry : supportedFeatures.entrySet()) {
            registrationRecord.features().add(new ControllerFeature().
                setName(entry.getKey()).
                setMinSupportedVersion(entry.getValue().min()).
                setMaxSupportedVersion(entry.getValue().max()));
        }
        return new ApiMessageAndVersion(registrationRecord,
            options.metadataVersion().registerControllerRecordVersion());
    }
An immutable class which represents controller registrations.
metadata/src/main/java/org/apache/kafka/metadata/ControllerRegistration.java