com.lsd.core.domain.ComponentName.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lsd-core Show documentation
Show all versions of lsd-core Show documentation
A library used to generate living sequence diagrams
The newest version!
package com.lsd.core.domain
import com.lsd.core.capitalise
data class ComponentName(val raw: String) {
val normalisedName = convertToValidName(raw)
}
private val illegalChars = "[()/]".toRegex()
private fun convertToValidName(raw: String): String =
raw.replace(illegalChars, " ")
.replace("-", "_")
.split(" ")
.dropLastWhile(String::isEmpty)
.toTypedArray()
.joinToString(transform = String::capitalise, separator = "")
.replace(" ", "")
© 2015 - 2024 Weber Informatics LLC | Privacy Policy