title: Setting an Enum value based on incoming String
body: <p>I have a number of setter methods which take an enum. These are based on incoming objects attribute. Rather than write a bunch of these is there a way around having to hard code say 10 different case statements. Would there be a way to create a reusable method?</p>
  
  <pre><code>//Side class declared as
  public final enum Side
  
  //How I initialise side
  static Side side = Side.SELL;//default
  
  //method to set object
  Obj.setSide(sideEnum(zasAlloc.getM_buySellCode()));
  
  //How I am implementing it
      public static Side sideEnum(String buysell)
      {
  
          if(buysell.equalsIgnoreCase("S"))
          {
              side = Side.SELL; //default 
          }
          else if(buysell.equalsIgnoreCase("B"))
          {
              side = Side.BUY; 
          }
  
          return side;
  
      }
  </code></pre>