code: public <E extends Enum<E>> E getEnum(Class<E> clazz, String key) throws JSONException {
          E val = optEnum(clazz, key);
          if(val==null) {
              // JSONException should really take a throwable argument.
              // If it did, I would re-implement this with the Enum.valueOf
              // method and place any thrown exception in the JSONException
              throw new JSONException("JSONObject[" + quote(key)
                      + "] is not an enum of type " + quote(clazz.getSimpleName())
                      + ".");
          }
          return val;
      }
docs: Get the enum value associated with a key.
  
  @param <E>
  Enum Type
  @param clazz
  The type of enum to retrieve.
  @param key
  A key string.
  @return The enum value associated with the key
  @throws JSONException
  if the key is not found or if the value cannot be converted
  to an enum.