handlebars.kotlin-client.infrastructure.ApiAbstractions.kt.mustache Maven / Gradle / Ivy
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