I have the following class:
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type"
)
@JsonSubTypes({
@JsonSubTypes.Type(value = CardOne.class, name = "CARD_ONE")
})
public abstract class Card {
String type;
// Getters & Setters
}
public class CardOne extends Card {
String foo;
// Getters & Setters
}
And the following JSON string will serialize no problem into it.
{
"type": "CARD_ONE",
"foo": "bar"
}
How do I make this work if I instead want to use composition with a generic type? I want something like this:
public class Card<T> {
String type;
T cardProperties();
// Getters & Setters
}
public class CardOneProperties {
String foo;
// Getters & Setters
}