From: Roland Häder Date: Thu, 13 Dec 2018 16:03:47 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=259c78bfca418ededa14015bdd22148ca313d5ac;p=jcontacts-business-core.git Continued: - if all 3 employee's relations are NULL, throw an NPE: branch office, personal data and headquarter - basic company data is always required Signed-off-by: Roland Häder --- 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