File tree Expand file tree Collapse file tree
lib/src/main/kotlin/com/openmeteo/api/common/query Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,18 +22,24 @@ interface Query {
2222 key(property, T ::class )
2323
2424 @OptIn(InternalSerializationApi ::class , ExperimentalSerializationApi ::class )
25- internal fun value (any : Any? ): String =
25+ internal fun value (any : Any? ): String? =
2626 when (any) {
27- is Iterable <* > -> any.joinToString(" ," ) { value(it) }
28- is Enum <* > -> any.javaClass.kotlin.serializer()
29- .descriptor.getElementName(any.ordinal)
27+ is Iterable <* > -> any
28+ .mapNotNull { value(it) }
29+ .takeUnless { it.isEmpty() }
30+ ?.joinToString(" ," )
31+ is Enum <* > -> runCatching {
32+ any.javaClass.kotlin.serializer()
33+ .descriptor.getElementName(any.ordinal)
34+ }.getOrNull()
35+ null -> null
3036 else -> any.toString()
3137 }
3238
3339 }
3440
3541 private fun value (property : KProperty1 <Query , * >) =
36- property.get(this )?. let { Companion .value(it) }
42+ Companion .value( property.get(this ))
3743
3844 private val memberProperties
3945 get() =
You can’t perform that action at this time.
0 commit comments