Skip to content

Commit f6f500b

Browse files
authored
dataconnect: testing: internal refactor of chain of "ifs" to a "when" expression (#7629)
1 parent 7d35531 commit f6f500b

File tree

1 file changed

+5
-8
lines changed
  • firebase-dataconnect/testutil/src/test/kotlin/com/google/firebase/dataconnect/testutil/property/arbitrary

1 file changed

+5
-8
lines changed

firebase-dataconnect/testutil/src/test/kotlin/com/google/firebase/dataconnect/testutil/property/arbitrary/protoUnitTest.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,11 @@ class protoUnitTest {
317317
}
318318

319319
fun Value.hasNestedKind(kindCase: Value.KindCase): Boolean =
320-
if (this@hasNestedKind.kindCase == kindCase) {
321-
true
322-
} else if (this@hasNestedKind.kindCase == Value.KindCase.LIST_VALUE) {
323-
listValue.hasNestedKind(kindCase)
324-
} else if (this@hasNestedKind.kindCase == Value.KindCase.STRUCT_VALUE) {
325-
structValue.hasNestedKind(kindCase)
326-
} else {
327-
false
320+
when (this.kindCase) {
321+
kindCase -> true
322+
Value.KindCase.LIST_VALUE -> listValue.hasNestedKind(kindCase)
323+
Value.KindCase.STRUCT_VALUE -> structValue.hasNestedKind(kindCase)
324+
else -> false
328325
}
329326

330327
fun Value.calculateExpectedDescendants(): List<DataConnectPathValuePair> = buildList {

0 commit comments

Comments
 (0)