title: How to automatically map @DefaultValue to an enum parameter using JAX-RS based Restlet?
body: <p>I have a web API where the user may (or may not) transfer an URL parameter like for  example <code>bird</code>, <code>dog</code> etc.</p>
  
  <p>I want this parameter to be mapped to an enum on the server side, something like:</p>
  
  <pre><code>@POST
  @Path("/zoo")
  public Response createNewAnimal(
                          @QueryParam("animal") 
                          @DefaultValue("CAT") AnimalType type 
                  ) throws Exception 
  
  ...
  
  public enum AnimalType {
      BIG_BIRD,
      SMALL_CAT;
  }
  </code></pre>
  
  <p><strong>But it doesn't work!</strong> </p>
  
  <p>While processing the web request, <code>Enum.valueOf()</code> is being called. And of course it fails, because the <code>bird</code> that user uses as URL parameter doesn't match the identifier in the <code>Enum</code> (<code>AnimalType.BIG_BIRD</code>).</p>
  
  <p>There is no way to override to <code>valueOf()</code> method (it's static...) and setting constructor doesn't help (it's the opposite logical direction).</p>
  
  <p>So maybe you know of a nice solution to this, instead of just using if...else...?</p>