tock / ai.tock.shared / kotlin.String

Extensions for kotlin.String

changeNamespace

Replace the current namespace with the new namespace.

fun String.changeNamespace(newNamespace: String): String

name

Extract a name from a qualified name (ie namespace:name).

fun String.name(): String

namespace

Extract a namespace from a qualified name (ie namespace:name).

fun String.namespace(): String

namespaceAndName

Extract namespace and name from a qualified name (ie namespace:name).

fun String.namespaceAndName(): Pair<String, String>

withNamespace

Add the specified namespace to a name if the name does not contains yet a namespace, and return the result.

fun String.withNamespace(namespace: String): String

withoutNamespace

Remove the specified namespace from a qualified name if this qualified name contains the namespace, and return the result.

fun String.withoutNamespace(namespace: String? = null): String