com.ancientlightstudios.quarkus.kotlin.openapi.transformer.NameRegistry.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-kotlin-openapi-maven-plugin Show documentation
Show all versions of quarkus-kotlin-openapi-maven-plugin Show documentation
A Maven plugin to use the OpenAPI generator.
package com.ancientlightstudios.quarkus.kotlin.openapi.transformer
import com.ancientlightstudios.quarkus.kotlin.openapi.models.transformed.name.ClassName
class NameRegistry {
private val nameBuilder = mutableMapOf()
fun uniqueNameFor(name: ClassName): ClassName {
val builder = nameBuilder[name]
return if (builder != null) {
builder.next()
} else {
nameBuilder[name] = NameBuilder(name)
name
}
}
private class NameBuilder(private val name: ClassName) {
private var nextIndex = 1
fun next() = name.extend(postfix = "${nextIndex++}")
}
}