code: public static <E extends Enum<E>> E getOptionalEnumParam(JSONObject params, String paramName,
  			Class<E> enumType) throws ApiException {
  		String enumValS = params.optString(paramName, null);
  		E enumVal = null;
  		if (enumValS != null && !enumValS.isEmpty()) {
  			try {
  				enumVal = Enum.valueOf(enumType, enumValS);
  			} catch (Exception ex) {
  				throw new ApiException(ApiException.Type.ILLEGAL_PARAMETER, paramName + ": "
  						+ ex.getLocalizedMessage());
  			}
  		}
  		return enumVal;
  	}
docs: Gets an optional enum param, returning {@code null} if the parameter was not found.
  
  @param <E> the type of the enum that will be returned
  @param params the params
  @param paramName the param name
  @param enumType the type of the enum
  @return the enum, or {@code null}
  @throws ApiException if the param value does not match any of the possible enum values