diff --git a/src/main/java/org/isf/accounting/gui/BillDataLoader.java b/src/main/java/org/isf/accounting/gui/BillDataLoader.java index 81b816e08f..05618b065c 100644 --- a/src/main/java/org/isf/accounting/gui/BillDataLoader.java +++ b/src/main/java/org/isf/accounting/gui/BillDataLoader.java @@ -47,19 +47,12 @@ public BillDataLoader(List billPeriod, List billFromPayments, Patien } public List loadBills(String status, String username) throws OHServiceException { - List 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 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; diff --git a/src/main/java/org/isf/admission/gui/AdmittedPatientBrowser.java b/src/main/java/org/isf/admission/gui/AdmittedPatientBrowser.java index 0e2aa065c8..fb611a04cf 100644 --- a/src/main/java/org/isf/admission/gui/AdmittedPatientBrowser.java +++ b/src/main/java/org/isf/admission/gui/AdmittedPatientBrowser.java @@ -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; diff --git a/src/main/java/org/isf/admission/gui/PatientFolderBrowser.java b/src/main/java/org/isf/admission/gui/PatientFolderBrowser.java index ec84046472..6420b94444 100644 --- a/src/main/java/org/isf/admission/gui/PatientFolderBrowser.java +++ b/src/main/java/org/isf/admission/gui/PatientFolderBrowser.java @@ -452,19 +452,16 @@ public void mouseClicked(MouseEvent mouseEvent) { } } - if (selectedObject instanceof Admission) { + if (selectedObject instanceof Admission ad) { - Admission ad = (Admission) selectedObject; startDate = ad.getAdmDate(); endDate = ad.getDisDate(); - } else if (selectedObject instanceof Opd) { + } else if (selectedObject instanceof Opd opd) { - Opd opd = (Opd) selectedObject; startDate = opd.getDate(); - } else if (selectedObject instanceof PatientExamination) { - PatientExamination exam = (PatientExamination) selectedObject; + } else if (selectedObject instanceof PatientExamination exam) { startDate = exam.getPex_date(); } diff --git a/src/main/java/org/isf/opd/gui/OpdEditExtended.java b/src/main/java/org/isf/opd/gui/OpdEditExtended.java index 4602a078bd..3c44beac58 100644 --- a/src/main/java/org/isf/opd/gui/OpdEditExtended.java +++ b/src/main/java/org/isf/opd/gui/OpdEditExtended.java @@ -445,8 +445,7 @@ private void setAttendance() { return; } Object selectedObject = diseaseBox1.getSelectedItem(); - if (selectedObject instanceof Disease) { - Disease disease = (Disease) selectedObject; + if (selectedObject instanceof Disease disease) { if (lastOPDDisease1 != null && disease.getCode().equals(lastOPDDisease1.getCode())) { rePatientButton.setSelected(true); } else { diff --git a/src/main/java/org/isf/patient/gui/PatientInsert.java b/src/main/java/org/isf/patient/gui/PatientInsert.java index 28878c1e3a..cd0d1f8a71 100644 --- a/src/main/java/org/isf/patient/gui/PatientInsert.java +++ b/src/main/java/org/isf/patient/gui/PatientInsert.java @@ -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); @@ -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); diff --git a/src/main/java/org/isf/patient/gui/PatientInsertExtended.java b/src/main/java/org/isf/patient/gui/PatientInsertExtended.java index 53a8a9901c..da5a0829c5 100644 --- a/src/main/java/org/isf/patient/gui/PatientInsertExtended.java +++ b/src/main/java/org/isf/patient/gui/PatientInsertExtended.java @@ -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); diff --git a/src/main/java/org/isf/session/LoginEventListener.java b/src/main/java/org/isf/session/LoginEventListener.java index 54029aa21f..aec980cf45 100644 --- a/src/main/java/org/isf/session/LoginEventListener.java +++ b/src/main/java/org/isf/session/LoginEventListener.java @@ -30,8 +30,7 @@ public class LoginEventListener implements LoginListener { @Override public void loginInserted(AWTEvent e) { - if (e.getSource() instanceof User) { - User myUser = (User) e.getSource(); + if (e.getSource() instanceof User myUser) { RestartUserSession.setUser(myUser); RestartUserSession.getTimer().startTimer(); } diff --git a/src/main/java/org/isf/therapy/gui/TherapyEdit.java b/src/main/java/org/isf/therapy/gui/TherapyEdit.java index 1e6855e163..1c1b612976 100644 --- a/src/main/java/org/isf/therapy/gui/TherapyEdit.java +++ b/src/main/java/org/isf/therapy/gui/TherapyEdit.java @@ -1142,14 +1142,12 @@ public void mouseClicked(MouseEvent e) { model = list.getModel(); for (int i = 0; i < model.getSize(); i++) { Object iteratedItem = model.getElementAt(i); - if (iteratedItem instanceof Therapy) { - Therapy aTherapy = (Therapy) iteratedItem; + if (iteratedItem instanceof Therapy aTherapy) { if (therapyID != 0 && aTherapy.getTherapyID() == therapyID) { list.setSelectedIndex(i); } } - if (iteratedItem instanceof Visit) { - Visit aVisit = (Visit) iteratedItem; + if (iteratedItem instanceof Visit aVisit) { if (visitID != 0 && aVisit.getVisitID() == visitID) { list.setSelectedIndex(i); } diff --git a/src/main/java/org/isf/utils/jobjects/OhTableDrugsModel.java b/src/main/java/org/isf/utils/jobjects/OhTableDrugsModel.java index 4d1d50b63f..ebfe1b2b8f 100644 --- a/src/main/java/org/isf/utils/jobjects/OhTableDrugsModel.java +++ b/src/main/java/org/isf/utils/jobjects/OhTableDrugsModel.java @@ -97,8 +97,7 @@ public Object getValueAt(int rowIndex, int columnIndex) { String value = ""; if (rowIndex >= 0 && rowIndex < this.filteredList.size()) { T obj = this.filteredList.get(rowIndex); - if (obj instanceof MovementWard) { - MovementWard drugObj = (MovementWard) obj; + if (obj instanceof MovementWard drugObj) { switch (columnIndex) { case 0: String dt; diff --git a/src/main/java/org/isf/utils/jobjects/OhTableModel.java b/src/main/java/org/isf/utils/jobjects/OhTableModel.java index d2780e654b..6ce43fc84c 100644 --- a/src/main/java/org/isf/utils/jobjects/OhTableModel.java +++ b/src/main/java/org/isf/utils/jobjects/OhTableModel.java @@ -67,8 +67,7 @@ public T filter(String searchQuery) throws OHException { for (T t : this.dataList) { Object object = t; - if (object instanceof Price) { - Price price = (Price) object; + if (object instanceof Price price) { String strItem = price.getItem() + price.getDesc(); if (allowSearchByCode && searchQuery.equalsIgnoreCase(price.getItem())) { T resPbj = (T) object; @@ -83,8 +82,7 @@ public T filter(String searchQuery) throws OHException { } } - if (object instanceof MedicalWard) { - MedicalWard mdw = (MedicalWard) object; + if (object instanceof MedicalWard mdw) { String strItem = mdw.getMedical().getProdCode() + mdw.getMedical().getDescription(); if (allowSearchByCode && searchQuery.equalsIgnoreCase(mdw.getMedical().getProdCode())) { @@ -101,8 +99,7 @@ public T filter(String searchQuery) throws OHException { } } - if (object instanceof PricesOthers) { - PricesOthers priceO = (PricesOthers) object; + if (object instanceof PricesOthers priceO) { String strItem = priceO.getCode() + priceO.getDescription(); if (allowSearchByCode && searchQuery.equalsIgnoreCase(priceO.getCode())) { @@ -119,8 +116,7 @@ public T filter(String searchQuery) throws OHException { } } - if (object instanceof BillItems) { - BillItems priceO = (BillItems) object; + if (object instanceof BillItems priceO) { String strItem = priceO.getItemDisplayCode() + priceO.getItemDescription(); if (allowSearchByCode && searchQuery.equalsIgnoreCase(priceO.getItemDisplayCode())) { @@ -188,24 +184,21 @@ public Object getValueAt(int rowIndex, int columnIndex) { String value = ""; if (rowIndex >= 0 && rowIndex < this.filteredList.size()) { T obj = this.filteredList.get(rowIndex); - if (obj instanceof Price) { - Price priceObj = (Price) obj; + if (obj instanceof Price priceObj) { if (columnIndex == 0) { value = priceObj.getItem() != null ? priceObj.getItem() : String.valueOf(priceObj.getId()); } else { value = priceObj.getDesc(); } } - if (obj instanceof MedicalWard) { - MedicalWard mdwObj = (MedicalWard) obj; + if (obj instanceof MedicalWard mdwObj) { if (columnIndex == 0) { value = mdwObj.getMedical().getProdCode() != null ? mdwObj.getMedical().getProdCode() : String.valueOf(mdwObj.getMedical().getCode()); } else { value = mdwObj.getMedical().getDescription(); } } - if (obj instanceof PricesOthers) { - PricesOthers mdwObj = (PricesOthers) obj; + if (obj instanceof PricesOthers mdwObj) { if (columnIndex == 0) { value = mdwObj.getCode() != null ? mdwObj.getCode() : String.valueOf(mdwObj.getId()); } else { @@ -213,8 +206,7 @@ public Object getValueAt(int rowIndex, int columnIndex) { } } - if (obj instanceof BillItems) { - BillItems mdwObj = (BillItems) obj; + if (obj instanceof BillItems mdwObj) { if (columnIndex == 0) { value = mdwObj.getItemDisplayCode() != null ? mdwObj.getItemDisplayCode() : String.valueOf(mdwObj.getId()); } else { diff --git a/src/main/java/org/isf/utils/jobjects/OhTableOperationModel.java b/src/main/java/org/isf/utils/jobjects/OhTableOperationModel.java index 812c360f46..6946646975 100644 --- a/src/main/java/org/isf/utils/jobjects/OhTableOperationModel.java +++ b/src/main/java/org/isf/utils/jobjects/OhTableOperationModel.java @@ -63,8 +63,7 @@ public int filter(String searchQuery) { for (T t : this.dataList) { Object object = t; - if (object instanceof OperationRow) { - OperationRow price = (OperationRow) object; + if (object instanceof OperationRow price) { String strItem = price.getOperation().getCode() + price.getOpResult(); strItem = strItem.toLowerCase(); searchQuery = searchQuery.toLowerCase(); @@ -126,8 +125,7 @@ public Object getValueAt(int rowIndex, int columnIndex) { String value = ""; if (rowIndex >= 0 && rowIndex < this.filteredList.size()) { T obj = this.filteredList.get(rowIndex); - if (obj instanceof OperationRow) { - OperationRow opdObj = (OperationRow) obj; + if (obj instanceof OperationRow opdObj) { switch (columnIndex) { case -1: return opdObj; diff --git a/src/main/java/org/isf/video/PhotoboothTester.java b/src/main/java/org/isf/video/PhotoboothTester.java index 994f13453e..878383f5ed 100644 --- a/src/main/java/org/isf/video/PhotoboothTester.java +++ b/src/main/java/org/isf/video/PhotoboothTester.java @@ -46,16 +46,14 @@ public static void main(final String[] args) { final PhotoboothPanelPresentationModel presentationModel = new PhotoboothPanelPresentationModel(); presentationModel.addBeanPropertyChangeListener(PhotoboothPanelModel.PROPERTY_IMAGE, propertyChangeEvent -> { final Object newValue = propertyChangeEvent.getNewValue(); - if (newValue instanceof BufferedImage) { - final BufferedImage bufferedImage = (BufferedImage) newValue; - LOGGER.info("New image is being set {}x{}", bufferedImage.getWidth(), bufferedImage.getHeight()); + if (newValue instanceof BufferedImage bufferedImage) { + LOGGER.info("New image is being set {}x{}", bufferedImage.getWidth(), bufferedImage.getHeight()); } }); presentationModel.addBeanPropertyChangeListener(PhotoboothPanelModel.PROPERTY_RESOLUTION, propertyChangeEvent -> { Object newValue = propertyChangeEvent.getNewValue(); - if (newValue instanceof Dimension) { - final Dimension newDimension = (Dimension) newValue; - LOGGER.info("New dimension is {}x{}", newDimension.getWidth(), newDimension.getHeight()); + if (newValue instanceof Dimension newDimension) { + LOGGER.info("New dimension is {}x{}", newDimension.getWidth(), newDimension.getHeight()); } }); diff --git a/src/main/java/org/isf/video/gui/PhotoboothComponentImpl.java b/src/main/java/org/isf/video/gui/PhotoboothComponentImpl.java index 644e091074..25c71ad390 100644 --- a/src/main/java/org/isf/video/gui/PhotoboothComponentImpl.java +++ b/src/main/java/org/isf/video/gui/PhotoboothComponentImpl.java @@ -58,9 +58,8 @@ public Component getListCellRendererComponent(final JList list, final boolean isSelected, final boolean cellHasFocus) { final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof Dimension) { - final Dimension valueAsDimension = (Dimension) value; - setText(String.format("%d x %d", (int) valueAsDimension.getWidth(), (int) valueAsDimension.getHeight())); + if (value instanceof Dimension valueAsDimension) { + setText(String.format("%d x %d", (int) valueAsDimension.getWidth(), (int) valueAsDimension.getHeight())); } return component; } @@ -73,9 +72,8 @@ public Component getListCellRendererComponent(final JList list, final boolean isSelected, final boolean cellHasFocus) { final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof Webcam) { - final Webcam webcam = (Webcam) value; - setText(webcam.getName()); + if (value instanceof Webcam webcam) { + setText(webcam.getName()); } return component; }