Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use kotlin sealed class to determine subtypes #59

Closed
mortterna opened this issue Apr 5, 2020 · 1 comment
Closed

Use kotlin sealed class to determine subtypes #59

mortterna opened this issue Apr 5, 2020 · 1 comment
Assignees

Comments

@mortterna
Copy link
Member

mortterna commented Apr 5, 2020

By default jackson defines subtypes for discriminated unions using @JsonSubTypes-annotation. Jackson-module-kotlin allows lighter syntax by reading subclasses directly from sealed class using reflection. Same information could be used by apina but it needs to be read from the bytecode instead relying on kotlin-reflection.

FasterXML/jackson-module-kotlin#239

@komu
Copy link
Member

komu commented Apr 6, 2020

Now that I look at this closer, this might be quite easy to do even without access to Kotlin's own metadata. If we have @JsonTypeInfo without, @JsonSubTypes, we could just search all of the classes in the same package for subclasses. The subclasses of a sealed class need to be in the same file, which means that they will have the same package.

@komu komu self-assigned this Apr 17, 2020
@komu komu closed this as completed in 6c5a933 Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants