title: using enum in switch/case
body: <p>I have an entity that has an enum property:</p>
  
  <pre><code>// MyFile.java
  public class MyFile {   
      private DownloadStatus downloadStatus;
      // other properties, setters and getters
  }
  
  // DownloadStatus.java
  public enum DownloadStatus {
      NOT_DOWNLOADED(1),
      DOWNLOAD_IN_PROGRESS(2),
      DOWNLOADED(3);
  
      private int value;
      private DownloadStatus(int value) {
          this.value = value;
      }
  
      public int getValue() {
          return value;
      }
  } 
  </code></pre>
  
  <p>I want to save this entity in database and retrieve it. The problem is that I save the int value in database and I get int value! I can not use switch like below:</p>
  
  <pre><code>MyFile file = new MyFile();
  int downloadStatus = ...
  switch(downloadStatus) {
      case NOT_DOWNLOADED:
      file.setDownloadStatus(NOT_DOWNLOADED);
      break;
      // ...
  }    
  </code></pre>
  
  <p>What should I do?</p>