Skip to content

Commit 4d55afc

Browse files
committed
Reformat conditions for compareTo
1 parent 8f93ca2 commit 4d55afc

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

processor/src/main/kotlin/com/tobrun/datacompat/DataCompatProcessor.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,11 @@ class DataCompatProcessor(
236236
toClassName() == Float::class.asTypeName()
237237
val isDouble =
238238
toClassName() == Double::class.asTypeName()
239-
if (isFloat || isDouble) {
240-
if (isMarkedNullable && isDouble) {
241-
"($it·?:·0.0).compareTo(other.$it·?:·0.0)·==·0"
242-
} else if (isMarkedNullable && isFloat) {
243-
"($it·?:·0f).compareTo(other.$it·?:·0f)·==·0"
244-
} else {
245-
"$it.compareTo(other.$it)·==·0"
246-
}
247-
} else {
248-
"$it·==·other.$it"
239+
when {
240+
!isMarkedNullable && (isDouble || isFloat) -> "$it.compareTo(other.$it)·==·0"
241+
isMarkedNullable && isDouble -> "($it·?:·0.0).compareTo(other.$it·?:·0.0)·==·0"
242+
isMarkedNullable && isFloat -> "($it·?:·0f).compareTo(other.$it·?:·0f)·==·0"
243+
else -> "$it·==·other.$it"
249244
}
250245
}
251246
},

0 commit comments

Comments
 (0)