![JAR search and dependency download from the Maven repository](/logo.png)
templates.kotlin.enum_body.mustache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-kotlin-schema-codegen Show documentation
Show all versions of json-kotlin-schema-codegen Show documentation
Code generation from JSON Schema to Kotlin or Java
{{#constraints}}{{^extensibleEnum}}{{&indent}}enum class {{&className}} {
{{#enumValues}}{{&indent}} {{&.}}{{^last}},{{/last}}
{{/enumValues}}{{&indent}}{{&closeBrace}}{{/extensibleEnum}}{{#extensibleEnum}}{{&indent}}@JvmInline
{{&indent}}value class {{&className}}(val name: String) : CharSequence {
{{&indent}} override fun toString(): String = name
{{&indent}} override val length: Int
{{&indent}} get() = name.length
{{&indent}} override fun get(index: Int): Char = name[index]
{{&indent}} override fun subSequence(startIndex: Int, endIndex: Int): {{&className}} =
{{&indent}} valueOf(name.subSequence(startIndex, endIndex).toString())
{{&indent}} companion object {
{{#enumValues}}{{&indent}} val {{&.}} = {{&className}}("{{&.}}")
{{/enumValues}}
{{&indent}} fun valueOf(name: String): {{&className}} = when (name) {
{{#enumValues}}{{&indent}} "{{&.}}" -> {{&.}}
{{/enumValues}}{{&indent}} else -> {{&className}}(name)
{{&indent}} }
{{&indent}} val entries: List<{{&className}}> = listOf(
{{#enumValues}}{{&indent}} {{&.}}{{^last}},{{/last}}
{{/enumValues}}{{&indent}} )
{{&indent}} }
{{&indent}}{{&closeBrace}}{{/extensibleEnum}}{{/constraints}}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy