long getLong(Object o) { if (o instanceof Integer || o instanceof Long) { return Field.getLong(o); } else if (o instanceof String && NumberUtils.isDigits((String) o)) { return NumberUtils.toLong((String) o, 0L); } else { return 0L; } }
/** * Deserialize the json to extract standard attributes and keep a reference of * other attributes. * * @param json The JSON object to read. */ @Override void deserialize(JSONObject json) throws JiraException { super.deserialize(json); this.originalEstimate = Field.getString(json.get("originalEstimate")); this.remainingEstimate = Field.getString(json.get("remainingEstimate")); this.timeSpent = Field.getString(json.get("timeSpent")); this.originalEstimateSeconds = Field.getLong(json.get("originalEstimateSeconds")); this.remainingEstimateSeconds = Field.getLong(json.get("remainingEstimateSeconds")); this.timeSpentSeconds = Field.getLong(json.get("timeSpentSeconds")); }
/** * Deserialize the json to extract standard attributes and keep a reference of * other attributes. * * @param json The JSON object to read. */ @Override void deserialize(JSONObject json) throws JiraException { super.deserialize(json); this.author = getSubResource(User.class, json, "author"); this.comment = Field.getString(json.get("comment")); this.created = Field.getDateTime(json.get("created")); this.updated = Field.getDateTime(json.get("updated")); this.updateAuthor = getSubResource(User.class, json, "updateAuthor"); this.started = Field.getDateTime(json.get("started")); this.timeSpent = Field.getString(json.get("timeSpent")); this.timeSpentSeconds = Field.getLong(json.get("timeSpentSeconds")); }