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

kotlinx.serialization.hocon.NamingConvention.kt Maven / Gradle / Ivy

The newest version!
package kotlinx.serialization.hocon

import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*

private val NAMING_CONVENTION_REGEX by lazy { "[A-Z]".toRegex() }

@OptIn(ExperimentalSerializationApi::class)
internal fun SerialDescriptor.getConventionElementName(index: Int, useConfigNamingConvention: Boolean): String {
    val originalName = getElementName(index)
    return if (!useConfigNamingConvention) originalName
    else originalName.replace(NAMING_CONVENTION_REGEX) { "-${it.value.lowercase()}" }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy