Join Slack
Powered by
Is it possible to iterate on all kclass types of a...
# announcements
p
Paul Woitaschek
12/12/2018, 9:34 AM
Is it possible to iterate on all kclass types of a sealed class? I use moshi and use
https://github.com/square/moshi/blob/master/adapters/src/main/java/com/squareup/moshi/adapters/PolymorphicJsonAdapterFactory.java
Therefore I need to registert all children of a sealed class and I want some compile time safety and want to make sure I handled all sub classes.
d
diesieben07
12/12/2018, 9:34 AM
Since 1.3 yes it is:
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.reflect/-k-class/sealed-subclasses.html
p
Paul Woitaschek
12/12/2018, 10:06 AM
Thanks a lot! Follow up:
https://github.com/square/moshi/issues/772
3
Views
Open in Slack
Previous
Next