title: Jackson Annotation decide on one field class based on another field
body: <p>I have multiple implementations for class AbstractAsset </p>
  
  <p>I would like to choose the asset impl based on the type . 
  I managed to do so in inheritance and with </p>
  
  <blockquote>
    <p>@JsonSubTypes</p>
  </blockquote>
  
  <p>the problem is , inside couple of the asset I already have the same type string which makes it </p>
  
  <pre><code>@Data
  @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
  @JsonSubTypes({
    @JsonSubTypes.Type(value = TitleAssetDTO.class, name = "TITLE"),
    @JsonSubTypes.Type(value = VideoAssetDTO.class, name = "VIDEO"),
    @JsonSubTypes.Type(value = ImageAssetDTO.class, name = "IMAGE"),
    @JsonSubTypes.Type(value = DataAssetDTO.class, name = "DATA")
  })
  @AllArgsConstructor
  @NoArgsConstructor
  public abstract class AbstractAssetDTO {
    @NotNull private String type;
    @NotNull private String key;
  }
  </code></pre>
  
  <p>and for instance </p>
  
  <pre><code>public class TitleAssetDTO extends AbstractAssetDTO {
  
    private Title title;
  
    public Title getTitle() {
      return title;
    }
  
    public void setTitle(Title title) {
      this.title = title;
    }
  
    public TitleAssetDTO() {
      this.title = new Title();
    }
  
    @Data
    public class Title {
      private Integer maxLength;
    }
  
    @JsonIgnore
    public int getMaxLength() {
      return title.maxLength;
    }
  }
  </code></pre>
  
  <p>The problem is that other asset types as the type string inside them in the json so I assume that working with inheritance is not the right way to solve this , composite like : </p>
  
  <pre><code>class myClass{ 
  String type;
  AbstractAsset asset;
  }
  </code></pre>
  
  <p>would be a better way to implement this , how can I do so ? </p>