kotlin-client.infrastructure.ApiAbstractions.kt.mustache Maven / Gradle / Ivy
package {{packageName}}.infrastructure
{{#nonPublicApi}}internal {{/nonPublicApi}}typealias MultiValueMap = MutableMap>
{{#nonPublicApi}}internal {{/nonPublicApi}}fun collectionDelimiter(collectionFormat: String) = when(collectionFormat) {
"csv" -> ","
"tsv" -> "\t"
"pipe" -> "|"
"space" -> " "
else -> ""
}
{{#nonPublicApi}}internal {{/nonPublicApi}}val defaultMultiValueConverter: (item: Any?) -> String = { item -> "$item" }
{{#nonPublicApi}}internal {{/nonPublicApi}}fun toMultiValue(items: Array, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter)
= toMultiValue(items.asIterable(), collectionFormat, map)
{{#nonPublicApi}}internal {{/nonPublicApi}}fun toMultiValue(items: Iterable, collectionFormat: String, map: (item: T) -> String = defaultMultiValueConverter): List {
return when(collectionFormat) {
"multi" -> items.map(map)
else -> listOf(items.joinToString(separator = collectionDelimiter(collectionFormat), transform = map))
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy