title: Using switch in Enum
body: <p>What if I'll use <code>switch</code> in <code>getByIntValue()</code>? Is it really neccessary to use a <code>SparseArray</code>?</p>
  
  <pre><code>public enum Gender {
      Unknown(0),
      Male(1),
      Female(2);
  
      private static final SparseArray&lt;Gender&gt; lookupTable = new SparseArray&lt;Gender&gt;();
      static {
          for (final Gender gender : EnumSet.allOf(Gender.class)) {
              lookupTable.put(gender.intValue, gender);
          }
      }
  
      private final int intValue;
  
      public static Gender getByIntValue(int val) {
          return lookupTable.get(val);
      }
  
      private Gender(int intValue) {
          this.intValue = intValue;
      }
  
      public int getIntValue() {
          return intValue;
      }
  }
  </code></pre>