title: Spring map Enum in @RequestBody
body: <p>In my controller I made an endpoint that allows status change:</p>
  
  <pre><code>@RequestMapping(value = "{ids}" + "/" + "status", method = RequestMethod.PUT)
  public ResponseEntity&lt;Void&gt; changeStatus(@PathVariable final List&lt;Integer&gt; ids,
                                           @NotNull @RequestBody final String status) {
      deviceService.updateStatus(ids, status);
      return new ResponseEntity&lt;&gt;(HttpStatus.NO_CONTENT);
  }
  </code></pre>
  
  <p>And enum looks like this:</p>
  
  <pre><code>public enum DeviceStatus {
      ACTIVE, INACTIVE, DELETED, ARCHIVED;
  
      @JsonCreator
      public static DeviceStatus parseWithValidation(String status) {
          final String upperCaseStatus = status.toUpperCase();
          if (exists(upperCaseStatus)) {
              return DeviceStatus.valueOf(upperCaseStatus);
          } else {
              throw new UnsupportedStatusException();
          }
      }
  
      private static boolean exists(final String upperCaseStatus) {
          return Arrays.stream(values()).anyMatch(c -&gt; c.name().equals(upperCaseStatus));
      }
  }
  </code></pre>
  
  <p>But <code>Device</code> domain object has a field <code>Status</code> of type <code>DeviceStatus</code>, so how should change status:</p>
  
  <pre><code>public void updateStatus(final List&lt;Integer&gt; ids, final String status) {
          getByIds(ids).forEach(device -&gt; {
              device.setStatus(status);
              update(device);
          });
      }
  </code></pre>
  
  <p>But there is a problem with <code>device.setStatus(status);</code>. I can use <code>parseWithValidation</code> but it doesn't make sense, because it is already done. Someone gives me <code>{"status":"INACTIVE"}</code> How should I parse this enum ?</p>