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

com.lsd.core.domain.ComponentName.kt Maven / Gradle / Ivy

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