Skip to content

Commit

Permalink
avniproject/avni-client#1452 - initialize inputs with default value.
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Jul 17, 2024
1 parent a45c1d8 commit f1bbdf5
Showing 1 changed file with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ReportCard extends OrganisationAwareEntity {

@Column
@Type(type = "jsonObject")
private JsonObject standardReportCardInput;
private JsonObject standardReportCardInput = new JsonObject(new HashMap<>());

public String getName() {
return name;
Expand Down Expand Up @@ -121,40 +121,30 @@ public List<String> getStandardReportCardInputSubjectTypes() {
}

public void setStandardReportCardInputSubjectTypes(List<String> subjectTypes) {
safeSetterForStandardReportCardInput("subjectTypes", subjectTypes);
standardReportCardInput.with("subjectTypes", subjectTypes);
}

public List<String> getStandardReportCardInputPrograms() {
return safeGetterForStandardReportCardInput("programs");
}

public void setStandardReportCardInputPrograms(List<String> programs) {
safeSetterForStandardReportCardInput("programs", programs);
standardReportCardInput.with("programs", programs);
}

public List<String> getStandardReportCardInputEncounterTypes() {
return safeGetterForStandardReportCardInput("encounterTypes");
}

public void setStandardReportCardInputEncounterTypes(List<String> encounterTypes) {
safeSetterForStandardReportCardInput("encounterTypes", encounterTypes);
standardReportCardInput.with("encounterTypes", encounterTypes);
}

private List safeGetterForStandardReportCardInput(String key) {
return standardReportCardInput == null ? new ArrayList() : standardReportCardInput.getList(key);
}

private void safeSetterForStandardReportCardInput(String key, List<String> value) {
if (standardReportCardInput == null) {
standardReportCardInput = new JsonObject(new HashMap<>());
}
standardReportCardInput.with(key, value);
}

private void safeSetterForStandardReportCardInput(String key, String value) {
if (standardReportCardInput == null) {
standardReportCardInput = new JsonObject(new HashMap<>());
}
standardReportCardInput.with(key, value);
}

Expand Down

0 comments on commit f1bbdf5

Please sign in to comment.