-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Benefit A
Default values are still not supported in Moshi, yet Kotlin can support them natively. This means that List no longer needs to be nullable, with some obvious other examples being primitives.
Benefit B
Another benefit is that you access the Kotlin fields directly instead of having to use a getter.
Java
if (event.repo() != null) {
event.repo().someFunction(); // Warning of calling method someFunction() on potentially null object
}Kotlin
if (event.repo != null) {
event.repo.someFunction(); // No warning occurs as nullability has been checked for
}Benefit C
Java
event.repo().someFunction(); // Can cause NPE as event.repo() hasn't been checked for nullabilityKotlin
event.repo.someFunction(); // Would be a compiler error as event.repo hasn't been checked for nullabilityBenefit D
Much more concise models in Kotlin, as builders, immutable objects, nullability status, are all extremely concise in Kotlin.
Benefit E
This isn't a huge benefit, but one less library (i.e. AutoValue) is used.
Metadata
Metadata
Assignees
Labels
No labels