Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re RA-1832: Collection.isEmpty() should be used to test for emptiness #395

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ public Collection<FormSubmissionError> validateSubmission(FormEntryContext conte
JsonNode submittedList = new ObjectMapper().readTree(submitted);

List<Diagnosis> diagnoses = parseDiagnoses(submittedList, null);
if (diagnoses.size() == 0 && required) {
if (diagnoses.isEmpty() && required) {
return Collections.singleton(new FormSubmissionError(hiddenDiagnoses, "Required"));
}
if (diagnoses.size() > 0) {
if (!diagnoses.isEmpty()) {
// at least one diagnosis must be primary
boolean foundPrimary = false;
for (Diagnosis diagnosis : diagnoses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ public Collection<FormSubmissionError> validateSubmission(FormEntryContext conte

try {
List<Diagnosis> diagnoses = parseDiagnoses(submitted, null);
if (diagnoses.size() == 0 && required) {
if (diagnoses.isEmpty() && required) {
return Collections.singleton(new FormSubmissionError(hiddenDiagnoses, "Required"));
}
if (diagnoses.size() > 0) {
if (!diagnoses.isEmpty()) {
// at least one diagnosis must be primary
boolean foundPrimary = false;
for (Diagnosis diagnosis : diagnoses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public String generateHtml(FormEntryContext context) {
}

private String initialValueAsJson(List<CodedOrFreeTextAnswer> initialValue) {
if (initialValue == null || initialValue.size() == 0) {
if (initialValue == null || initialValue.isEmpty()) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ public Collection<FormSubmissionError> validateSubmission(FormEntryContext conte

try {
List<Diagnosis> diagnoses = parseDiagnoses(submitted, null);
if (diagnoses.size() == 0 && required) {
if (diagnoses.isEmpty() && required) {
return Collections.singleton(new FormSubmissionError(hiddenDiagnoses, "Required"));
}
if (diagnoses.size() > 0) {
if (!diagnoses.isEmpty()) {
// at least one diagnosis must be primary
boolean foundPrimary = false;
for (Diagnosis diagnosis : diagnoses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,21 @@ public boolean doStartTag(FormEntrySession session, PrintWriter out, Node parent
}

// determine if there are any additional observations we need to collect for this disposition
if (disposition.getAdditionalObs() != null && disposition.getAdditionalObs().size() > 0) {
if (disposition.getAdditionalObs() != null && !disposition.getAdditionalObs().isEmpty()) {
controls.add(buildNewControl(disposition, disposition.getAdditionalObs()));
}
}

dispositionObs.setAttribute("answerConceptIds", answerConceptIds.toString());
dispositionObs.setAttribute("answerCodes", answerCodes.toString());

if (controls != null && controls.size() > 0) {
if (controls != null && !controls.isEmpty()) {
generateControlsElement(dispositionObs, controls);
}

dispositionObsGroup.appendChild(dispositionObs);

if (controls != null && controls.size() > 0) {
if (controls != null && !controls.isEmpty()) {
generateAdditionalObsElements(dispositionObsGroup, controls, exisitingDispositionObsGroup);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public FragmentActionResult codeDiagnosis(UiUtils ui,
}
}
List<Obs> newDiagnoses= diagnosisService.codeNonCodedDiagnosis(nonCodedObs, diagnosisList);
if ((newDiagnoses != null) && (newDiagnoses.size()>0) ){
if ((newDiagnoses != null) && (!newDiagnoses.isEmpty()) ){
return new SuccessResult(ui.message("coreapps.dataManagement.codeDiagnosis.success"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void controller(FragmentConfiguration config, FragmentModel model, UiUtil

model.addAttribute("definitionUiResource", definitionUiResource);

if (encounters.size() > 0) {
if (!encounters.isEmpty()) {
model.addAttribute("encounter", encounters.get(encounters.size() - 1));
} else {
model.addAttribute("encounter", null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void controller(FragmentConfiguration config,

model.addAttribute("patient", wrapper);
List<VisitType> visitTypes = visitTypeHelper.getUnRetiredVisitTypes();
if (visitType != null && visitTypes.size() > 0) {
if (visitType != null && !visitTypes.isEmpty()) {
ListIterator<VisitType> iterator = visitTypes.listIterator();
while (iterator.hasNext() ) {
if (!iterator.next().getUuid().equals(visitType)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void get(@SpringBean PageModel pageModel,
}
List<Visit> visits = Context.getVisitService().getVisitsByPatient(patient);

if (visits.size() > 0) {
if (!visits.isEmpty()) {
//Current order of visits returned by getVisitsByPatient() of VisitService has first in list as last visit
pageModel.put("lastVisitDate", visits.get(0).getStartDatetime());
} else {
Expand Down Expand Up @@ -111,7 +111,7 @@ private Collection<ConceptAnswer> getConceptAnswers(String conceptId) {
*/
private void closeActiveVisitsAfterDeath(Patient patient) {
List<Visit> visitList = Context.getVisitService().getActiveVisitsByPatient(patient);
if (visitList.size() <= 0) {
if (!visitList.isEmpty()) {
for (Visit visit : visitList) {
Context.getVisitService().endVisit(visit, patient.getDeathDate());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public String post(@RequestParam("patientId") Patient patient,
SimpleObject.create("patientId", patient.getId().toString() ));
}

if (mergeVisits!=null && mergeVisits.size() > 0 ){
if (mergeVisits!=null && !mergeVisits.isEmpty() ){
Visit mergedVisit = service.mergeConsecutiveVisits(mergeVisits, patient);
if (mergedVisit != null){
request.getSession().setAttribute(AppUiConstants.SESSION_ATTRIBUTE_INFO_MESSAGE, ui.message("coreapps.task.mergeVisits.success"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void get(PageModel model,

Map<Provider, List<ProviderPersonRelationship>> providers = new HashMap<Provider, List<ProviderPersonRelationship>>();
List<ProviderRole> providerRoleList = providerManagementService.getRestrictedProviderRoles(false);
if (providerRoleList != null && providerRoleList.size() > 0 ) {
if (providerRoleList != null && !providerRoleList.isEmpty() ) {
List<Provider> providersByRoles = Context.getService(ProviderManagementService.class).getProvidersByRoles(providerRoleList);
for (Provider providerByRole : providersByRoles) {
List<ProviderPersonRelationship> supervisorsForProvider = ProviderManagementUtils.getSupervisors(providerByRole);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected PageableResult doSearch(RequestContext context) {
questions.add(concept);

List<Obs> latestObs = obsService.getObservations(who, null, questions, null, null, null, sort, nLatestObs, null, null, null, false);
if (latestObs.size() > 0) {
if (!latestObs.isEmpty()) {
obsList.addAll(latestObs);
}
}
Expand Down