Byron Woodfork
12/02/2019, 10:25 PMclass ShapeTypeAdapter: TypeAdapter<Shape> {
override fun classFor(type: Any): KClass<out Shape> = when(type as Int) {
1 -> Rectangle::class
2 -> Circle::class
else -> throw IllegalArgumentException("Unknown type: $type")
}
}
Animesh Sahu
12/03/2019, 4:08 PM{}
a lambda instead throwing an exception, for caching the exception you can do that whereever you parse the objectByron Woodfork
12/03/2019, 9:13 PM