Skip to content

Commit 5d6edd5

Browse files
committed
Keep format
1 parent 983702f commit 5d6edd5

File tree

1 file changed

+12
-13
lines changed
  • firebase-common/src/androidMain/kotlin/dev/gitlive/firebase

1 file changed

+12
-13
lines changed

firebase-common/src/androidMain/kotlin/dev/gitlive/firebase/_decoders.kt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ import kotlinx.serialization.descriptors.PolymorphicKind
1111
import kotlinx.serialization.descriptors.SerialDescriptor
1212
import kotlinx.serialization.descriptors.StructureKind
1313

14-
actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, decodeDouble: (value: Any?) -> Double?): CompositeDecoder =
15-
when(descriptor.kind) {
16-
StructureKind.CLASS, StructureKind.OBJECT, PolymorphicKind.SEALED -> (value as Map<*, *>).let { map ->
17-
FirebaseClassDecoder(decodeDouble, map.size, { map.containsKey(it) }) { desc, index -> map[desc.getElementName(index)] }
18-
}
19-
StructureKind.LIST, PolymorphicKind.SEALED-> (value as List<*>).let {
20-
FirebaseCompositeDecoder(decodeDouble, it.size) { _, index -> it[index] }
21-
}
22-
StructureKind.MAP -> (value as Map<*, *>).entries.toList().let {
23-
FirebaseCompositeDecoder(decodeDouble, it.size) { _, index -> it[index/2].run { if(index % 2 == 0) key else value } }
24-
}
25-
else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet")
26-
}
14+
actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor, decodeDouble: (value: Any?) -> Double?): CompositeDecoder = when(descriptor.kind) {
15+
StructureKind.CLASS, StructureKind.OBJECT, PolymorphicKind.SEALED -> (value as Map<*, *>).let { map ->
16+
FirebaseClassDecoder(decodeDouble, map.size, { map.containsKey(it) }) { desc, index -> map[desc.getElementName(index)] }
17+
}
18+
StructureKind.LIST, PolymorphicKind.SEALED-> (value as List<*>).let {
19+
FirebaseCompositeDecoder(decodeDouble, it.size) { _, index -> it[index] }
20+
}
21+
StructureKind.MAP -> (value as Map<*, *>).entries.toList().let {
22+
FirebaseCompositeDecoder(decodeDouble, it.size) { _, index -> it[index/2].run { if(index % 2 == 0) key else value } }
23+
}
24+
else -> TODO("The firebase-kotlin-sdk does not support $descriptor for serialization yet")
25+
}

0 commit comments

Comments
 (0)