title: No suitable constructor found for type when we use an Enum - Jackson JSON
body: <p>I got a class that looks like this:</p>
  
  <pre><code>   public class Content {
  
          public enum Type {
              TEXT, URL, FILE
          }
  
          public enum Rendering {
              MARKDOWN, HTML, PLAIN, AUTO
          }
  
          public final Type type;
          public final Rendering rendering;
          public final String content;
  
          public Content(Type type, Rendering rendering, String content) {
              this.type = type;
              this.rendering = (rendering != null ? rendering : Rendering.AUTO);
              this.content = content;
          }
  
      }
  </code></pre>
  
  <p>And I got a JSON string that looks like this:</p>
  
  <pre><code>{
      "type": "TEXT",
      "rendering": "AUTO",
      "content": "Lorem ipsum"
  }
  </code></pre>
  
  <p>Now, because fields in <code>Content</code> class is final, Jackson won't work, so I use <a href="http://wiki.fasterxml.com/JacksonMixInAnnotations" rel="nofollow">MixIns</a>:</p>
  
  <pre><code>    public abstract static class ContentMixIn {
          @JsonCreator
          public ContentMixIn(@JsonProperty("type") Type type,
                  @JsonProperty("rendering") Rendering rendering,
                  @JsonProperty("content") String content) {
          }
      }
  </code></pre>
  
  <p>Note: I could have annotated the original class using the constructor parameters, but <code>Content</code> is from a library which I cannot modify</p>
  
  <p>And this is how I use them:</p>
  
  <pre><code>    // ... 
      SimpleModule module = new SimpleModule();
      module.setMixInAnnotation(Content.class, ContentMixIn.class);
      ObjectMapper mapper = new ObjectMapper();
      mapper.registerModule(module);
      mapper.readValue("&lt;the json&gt;", Content.class);
  </code></pre>
  
  <p>This would throw:</p>
  
  <pre><code>com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class com.foo.Content]: can not instantiate from JSON object (need to add/enable type information?)
   at [Source: {
      "type": "TEXT",
      "rendering": "AUTO",
      "content": "Lorem ipsum"
  }; line: 2, column: 2]
      at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)
      at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1063)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:264)
      at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:124)
      at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3051)
      at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2146)
  </code></pre>
  
  <p>Why? By simpley looking at the line number, I assume It's complaining about the <code>enum Type</code>, but how do I correct this?</p>
  
  <p>PS: MixIn is setup correctly because when I replace my Content constructor's enum paramater with String values, it works(although not the way I want it):</p>
  
  <pre><code>        // ... in the Content class
          public Content(String type, String rendering, String content) {
              this.type = null;
              this.rendering = null; 
              this.content = content;
          }
  
          // ... in the mixin class
          @JsonCreator
          public ContentMixIn(@JsonProperty("type") String type,
                              @JsonProperty("rendering") String rendering,
                              @JsonProperty("content") String content) {
          }
  </code></pre>