Skip to content

Commit

Permalink
OP-1157 use enhanced switch (JDK 14)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbmalkovsky committed Nov 8, 2024
1 parent b9faed4 commit b618a7c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 46 deletions.
19 changes: 6 additions & 13 deletions src/main/java/org/isf/accounting/gui/BillDataLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,12 @@ public BillDataLoader(List<Bill> billPeriod, List<Bill> billFromPayments, Patien
}

public List<Bill> loadBills(String status, String username) throws OHServiceException {
List<Bill> tableArray = new ArrayList<>();

switch (status) {
case "O":
tableArray = getPendingBills(status, username);
break;
case "ALL":
tableArray = getAllBills(username);
break;
case "C":
tableArray = getClosedBills(status, username);
break;
}
List<Bill> tableArray = switch (status) {
case "O" -> getPendingBills(status, username);
case "ALL" -> getAllBills(username);
case "C" -> getClosedBills(status, username);
default -> new ArrayList<>();
};

tableArray.sort(Collections.reverseOrder());
return tableArray;
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/org/isf/admission/gui/AdmittedPatientBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1206,15 +1206,11 @@ else if (patientClassBox.getSelectedItem().equals(patientClassItems[1])) {
}

// sex patient type
Character sex = null;
switch (patientSexBox.getSelectedIndex()) {
case 1:
sex = 'M';
break;
case 2:
sex = 'F';
break;
}
Character sex = switch (patientSexBox.getSelectedIndex()) {
case 1 -> 'M';
case 2 -> 'F';
default -> null;
};

if (sex != null && !sex.equals(ap.getPatient().getSex())) {
continue;
Expand Down
26 changes: 10 additions & 16 deletions src/main/java/org/isf/patient/gui/PatientInsert.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,11 @@ private JButton getJOkButton() {
String name = jFirstNameTextField.getText() + ' ' + jSecondNameTextField.getText();
try {
if (patientBrowserManager.isNamePresent(name)) {
switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION:
ok = true;
break;
case JOptionPane.NO_OPTION:
ok = false;
break;
}
ok = switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION -> true;
case JOptionPane.NO_OPTION -> false;
default -> ok;
};
}
} catch (OHServiceException ex) {
OHServiceExceptionUtil.showMessages(ex);
Expand Down Expand Up @@ -320,14 +317,11 @@ private JButton getJOkButton() {
if (!patient.getName().equals(name)) {
try {
if (patientBrowserManager.isNamePresent(name)) {
switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION:
ok = true;
break;
case JOptionPane.NO_OPTION:
ok = false;
break;
}
ok = switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION -> true;
case JOptionPane.NO_OPTION -> false;
default -> ok;
};
}
} catch (OHServiceException ex) {
OHServiceExceptionUtil.showMessages(ex);
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/org/isf/patient/gui/PatientInsertExtended.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,11 @@ private JButton getJOkButton() {
String name = firstName + ' ' + secondName;
try {
if (patientBrowserManager.isNamePresent(name)) {
switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION:
ok = true;
break;
case JOptionPane.NO_OPTION:
ok = false;
break;
}
ok = switch (MessageDialog.yesNo(null, "angal.patient.thepatientisalreadypresent.msg")) {
case JOptionPane.OK_OPTION -> true;
case JOptionPane.NO_OPTION -> false;
default -> ok;
};
}
} catch (OHServiceException ex) {
OHServiceExceptionUtil.showMessages(ex);
Expand Down

0 comments on commit b618a7c

Please sign in to comment.