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

kotlin-client.infrastructure.ApiAbstractions.kt.mustache Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
package {{packageName}}.infrastructure

typealias MultiValueMap = Map>

fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
    "csv" -> ","
    "tsv" -> "\t"
    "pipes" -> "|"
    "ssv" -> " "
    else -> ""
}

val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }

fun  toMultiValue(items: List, collectionFormat: String, map: (item: Any?) -> String = defaultMultiValueConverter): List {
    return when(collectionFormat) {
        "multi" -> items.map(map)
        else -> listOf(items.map(map).joinToString(separator = collectionDelimiter(collectionFormat)))
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy