title: Spring @RequestBody and Enum value
body: <p>I Have this <strong>enum</strong></p>
  
  <pre><code>public enum Reos {
  
      VALUE1("A"),VALUE2("B"); 
  
      private String text;
  
      Reos(String text){this.text = text;}
  
      public String getText(){return this.text;}
  
      public static Reos fromText(String text){
          for(Reos r : Reos.values()){
              if(r.getText().equals(text)){
                  return r;
              }
          }
          throw new IllegalArgumentException();
      }
  }
  </code></pre>
  
  <p>And a class called Review, this class contains a property of the type <strong>enum Reos</strong>.</p>
  
  <pre><code>public class Review implements Serializable{
  
      private Integer id;
      private Reos reos;
  
      public Integer getId() {return id;}
  
      public void setId(Integer id) {this.id = id;}
  
      public Reos getReos() {return reos;}
  
      public void setReos(Reos reos) {
          this.reos = reos;
      }
  }
  </code></pre>
  
  <p>Finally I have a controller that receives an object review with the <strong>@RequestBody</strong>.</p>
  
  <pre><code>@RestController
  public class ReviewController {
  
      @RequestMapping(method = RequestMethod.POST, value = "/reviews")
      @ResponseStatus(HttpStatus.CREATED)
      public void saveReview(@RequestBody Review review) {
          reviewRepository.save(review);
      }
  }
  </code></pre>
  
  <p>If I invoke the controller with </p>
  
  <pre><code>{"reos":"VALUE1"}
  </code></pre>
  
  <p>There is not problem, but when I invoke with </p>
  
  <pre><code>{"reos":"A"}
  </code></pre>
  
  <p>I get this error</p>
  
  <pre><code>Could not read document: Can not construct instance of com.microservices.Reos from String value 'A': value not one of declared Enum instance names: [VALUE1, VALUE2] at [Source: java.io.PushbackInputStream@23ce847a; line: 1, column: 40] (through reference chain: com.microservices.Review["reos"]); nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of com.microservices.Reos from String value 'A': value not one of declared Enum instance names: [VALUE1, VALUE2] at [Source: java.io.PushbackInputStream@23ce847a; line: 1, column: 40] (through reference chain: com.microservices.Review["reos"])"
  </code></pre>
  
  <p>I undertand the problem, but I wanted to know a way to tell Spring that for every object with Reos enum use Reos.fromText() instead of Reos.valueof().</p>
  
  <p>Is this possible?</p>