public WeatherCondition(JSONObject json) { this.code = ConditionCode.valueof(json.optInt(WeatherCondition.JSON_ID, Integer.MIN_VALUE)); this.main = json.optString(WeatherCondition.JSON_MAIN); this.description = json.optString(WeatherCondition.JSON_DESCRIPTION); this.iconName = json.optString(WeatherCondition.JSON_ICON); }
public static ConditionCode valueof(int id) { for (ConditionCode condition : ConditionCode.values()) { if (condition.id == id) return condition; } return ConditionCode.UNKNOWN; }