Using Jackson JSON Deserialize with w/ nested class?
<p>I'm new to using Jackson &amp; deserializing JSON. I"m trying to create a message processor and have something like the following: </p>

<pre><code>@JsonDeserialize(builder = TestMessage.TestMessageBuilder.class)
private static class TestMessage {
    @Nonnull
    private Long timestamp;
    @Nonnull
    private String regionId;
    @Nonnull
    private String userId;
    @Nonnull
    private String action; 
    @Nonnull
    private TestMessageMetadata metadata;

    @JsonPOJOBuilder(withPrefix = "") 
    public static class TestMessageBuilder {}
}
</code></pre>

<p>The issue is that depending on what kind of <em>action type</em> the message comes in with, the TestMessageMetadata will need to be one of a set of a few different subclasses.
For example if action is "stream", TestMessageMetadata will need to be of type TestMessageStreamMetadata. Each subclass of TestMessageMetadata has different attributes within it (TestMessageStreamMetadata may have 4 fields that only apply to "stream" type messages, while for some other action there might only be 1 field that only applies to that type of action etc.) </p>

<p>The processor needs to only have this one overarching message class, so what are some ways to handle the multiple action types? Help would be greatly appreciated! </p>