toTypeName

fun toTypeName(raw: String, fallback: String = "Element"): String

Convert an arbitrary string into a valid Kotlin class name.

Rules:

  • If the input already looks like a Kotlin identifier (no separators) we keep internal capitals intact.

  • Otherwise we split on non-alphanumerics and build UpperCamelCase.

  • If the name would start with a digit, we prefix it with Stig.

  • If the result collides with a Kotlin keyword, we prefix it with Stig.

Generated with STIG