All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.infobip.kafkistry.sql.sources.common.kt Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
@file:Suppress("JpaDataSourceORMInspection")

package com.infobip.kafkistry.sql.sources

import org.apache.kafka.clients.admin.ConfigEntry
import com.infobip.kafkistry.kafka.ConfigValue
import com.infobip.kafkistry.model.KafkaClusterIdentifier
import jakarta.persistence.Column
import jakarta.persistence.Embeddable
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated

fun Map.Entry.toKafkaConfigEntry() = KafkaConfigEntry().apply {
    key = [email protected]
    value = [email protected]
}

fun Map.Entry.toExistingKafkaConfigEntry() = ExistingConfigEntry().apply {
    val mapEntry = this@toExistingKafkaConfigEntry
    entry = KafkaConfigEntry().apply {
        key = mapEntry.key
        value = mapEntry.value.value
    }
    with(mapEntry.value) {
        [email protected] = default
        [email protected] = readOnly
        [email protected] = sensitive
        configSource = source
    }
}

@Embeddable
class PresenceCluster {
    lateinit var cluster: KafkaClusterIdentifier
}

@Suppress("RedundantGetter")    //for hibernate annotations on get()
@Embeddable
class ExistingConfigEntry {

    lateinit var entry: KafkaConfigEntry

    @Column(nullable = false)
    var isDefault: Boolean? = null
        @Column(name = "isDefault", nullable = false)
        get() = field

    @Column(nullable = false)
    var isReadOnly: Boolean? = null
        @Column(name = "isReadOnly", nullable = false)
        get() = field

    @Column(nullable = false)
    var isSensitive: Boolean? = null
        @Column(name = "isSensitive", nullable = false)
        get() = field

    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    var configSource: ConfigEntry.ConfigSource? = null
        @Enumerated(EnumType.STRING)
        get() = field
}

@Embeddable
class KafkaConfigEntry {

    lateinit var key: String
    var value: String? = null
}







© 2015 - 2024 Weber Informatics LLC | Privacy Policy