Since sealed classes were included in the java 17 release as a stable feature, I think jackson should support them and automatically detect possible subtypes without the @JsonSubTypes annotation.
Usage example
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
sealed interface UserEvent permits UserCreatedEvent, UserBlockedEvent {
int getUserId();
}
@Value
final class UserCreatedEvent implements UserEvent {
LocalDateTime createdAt;
int userId;
//...
}
@Value
final class UserBlockedEvent implements UserEvent {
LocalDateTime blockedFrom;
LocalDateTime blockedTo;
int userId;
//...
}
Additional context
Similar issue for kotlin sealed classes:
FasterXML/jackson-module-kotlin#239
Since
sealed classeswere included in the java 17 release as a stable feature, I think jackson should support them and automatically detect possible subtypes without the@JsonSubTypesannotation.Usage example
Additional context
Similar issue for kotlin sealed classes:
FasterXML/jackson-module-kotlin#239