subclassesOfSealed

Registers the child serializers for the sealed type T in the resulting module under the base class. Please note that type T has to be sealed and have a standard serializer, if not a runtime error will be thrown at registration time. If one of T's subclasses is a sealed serializable class on its own, its subclasses are registered recursively as well. If one of T's subclasses is an open polymorphic class an IllegalArgumentException is thrown.

This function is a convenience function for the version that receives a serializer.

Example:

interface Base

@Serializable
sealed interface Sub: Base

@Serializable
class Sub1: Sub

serializersModule {
polymorphic(Base::class) {
subclassesOfSealed<Sub>()
}
}

Registers the child serializers for the sealed type T in the resulting module under the base class. Please note that type T has to be sealed and have a standard serializer, if not a runtime error will be thrown at registration time. If one of T's subclasses is a sealed serializable class on its own, its subclasses are registered recursively as well. If one of T's subclasses is an open polymorphic class an IllegalArgumentException is thrown.

Example:

interface Base

@Serializable
sealed interface Sub: Base

@Serializable
class Sub1: Sub

serializersModule {
polymorphic(Base::class) {
subclassesOfSealed(Sub.serializer())
}
}

Note that if Sub1 is itself open polymorphic this is an error.