@Test public void readJSONReturnsNullWhenJSONIsEmpty() { JSONObject json = new JSONObject(); Assert.assertNull(this.component.readJSON(json)); }
@Override public PatientData<PhenoTipsDate> readJSON(JSONObject json) { Map<String, PhenoTipsDate> result = new LinkedHashMap<>(); for (String property : this.getPatientDocumentProperties()) { String jsonFieldName = getJSONFieldName(property); if (json.has(jsonFieldName)) { JSONObject dateAsObject = json.optJSONObject(jsonFieldName); if (dateAsObject != null) { result.put(property, new PhenoTipsDate(dateAsObject)); } else { result.put(property, new PhenoTipsDate(json.optString(jsonFieldName, null))); } } } if (result.isEmpty()) { return null; } else { return new DictionaryPatientData<>(DATA_NAME, result); } }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public PatientData<PhenoTipsDate> readJSON(JSONObject json) { Map<String, PhenoTipsDate> result = new LinkedHashMap<>(); for (String property : this.getPatientDocumentProperties()) { String jsonFieldName = getJSONFieldName(property); if (json.has(jsonFieldName)) { JSONObject dateAsObject = json.optJSONObject(jsonFieldName); if (dateAsObject != null) { result.put(property, new PhenoTipsDate(dateAsObject)); } else { result.put(property, new PhenoTipsDate(json.optString(jsonFieldName, null))); } } } if (result.isEmpty()) { return null; } else { return new DictionaryPatientData<>(DATA_NAME, result); } } }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public PatientData<PhenoTipsDate> readJSON(JSONObject json) { Map<String, PhenoTipsDate> result = new LinkedHashMap<>(); for (String property : this.getPatientDocumentProperties()) { String jsonFieldName = getJSONFieldName(property); if (json.has(jsonFieldName)) { JSONObject dateAsObject = json.optJSONObject(jsonFieldName); if (dateAsObject != null) { result.put(property, new PhenoTipsDate(dateAsObject)); } else { result.put(property, new PhenoTipsDate(json.optString(jsonFieldName, null))); } } } if (result.isEmpty()) { return null; } else { return new DictionaryPatientData<>(DATA_NAME, result); } }  }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public PatientData<PhenoTipsDate> readJSON(JSONObject json) { Map<String, PhenoTipsDate> result = new LinkedHashMap<>(); for (String property : this.getPatientDocumentProperties()) { String jsonFieldName = getJSONFieldName(property); if (json.has(jsonFieldName)) { JSONObject dateAsObject = json.optJSONObject(jsonFieldName); if (dateAsObject != null) { result.put(property, new PhenoTipsDate(dateAsObject)); } else { result.put(property, new PhenoTipsDate(json.optString(jsonFieldName, null))); } } } if (result.isEmpty()) { return null; } else { return new DictionaryPatientData<>(DATA_NAME, result); } }  @Override PatientData<PhenoTipsDate> load(Patient patient); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override void writeJSON(Patient patient, JSONObject json); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<PhenoTipsDate> readJSON(JSONObject json); @Override String getName(); }
DatesController implements PatientDataController<PhenoTipsDate> { @Override public PatientData<PhenoTipsDate> readJSON(JSONObject json) { Map<String, PhenoTipsDate> result = new LinkedHashMap<>(); for (String property : this.getPatientDocumentProperties()) { String jsonFieldName = getJSONFieldName(property); if (json.has(jsonFieldName)) { JSONObject dateAsObject = json.optJSONObject(jsonFieldName); if (dateAsObject != null) { result.put(property, new PhenoTipsDate(dateAsObject)); } else { result.put(property, new PhenoTipsDate(json.optString(jsonFieldName, null))); } } } if (result.isEmpty()) { return null; } else { return new DictionaryPatientData<>(DATA_NAME, result); } }  @Override PatientData<PhenoTipsDate> load(Patient patient); @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override void writeJSON(Patient patient, JSONObject json); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override PatientData<PhenoTipsDate> readJSON(JSONObject json); @Override String getName();  }