From 259c78bfca418ededa14015bdd22148ca313d5ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 13 Dec 2018 17:03:47 +0100 Subject: [PATCH] Continued: - if all 3 employee's relations are NULL, throw an NPE: branch office, personal data and headquarter - basic company data is always required MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../jcontactsbusiness/model/employee/Employees.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/org/mxchange/jcontactsbusiness/model/employee/Employees.java b/src/org/mxchange/jcontactsbusiness/model/employee/Employees.java index 177da4f..c037394 100644 --- a/src/org/mxchange/jcontactsbusiness/model/employee/Employees.java +++ b/src/org/mxchange/jcontactsbusiness/model/employee/Employees.java @@ -101,9 +101,9 @@ public class Employees implements Serializable { } else if (employee1.getEmployeeHeadquarter() != null && employee1.getEmployeeHeadquarter().getHeadquarterId() < 1) { // Throw IAE throw new IllegalArgumentException(MessageFormat.format("employee1.employeeHeadquarter.headquarterId={0} is invalid.", employee1.getEmployeeHeadquarter().getHeadquarterId())); //NOI18N - } else if ((employee1.getEmployeePersonalData() == null) && (employee1.getEmployeeNumber() == null)) { - // Both are null - throw new NullPointerException("employee1.employeePersonalData and employee1.employeeNumber are null"); //NOI18N + } else if ((employee1.getEmployeePersonalData() == null) && (employee1.getEmployeeBranchOffice() == null) && (employee1.getEmployeeHeadquarter() == null) && (employee1.getEmployeeNumber() == null)) { + // All are null + throw new NullPointerException("employee1.employeePersonalData, employee1.employeeBranchOffice, employee1.employeeHeadquarter and employee1.employeeNumber are null"); //NOI18N } else if ((employee1.getEmployeePersonalData() != null) && (employee1.getEmployeePersonalData().getContactId() == null)) { // Throw NPE throw new NullPointerException("employee1.employeePersonalData.contactId is null"); //NOI18N @@ -146,9 +146,9 @@ public class Employees implements Serializable { } else if (employee2.getEmployeeHeadquarter() != null && employee2.getEmployeeHeadquarter().getHeadquarterId() < 1) { // Throw IAE throw new IllegalArgumentException(MessageFormat.format("employee2.employeeHeadquarter.headquarterId={0} is invalid.", employee2.getEmployeeHeadquarter().getHeadquarterId())); //NOI18N - } else if ((employee2.getEmployeePersonalData() == null) && (employee2.getEmployeeNumber() == null)) { - // Both are null - throw new NullPointerException("employee2.employeePersonalData and employee2.employeeNumber are null"); //NOI18N + } else if ((employee2.getEmployeePersonalData() == null) && (employee2.getEmployeeBranchOffice() == null) && (employee2.getEmployeeHeadquarter() == null) && (employee2.getEmployeeNumber() == null)) { + // All are null + throw new NullPointerException("employee2.employeePersonalData, employee2.employeeBranchOffice, employee2.employeeHeadquarter and employee2.employeeNumber are null"); //NOI18N } else if ((employee2.getEmployeePersonalData() != null) && (employee2.getEmployeePersonalData().getContactId() == null)) { // Throw NPE throw new NullPointerException("employee2.employeePersonalData.contactId is null"); //NOI18N -- 2.39.5