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

internal.util.TablesPropertyNamer.kt Maven / Gradle / Ivy

package com.mybatisflex.kotlin.ksp.internal.util

import com.squareup.kotlinpoet.PropertySpec

class TablesPropertyNamer {
    private val timesMap = HashMap()

    private fun getPropertyName(propertySpec: PropertySpec): String {
        val name = propertySpec.name
        var time = timesMap[name]
        return if (time != null) {
            timesMap[name] = ++time
            "${name}$$time"
        } else {
            timesMap[name] = 0
            name
        }
    }

    fun renameProperties(propertySpecs: List): List = buildList {
        propertySpecs.forEach {
            this += it.toBuilder(name = getPropertyName(it)).build()
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy