public < E extends Enum < E > > E getEnum ( Class < E > clazz , int index ) throws JSONException { E val = optEnum ( clazz , index ) ; 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 ( "JSONArray[" + index + "] is not an enum of type " + JSONObject . quote ( clazz . getSimpleName ( ) ) + "." ) ; } return val ; }
Get the enum value associated with an index .