title: Java enum and if statement, is there a better way to do this?
body: <p>I have an java <code>Enum</code> class, and at runtime I will read in a value from command line, and I want to correspond this value to a value in my <code>Enum</code> class. <code>Shipper</code> is my Enum Class. Is there a better way do this this, instead of <code>if</code> and <code>else if</code> below? This look ugly. </p>
  
  <pre><code>private List&lt;Shipper&gt; shipperName = new ArrayList&lt;Shipper&gt;();
  ...
  public void init(String s){ 
      if(s.equals("a")){
          shipperName.add(Shipper.A);
      }else if(s.equals("b")){
          shipperName.add(Shipper.B);
      }else if(s.equals("c")){
          shipperName.add(Shipper.C);
      }else if(s.equals("d")){
          shipperName.add(Shipper.D);
      }else if(s.equals("e")){
          shipperName.add(Shipper.E);
      }else{
          System.out.println("Error");
      }
  }
  </code></pre>
  
  <p>Here is my Shipper.class</p>
  
  <pre><code>public enum Shipper
  {
      A("a"),
      B("b"),
      C("c"),
      D("e"),
      F("f")
  ;
  
      private String directoryName;
  
      private Shipper(String directoryName)
      {
           this.directoryName = directoryName;
      }
  
      public String getDirectoryName()
      {
           return directoryName;
      }
  }
  </code></pre>