Source:
private static LamiNumber createFromNumberJsonObject(JSONObject obj, boolean useLong) throws JSONException { String dataClass = obj.optString(LamiStrings.CLASS); if (dataClass == null) { throw new JSONException("Cannot find data class"); } Number valueNumber = getNumberFromJsonObject(obj, LamiStrings.VALUE, useLong, false); Number lowNumber = getNumberFromJsonObject(obj, LamiStrings.LOW, useLong, true); Number highNumber = getNumberFromJsonObject(obj, LamiStrings.HIGH, useLong, true); if (valueNumber == null && (lowNumber == null || highNumber == null)) { throw new JSONException("Invalid number object: no value, invalid limit"); } else if (lowNumber == null && highNumber != null) { throw new JSONException("Invalid number object: high limit, but no low limit"); } else if (highNumber == null && lowNumber != null) { throw new JSONException("Invalid number object: low limit, but no high limit"); } LamiNumberFromValuesFunction func = NUMBER_TYPE_GENERATOR.get(dataClass); if (func == null) { throw new JSONException(String.format("Data class \"%s\" is not a number class", dataClass)); } return func.create(lowNumber, valueNumber, highNumber); }

Target:
private static LamiNumber createFromNumberJsonObject(JSONObject obj, boolean useLong) throws JSONException { String dataClass = obj.optString(LamiStrings.CLASS); if (dataClass == null) { throw new JSONException("Cannot find data class"); } Number valueNumber = getNumberFromJsonObject(obj, LamiStrings.VALUE, useLong, false); Number lowNumber = getNumberFromJsonObject(obj, LamiStrings.LOW, useLong, true); Number highNumber = getNumberFromJsonObject(obj, LamiStrings.HIGH, useLong, true); if (valueNumber == null && (lowNumber == null || highNumber == null)) { throw new JSONException("Invalid number object: no value, invalid limit"); } else if (lowNumber == null && highNumber != null) { throw new JSONException("Invalid number object: high limit, but no low limit"); } else if (highNumber == null && lowNumber != null) { throw new JSONException("Invalid number object: low limit, but no high limit"); } Number eqLowNumber = lowNumber; Number eqHighNumber = highNumber; Number eqValueNumber = valueNumber; if (eqLowNumber == null) { eqLowNumber = valueNumber; eqHighNumber = valueNumber; } else if (eqValueNumber == null) { eqValueNumber = eqLowNumber; } if (checkNotNull(eqValueNumber).doubleValue() < checkNotNull(eqLowNumber).doubleValue() || checkNotNull(eqHighNumber).doubleValue() < checkNotNull(eqValueNumber).doubleValue()) { throw new JSONException("Invalid number object: low <= value <= high not respected"); } if (useLong) { LamiLongFromValuesFunction func = NUMBER_LONG_TYPE_GENERATOR.get(dataClass); if (func == null) { throw new JSONException(String.format("Data class \"%s\" is not a number class", dataClass)); } return func.create(nullableNumberToLong(lowNumber), nullableNumberToLong(valueNumber), nullableNumberToLong(highNumber)); } LamiDoubleFromValuesFunction func = NUMBER_DOUBLE_TYPE_GENERATOR.get(dataClass); if (func == null) { throw new JSONException(String.format("Data class \"%s\" is not a number class", dataClass)); } return func.create(nullableNumberToDouble(lowNumber), nullableNumberToDouble(valueNumber), nullableNumberToDouble(highNumber)); }