com.casadetasha.kexp.sproute.processor.ktx.Kotlin.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sproutes-processor Show documentation
Show all versions of sproutes-processor Show documentation
KAPT processor to manage routing boilerplate for KTOR projects. Use in conjunction with the sproutes library.
package com.casadetasha.kexp.sproute.processor.ktx
import kotlin.collections.removeFirst as removeFirstFromCollection
internal fun Boolean.orElse(function: () -> Unit) {
if (!this) function()
}
internal fun String.asPath() : String {
return this.replace(".", "/")
}
internal fun String.asSubPackageOf(classPackage: String) : String {
return this.removePrefix(classPackage)
}
internal fun Collection.removeFirst(): List {
return toMutableList().apply { removeFirstFromCollection() }
}
internal fun List.asVarArgs(): String = this.let {
return joinToString(", ") { "\"$it\"" }
}
internal fun List?.ifNotEmpty(function: (List) -> Unit): Boolean {
if (this == null || isEmpty()) {
return false
}
function(this)
return true
}