+++ /dev/null
-/*
- * Copyright (C) 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.basicdata;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-/**
- * An utilities class for basic company data
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class BasicDataUtils implements Serializable {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 159_847_673_672_091L;
-
- /**
- * Compares both basic company data instances. This method returns -1 if
- * second instance is null.
- * <p>
- * @param basicData1 Basic company data instance 1
- * @param basicData2 Basic company data instance 2
- * <p>
- * @return Comparison value
- */
- public static int compare (final BasicData basicData1, final BasicData basicData2) {
- // Check equality, then at least first must be given
- if (Objects.equals(basicData1, basicData2)) {
- // Both are same
- return 0;
- } else if (null == basicData1) {
- // First is null
- return -1;
- } else if (null == basicData2) {
- // Second is null
- return 1;
- }
-
- // Invoke compareTo() method
- return basicData1.compareTo(basicData2);
- }
-
- /**
- * Utility classes should not have instances
- */
- private BasicDataUtils () {
- // Private constructor
- }
-
-}
import org.mxchange.jcontactsbusiness.model.employee.Employable;
import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter;
import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
-import org.mxchange.jcontactsbusiness.model.headquarter.Headquarters;
import org.mxchange.jcontactsbusiness.model.logo.BusinessLogo;
import org.mxchange.jcontactsbusiness.model.logo.Logo;
+import org.mxchange.jcontactsbusiness.model.utils.HeadquarterUtils;
import org.mxchange.jcoreutils.Comparables;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
// Init comparators
final int comparators[] = {
// First compare company short name
- this.getCompanyShortName().compareToIgnoreCase(basicData.getCompanyShortName()),
+ StringUtils.compareIgnoreCase(this.getCompanyShortName(), basicData.getCompanyShortName()),
// ... 2nd compare company name
StringUtils.compareIgnoreCase(this.getCompanyName(), basicData.getCompanyName()),
// ... next tax number
// ... and email address
StringUtils.compareIgnoreCase(this.getCompanyEmailAddress(), basicData.getCompanyEmailAddress()),
// ... head quarter data
- Headquarters.compare(this.getCompanyHeadquarterData(), basicData.getCompanyHeadquarterData())
+ HeadquarterUtils.compare(this.getCompanyHeadquarterData(), basicData.getCompanyHeadquarterData())
};
// Check all values
+++ /dev/null
-
-/*
- * Copyright (C) 2017 - 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.branchoffice;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-/**
- * An utilities class for branch offices
- *
- * @author Roland Häder<roland@mxchange.org>
- */
-public class BranchOffices implements Serializable {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 69_537_867_224_651L;
-
- /**
- * Compares both branch office instances. This method returns -1 if second
- * instance is null.
- * <p>
- * @param branchOffice1 Branch office instance 1
- * @param branchOffice2 Branch office instance 2
- * <p>
- * @return Comparison value
- */
- public static int compare (final BranchOffice branchOffice1, final BranchOffice branchOffice2) {
- // Check equality, then at least first must be given
- if (Objects.equals(branchOffice1, branchOffice2)) {
- // Both are same
- return 0;
- } else if (null == branchOffice1) {
- // First is null
- return -1;
- } else if (null == branchOffice2) {
- // Second is null
- return 1;
- }
-
- // Invoke compareTo() method
- return branchOffice1.compareTo(branchOffice2);
- }
-
- /**
- * Copies all fields from source to target branch office instance
- * <p>
- * @param sourceBranchOffice Source BranchOffice instance
- * @param targetBranchOffice Target BranchOffice instance
- */
- public static void copyBranchOfficeData (final BranchOffice sourceBranchOffice, final BranchOffice targetBranchOffice) {
- // Check that both parameters are not null
- if (null == sourceBranchOffice) {
- // Throw NPE
- throw new NullPointerException("sourceBranchOffice is null"); //NOI18N
- } else if (null == targetBranchOffice) {
- // Throw NPE
- throw new NullPointerException("targetBranchOffice is null"); //NOI18N
- } else if (Objects.equals(sourceBranchOffice, targetBranchOffice)) {
- // Throw IAE
- throw new IllegalArgumentException("sourceBranchOffice and targetBranchOffice are the same"); //NOI18N
- }
-
- // Copy all fields
- targetBranchOffice.setBranchCity(sourceBranchOffice.getBranchCity());
- targetBranchOffice.setBranchCompany(sourceBranchOffice.getBranchCompany());
- targetBranchOffice.setBranchContactEmployee(sourceBranchOffice.getBranchContactEmployee());
- targetBranchOffice.setBranchCountry(sourceBranchOffice.getBranchCountry());
- targetBranchOffice.setBranchEmailAddress(sourceBranchOffice.getBranchEmailAddress());
- targetBranchOffice.setBranchFaxNumber(sourceBranchOffice.getBranchFaxNumber());
- targetBranchOffice.setBranchHouseNumber(sourceBranchOffice.getBranchHouseNumber());
- targetBranchOffice.setBranchHouseNumberExtension(sourceBranchOffice.getBranchHouseNumberExtension());
- targetBranchOffice.setBranchId(sourceBranchOffice.getBranchId());
- targetBranchOffice.setBranchLandLineNumber(sourceBranchOffice.getBranchLandLineNumber());
- targetBranchOffice.setBranchLastHouseNumber(sourceBranchOffice.getBranchLastHouseNumber());
- targetBranchOffice.setBranchNumber(sourceBranchOffice.getBranchNumber());
- targetBranchOffice.setBranchOpeningTimes(sourceBranchOffice.getBranchOpeningTimes());
- targetBranchOffice.setBranchOwnerEmployee(sourceBranchOffice.getBranchOwnerEmployee());
- targetBranchOffice.setBranchStore(sourceBranchOffice.getBranchStore());
- targetBranchOffice.setBranchStreet(sourceBranchOffice.getBranchStreet());
- targetBranchOffice.setBranchSuiteNumber(sourceBranchOffice.getBranchSuiteNumber());
- targetBranchOffice.setBranchUserOwner(sourceBranchOffice.getBranchUserOwner());
- targetBranchOffice.setBranchZipCode(sourceBranchOffice.getBranchZipCode());
- }
-
- /**
- * Checks if both branch offices have same address. This method will throw
- * an {@code NullPointerException} if one of the instances is null.
- * <p>
- * @param branchOffice1 Branch office 1
- * @param branchOffice2 Branch office 2
- * <p>
- * @return Whether both branch office addresses are the same
- * <p>
- * @throws NullPointerException If one of the instances is null
- */
- public static boolean isSameAddress (final BranchOffice branchOffice1, final BranchOffice branchOffice2) {
- // Check that both parameters are not null
- if (null == branchOffice1) {
- // Throw NPE
- throw new NullPointerException("branchOffice1 is null"); //NOI18N
- } else if (null == branchOffice2) {
- // Throw NPE
- throw new NullPointerException("branchOffice2 is null"); //NOI18N
- }
-
- // Default is the same
- boolean isSameAddress = true;
-
- // Compare both addresses
- if (!Objects.equals(branchOffice1.getBranchCompany(), branchOffice2.getBranchCompany())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(branchOffice1.getBranchCountry(), branchOffice2.getBranchCountry())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(branchOffice1.getBranchCity(), branchOffice2.getBranchCity())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(branchOffice1.getBranchZipCode(), branchOffice2.getBranchZipCode())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(branchOffice1.getBranchStreet(), branchOffice2.getBranchStreet())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(branchOffice1.getBranchHouseNumber(), branchOffice2.getBranchHouseNumber())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(branchOffice1.getBranchHouseNumberExtension(), branchOffice2.getBranchHouseNumberExtension())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(branchOffice1.getBranchStore(), branchOffice2.getBranchStore())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(branchOffice1.getBranchSuiteNumber(), branchOffice2.getBranchSuiteNumber())) {
- // Not the same
- isSameAddress = false;
- }
-
- // Return flag
- return isSameAddress;
- }
-
- /**
- * Private default constructor
- */
- private BranchOffices () {
- // Utilities don't have instances
- }
-
-}
import javax.persistence.Transient;
import org.apache.commons.lang3.StringUtils;
import org.mxchange.jcontacts.model.contact.Contact;
-import org.mxchange.jcontacts.model.contact.Contacts;
import org.mxchange.jcontacts.model.contact.UserContact;
+import org.mxchange.jcontacts.model.utils.ContactUtils;
import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime;
// Init comparisons
final int[] comparators = {
+ // First compare basic data
// First compare basic data
this.getBranchCompany().compareTo(branchOffice.getBranchCompany()),
// ... branch office number
SafeNumberUtils.compare(this.getBranchNumber(), branchOffice.getBranchNumber()),
// ... owner employee
- Contacts.compare(this.getBranchOwnerEmployee(), branchOffice.getBranchOwnerEmployee()),
+ ContactUtils.compare(this.getBranchOwnerEmployee(), branchOffice.getBranchOwnerEmployee()),
// ... contact person
- Contacts.compare(this.getBranchContactEmployee(), branchOffice.getBranchContactEmployee()),
+ ContactUtils.compare(this.getBranchContactEmployee(), branchOffice.getBranchContactEmployee()),
// ... then country
this.getBranchCountry().compareTo(branchOffice.getBranchCountry()),
// ... next city
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import org.apache.commons.lang3.StringUtils;
import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.jcontacts.model.contact.UserContact;
+import org.mxchange.jcontacts.model.utils.ContactUtils;
import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices;
import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice;
import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter;
import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
-import org.mxchange.jcontactsbusiness.model.headquarter.Headquarters;
+import org.mxchange.jcontactsbusiness.model.utils.BasicDataUtils;
+import org.mxchange.jcontactsbusiness.model.utils.BranchOfficeUtils;
+import org.mxchange.jcontactsbusiness.model.utils.HeadquarterUtils;
import org.mxchange.jcoreutils.Comparables;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.Users;
/**
* A POJO for company departments
// Init comparisons
final int[] comparators = {
// First department's company (BasicData) ...
- this.getDepartmentCompany().compareTo(department.getDepartmentCompany()),
+ BasicDataUtils.compare(this.getDepartmentCompany(), department.getDepartmentCompany()),
// ... then headquarters
- Headquarters.compare(this.getDepartmentHeadquarter(), department.getDepartmentHeadquarter()),
+ HeadquarterUtils.compare(this.getDepartmentHeadquarter(), department.getDepartmentHeadquarter()),
// ... branch office
- BranchOffices.compare(this.getDepartmentBranchOffice(), department.getDepartmentBranchOffice()),
- // ... finally department's i18n key
- this.getDepartmentI18nKey().compareTo(department.getDepartmentI18nKey())
+ BranchOfficeUtils.compare(this.getDepartmentBranchOffice(), department.getDepartmentBranchOffice()),
+ // ... department's i18n key
+ StringUtils.compare(this.getDepartmentI18nKey(), department.getDepartmentI18nKey()),
+ // ... lead contact
+ ContactUtils.compare(this.getDepartmentLead(), department.getDepartmentLead()),
+ // ... user owner
+ Users.compare(this.getDepartmentUserOwner(), department.getDepartmentUserOwner())
};
// Check all values
+++ /dev/null
-/*
- * Copyright (C) 2017 - 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.department;
-
-import java.io.Serializable;
-import java.text.MessageFormat;
-import java.util.Objects;
-import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
-
-/**
- * Utilities class for departments
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class Departments implements Serializable {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 20_154_686_786_561L;
-
- /**
- * Compares both department instances. This method returns -1 if second
- * instance is null.
- * <p>
- * @param department1 Department instance 1
- * @param department2 Department instance 2
- * <p>
- * @return Comparison value
- */
- public static int compare (final Department department1, final Department department2) {
- // Check equality, then at least first must be given
- if (Objects.equals(department1, department2)) {
- // Both are same
- return 0;
- } else if (null == department1) {
- // First is null
- return -1;
- } else if (null == department2) {
- // Second is null
- return 1;
- }
-
- // Invoke compareTo() method
- return department1.compareTo(department2);
- }
-
- /**
- * Copies all data from source department to target department.
- * <p>
- * @param sourceDepartment Source department
- * @param targetDepartment Target department
- */
- public static void copyDepartmentData (final Department sourceDepartment, final Department targetDepartment) {
- // Check that both parameters are not null
- if (null == sourceDepartment) {
- // Throw NPE
- throw new NullPointerException("sourceDepartment is null"); //NOI18N
- } else if (null == targetDepartment) {
- // Throw NPE
- throw new NullPointerException("targetDepartment is null"); //NOI18N
- } else if (Objects.equals(sourceDepartment, targetDepartment)) {
- // Throw IAE
- throw new IllegalArgumentException("sourceDepartment and targetDepartment are the same"); //NOI18N
- }
-
- // Copy all fields
- targetDepartment.setDepartmentBranchOffice(sourceDepartment.getDepartmentBranchOffice());
- targetDepartment.setDepartmentCompany(sourceDepartment.getDepartmentCompany());
- targetDepartment.setDepartmentHeadquarter(sourceDepartment.getDepartmentHeadquarter());
- targetDepartment.setDepartmentI18nKey(sourceDepartment.getDepartmentI18nKey());
- targetDepartment.setDepartmentId(sourceDepartment.getDepartmentId());
- targetDepartment.setDepartmentLead(sourceDepartment.getDepartmentLead());
- targetDepartment.setDepartmentUserOwner(sourceDepartment.getDepartmentUserOwner());
- }
-
- /**
- * Checks if both departments are the same (entity) or if at least basic
- * company data and department name are matching.
- * <p>
- * @param department1 Department 1
- * @param department2 Department 2
- * <p>
- * @return Whether both are the same
- */
- public static boolean isSameDepartment (final Department department1, final Department department2) {
- // Now check it
- if (null == department1) {
- // Throw NPE
- throw new NullPointerException("department1 is null"); //NOI18N
- } else if (null == department2) {
- // Throw it again
- throw new NullPointerException("department2 is null"); //NOI18N
- } else if (Objects.equals(department1, department2)) {
- // Same department
- return true;
- } else if (department1.getDepartmentCompany() == null) {
- // Throw NPE again
- throw new NullPointerException("department1.departmentCompany is null"); //NOI18N
- } else if (department1.getDepartmentCompany().getBasicDataId() == null) {
- // Throw NPE again
- throw new NullPointerException("department1.departmentCompany.basicDataId is null"); //NOI18N
- } else if (department1.getDepartmentCompany().getBasicDataId() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("department1.departmentCompany.basicDataId={0} is valid.", department1.getDepartmentCompany().getBasicDataId())); //NOI18N
- } else if (department1.getDepartmentI18nKey() == null) {
- // Throw it again
- throw new NullPointerException("department1.departmentName is null"); //NOI18N
- } else if (department1.getDepartmentI18nKey().isEmpty()) {
- // Throw IAE
- throw new IllegalArgumentException("department1.departmentName is empty"); //NOI18N
- } else if (department2.getDepartmentCompany() == null) {
- // Throw NPE again
- throw new NullPointerException("department2.departmentCompany is null"); //NOI18N
- } else if (department2.getDepartmentCompany().getBasicDataId() == null) {
- // Throw NPE again
- throw new NullPointerException("department2.departmentCompany.basicDataId is null"); //NOI18N
- } else if (department2.getDepartmentCompany().getBasicDataId() < 1) {
- // Throw NPE again
- throw new NullPointerException(MessageFormat.format("department2.departmentCompany.basicDataId={0} is valid.", department2.getDepartmentCompany().getBasicDataId())); //NOI18N
- } else if (department2.getDepartmentI18nKey() == null) {
- // Throw it again
- throw new NullPointerException("department2.departmentName is null"); //NOI18N
- } else if (department2.getDepartmentI18nKey().isEmpty()) {
- // Throw IAE
- throw new IllegalArgumentException("department2.departmentName is empty"); //NOI18N
- }
-
- // Same company and same name?
- boolean isSame = ((Objects.equals(department1.getDepartmentCompany(), department2.getDepartmentCompany())) &&
- (((department1.getDepartmentBranchOffice() instanceof BranchOffice) &&
- (Objects.equals(department1.getDepartmentBranchOffice(), department2.getDepartmentBranchOffice()))) ||
- ((department1.getDepartmentHeadquarter() instanceof Headquarter) &&
- (Objects.equals(department1.getDepartmentHeadquarter(), department2.getDepartmentHeadquarter())))) &&
- (Objects.equals(department1.getDepartmentI18nKey(), department2.getDepartmentI18nKey())));
-
- // Return it
- return isSame;
- }
-
- /**
- * Private default constructor
- */
- private Departments () {
- // Prevent instances from utilities classes
- }
-
-}
import javax.persistence.Transient;
import org.apache.commons.lang3.StringUtils;
import org.mxchange.jcontacts.model.contact.Contact;
-import org.mxchange.jcontacts.model.contact.Contacts;
import org.mxchange.jcontacts.model.contact.UserContact;
+import org.mxchange.jcontacts.model.utils.ContactUtils;
import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices;
import org.mxchange.jcontactsbusiness.model.branchoffice.BusinessBranchOffice;
import org.mxchange.jcontactsbusiness.model.department.BusinessDepartment;
import org.mxchange.jcontactsbusiness.model.department.Department;
-import org.mxchange.jcontactsbusiness.model.department.Departments;
import org.mxchange.jcontactsbusiness.model.headquarter.BusinessHeadquarter;
import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
-import org.mxchange.jcontactsbusiness.model.headquarter.Headquarters;
import org.mxchange.jcontactsbusiness.model.jobposition.EmployeePosition;
import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition;
-import org.mxchange.jcontactsbusiness.model.jobposition.JobPositions;
+import org.mxchange.jcontactsbusiness.model.utils.JobPositionUtils;
+import org.mxchange.jcontactsbusiness.model.utils.BasicDataUtils;
+import org.mxchange.jcontactsbusiness.model.utils.BranchOfficeUtils;
+import org.mxchange.jcontactsbusiness.model.utils.DepartmentUtils;
+import org.mxchange.jcontactsbusiness.model.utils.HeadquarterUtils;
import org.mxchange.jcoreutils.Comparables;
import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumber;
// Init comparisons
final int[] comparators = {
+ // First employee's number
// First employee's number
StringUtils.compareIgnoreCase(this.getEmployeeNumber(), employable.getEmployeeNumber()),
// ... finally contact data
- Contacts.compare(this.getEmployeePersonalData(), employable.getEmployeePersonalData()),
+ ContactUtils.compare(this.getEmployeePersonalData(), employable.getEmployeePersonalData()),
// ... employee's email address
StringUtils.compareIgnoreCase(this.getEmployeeEmailAddress(), employable.getEmployeeEmailAddress()),
// ... company data (BasicData)
- this.getEmployeeBasicData().compareTo(employable.getEmployeeBasicData()),
- JobPositions.compare(this.getEmployeeJobPosition(), employable.getEmployeeJobPosition()),
+ BasicDataUtils.compare(this.getEmployeeBasicData(), employable.getEmployeeBasicData()),
+ // ... job position
+JobPositionUtils.compare(this.getEmployeeJobPosition(), employable.getEmployeeJobPosition()),
// ... department
- Departments.compare(this.getEmployeeDepartment(), employable.getEmployeeDepartment()),
+ DepartmentUtils.compare(this.getEmployeeDepartment(), employable.getEmployeeDepartment()),
// ... branch office
- BranchOffices.compare(this.getEmployeeBranchOffice(), employable.getEmployeeBranchOffice()),
+ BranchOfficeUtils.compare(this.getEmployeeBranchOffice(), employable.getEmployeeBranchOffice()),
// ... next headquarters
- Headquarters.compare(this.getEmployeeHeadquarter(), employable.getEmployeeHeadquarter()),};
+ HeadquarterUtils.compare(this.getEmployeeHeadquarter(), employable.getEmployeeHeadquarter()),};
// Check all values
final int comparison = Comparables.checkAll(comparators);
+++ /dev/null
-/*
- * Copyright (C) 2017 - 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.employee;
-
-import java.io.Serializable;
-import java.text.MessageFormat;
-import java.util.Objects;
-
-/**
- * Utilities class for employees
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class Employees implements Serializable {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 158_376_461_255_901L;
-
- /**
- * Compares both employee instances. This method returns -1 if second
- * instance is null.
- * <p>
- * @param employable1 Employee instance 1
- * @param employable2 Employee instance 2
- * <p>
- * @return Comparison value
- */
- public static int compare (final Employable employable1, final Employable employable2) {
- // Check equality, then at least first must be given
- if (Objects.equals(employable1, employable2)) {
- // Both are same
- return 0;
- } else if (null == employable1) {
- // First is null
- return -1;
- } else if (null == employable2) {
- // Second is null
- return 1;
- }
-
- // Invoke compareTo() method
- return employable1.compareTo(employable2);
- }
-
- /**
- * Checks whether both employees are the same
- * <p>
- * @param employee1 Employee 1
- * @param employee2 Employee 2
- * <p>
- * @return Whether both are the same
- */
- public static boolean isSameEmployeeFound (final Employable employee1, final Employable employee2) {
- // Validate parameter
- if (null == employee1) {
- // Throw NPE
- throw new NullPointerException("employee1 is null"); //NOI18N
- } else if (employee1.getEmployeeBasicData() == null) {
- // Throw it again
- throw new NullPointerException("employee1.employeeCompany is null"); //NOI18N
- } else if (employee1.getEmployeeBasicData().getBasicDataId() == null) {
- // Throw it again
- throw new NullPointerException("employee1.employeeCompany.basicDataId is null"); //NOI18N
- } else if (employee1.getEmployeeBasicData().getBasicDataId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("employee1.employeeCompany.basicDataId={0} is invalid.", employee1.getEmployeeBasicData().getBasicDataId())); //NOI18N
- } else if (employee1.getEmployeeBranchOffice() == null && employee1.getEmployeeDepartment() == null && employee1.getEmployeeHeadquarter() == null) {
- // At least one must be set
- throw new NullPointerException("employee1.employeeBranchOffice, employee1.employeeDepartment and employee1.employeeHeadquarter is null"); //NOI18N
- } else if (employee1.getEmployeeBranchOffice() != null && employee1.getEmployeeBranchOffice().getBranchId() == null) {
- // Throw NPE
- throw new NullPointerException("employee1.employeeBranchOffice.branchId is null"); //NOI18N
- } else if (employee1.getEmployeeBranchOffice() != null && employee1.getEmployeeBranchOffice().getBranchId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("employee1.employeeBranchOffice.branchId={0} is invalid.", employee1.getEmployeeBranchOffice().getBranchId())); //NOI18N
- } else if (employee1.getEmployeeDepartment() != null && employee1.getEmployeeDepartment().getDepartmentId() == null) {
- // Throw NPE
- throw new NullPointerException("employee1.employeeDepartment.departmentId is null"); //NOI18N
- } else if (employee1.getEmployeeDepartment() != null && employee1.getEmployeeDepartment().getDepartmentId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("employee1.employeeDepartment.departmentId={0} is invalid.", employee1.getEmployeeDepartment().getDepartmentId())); //NOI18N
- } else if (employee1.getEmployeeHeadquarter() != null && employee1.getEmployeeHeadquarter().getHeadquarterId() == null) {
- // Throw NPE
- throw new NullPointerException("employee1.employeeHeadquarter.headquarterId is null"); //NOI18N
- } 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.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
- } else if ((employee1.getEmployeePersonalData() != null) && (employee1.getEmployeePersonalData().getContactId() < 1)) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("employee1.employeePersonalData.contactId={0} is invalid.", employee1.getEmployeePersonalData().getContactId())); //NOI18N
- } else if ((employee1.getEmployeeNumber() != null) && (employee1.getEmployeeNumber().isEmpty())) {
- // Throw it again
- throw new IllegalArgumentException("employee1.employeeNumber is empty"); //NOI18N
- } else if (null == employee2) {
- // Throw NPE
- throw new NullPointerException("employee2 is null"); //NOI18N
- } else if (employee2.getEmployeeBasicData() == null) {
- // Throw it again
- throw new NullPointerException("employee2.employeeCompany is null"); //NOI18N
- } else if (employee2.getEmployeeBasicData().getBasicDataId() == null) {
- // Throw it again
- throw new NullPointerException("employee2.employeeCompany.basicDataId is null"); //NOI18N
- } else if (employee2.getEmployeeBasicData().getBasicDataId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("employee2.employeeCompany.basicDataId={0} is invalid.", employee2.getEmployeeBasicData().getBasicDataId())); //NOI18N
- } else if (employee2.getEmployeeBranchOffice() == null && employee2.getEmployeeDepartment() == null && employee2.getEmployeeHeadquarter() == null) {
- // At least one must be set
- throw new NullPointerException("employee2.employeeBranchOffice, employee2.employeeDepartment and employee2.employeeHeadquarter is null"); //NOI18N
- } else if (employee2.getEmployeeBranchOffice() != null && employee2.getEmployeeBranchOffice().getBranchId() == null) {
- // Throw NPE
- throw new NullPointerException("employee2.employeeBranchOffice.branchId is null"); //NOI18N
- } else if (employee2.getEmployeeBranchOffice() != null && employee2.getEmployeeBranchOffice().getBranchId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("employee2.employeeBranchOffice.branchId={0} is invalid.", employee2.getEmployeeBranchOffice().getBranchId())); //NOI18N
- } else if (employee2.getEmployeeDepartment() != null && employee2.getEmployeeDepartment().getDepartmentId() == null) {
- // Throw NPE
- throw new NullPointerException("employee2.employeeDepartment.departmentId is null"); //NOI18N
- } else if (employee2.getEmployeeDepartment() != null && employee2.getEmployeeDepartment().getDepartmentId() < 1) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("employee2.employeeDepartment.departmentId={0} is invalid.", employee2.getEmployeeDepartment().getDepartmentId())); //NOI18N
- } else if (employee2.getEmployeeHeadquarter() != null && employee2.getEmployeeHeadquarter().getHeadquarterId() == null) {
- // Throw NPE
- throw new NullPointerException("employee2.employeeHeadquarter.headquarterId is null"); //NOI18N
- } 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.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
- } else if ((employee2.getEmployeePersonalData() != null) && (employee2.getEmployeePersonalData().getContactId() < 1)) {
- // Throw IAE
- throw new IllegalArgumentException(MessageFormat.format("employee2.employeePersonalData.contactId={0} is invalid.", employee2.getEmployeePersonalData().getContactId())); //NOI18N
- } else if ((employee2.getEmployeeNumber() != null) && (employee2.getEmployeeNumber().isEmpty())) {
- // Throw it again
- throw new IllegalArgumentException("employee2.employeeNumber is empty"); //NOI18N
- } else if (Objects.equals(employee1, employee2)) {
- // Found equal entity
- return true;
- }
-
- // Same data found?
- if (!Objects.equals(employee1.getEmployeeBasicData(), employee2.getEmployeeBasicData())) {
- // Not the same companies
- return false;
- } else if (!Objects.equals(employee1.getEmployeeNumber(), employee2.getEmployeeNumber())) {
- // Not same number
- return false;
- } else if (!Objects.equals(employee1.getEmployeePersonalData(), employee2.getEmployeePersonalData())) {
- // Not same personal data
- return false;
- }
-
- // Is same employee
- return true;
- }
-
- /**
- * Private constructor
- */
- private Employees () {
- // No instances from utilities
- }
-
-}
+++ /dev/null
-/*
- * Copyright (C) 2017 - 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.headquarter;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-/**
- * An utilities class for headquarter
- *
- * @author Roland Häder<roland@mxchange.org>
- */
-public class Headquarters implements Serializable {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 69_537_867_224_651L;
-
- /**
- * Compare null-reference-safe 2 headquarter instances with each other.
- * <p>
- * @param headquarter1 Headquarter 1
- * @param headquarter2 Headquarter 2
- * <p>
- * @return Comparison value from invoking Comparable.compareTo()
- */
- public static int compare (final Headquarter headquarter1, final Headquarter headquarter2) {
- // Compare both
- if (Objects.equals(headquarter1, headquarter2)) {
- // Same headquarters
- return 0;
- } else if (null == headquarter1) {
- // First is null
- return -1;
- } else if (null == headquarter2) {
- // Second headquarter is null
- return 1;
- }
-
- // Now that both are not NULL, compare them
- return headquarter1.compareTo(headquarter2);
- }
-
- /**
- * Checks if both headquarter have same address. This method will throw an
- * {@code NullPointerException} if one of the instances is null.
- * <p>
- * @param headquarter1 Headquarter 1
- * @param headquarter2 Headquarter 2
- * <p>
- * @return Whether both branch office addresses are the same
- * <p>
- * @throws NullPointerException If one of the instances is null
- */
- public static boolean isSameAddress (final Headquarter headquarter1, final Headquarter headquarter2) {
- // Check that both parameters are not null
- if (null == headquarter1) {
- // Throw NPE
- throw new NullPointerException("headquarter1 is null"); //NOI18N
- } else if (null == headquarter2) {
- // Throw NPE
- throw new NullPointerException("headquarter2 is null"); //NOI18N
- }
-
- // Default is the same
- boolean isSameAddress = true;
-
- // Compare both addresses
- if (!Objects.equals(headquarter1.getHeadquarterCompanyName(), headquarter2.getHeadquarterCompanyName())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(headquarter1.getHeadquarterCountry(), headquarter2.getHeadquarterCountry())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(headquarter1.getHeadquarterCity(), headquarter2.getHeadquarterCity())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(headquarter1.getHeadquarterZipCode(), headquarter2.getHeadquarterZipCode())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(headquarter1.getHeadquarterStreet(), headquarter2.getHeadquarterStreet())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(headquarter1.getHeadquarterHouseNumber(), headquarter2.getHeadquarterHouseNumber())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(headquarter1.getHeadquarterHouseNumberExtension(), headquarter2.getHeadquarterHouseNumberExtension())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(headquarter1.getHeadquarterStore(), headquarter2.getHeadquarterStore())) {
- // Not the same
- isSameAddress = false;
- } else if (!Objects.equals(headquarter1.getHeadquarterSuiteNumber(), headquarter2.getHeadquarterSuiteNumber())) {
- // Not the same
- isSameAddress = false;
- }
-
- // Return flag
- return isSameAddress;
- }
-
- /**
- * Private default constructor
- */
- private Headquarters () {
- // Utilities don't have instances
- }
-
-}
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import org.apache.commons.lang3.StringUtils;
import org.mxchange.jcontactsbusiness.model.jobposition.status.JobPositionStatus;
import org.mxchange.jcoreutils.Comparables;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.Users;
/**
* A POJO for job positions
// Init comparisons
final int[] comparators = {
// First added by which user ...
- this.getJobPositionAddedUser().compareTo(jobPosition.getJobPositionAddedUser()),
+ Users.compare(this.getJobPositionAddedUser(), jobPosition.getJobPositionAddedUser()),
// ... next name
- this.getJobPositionName().compareToIgnoreCase(jobPosition.getJobPositionName())
+ StringUtils.compareIgnoreCase(this.getJobPositionName(), jobPosition.getJobPositionName())
};
// Check all values
+++ /dev/null
-/*
- * Copyright (C) 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcontactsbusiness.model.jobposition;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-/**
- * Utilities class for job positions
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class JobPositions implements Serializable {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 157_986_766_142_309L;
-
- /**
- * Compares both job position instances. This method returns -1 if second
- * instance is null.
- * <p>
- * @param jobPosition1 Job position instance 1
- * @param jobPosition2 Job position instance 2
- * <p>
- * @return Comparison value
- */
- public static int compare (final HireableJobPosition jobPosition1, final HireableJobPosition jobPosition2) {
- // Check equality, then at least first must be given
- if (Objects.equals(jobPosition1, jobPosition2)) {
- // Both are same
- return 0;
- } else if (null == jobPosition1) {
- // First is null
- return -1;
- } else if (null == jobPosition2) {
- // Second is null
- return 1;
- }
-
- // Invoke compareTo() method
- return jobPosition1.compareTo(jobPosition2);
- }
-
- /**
- * Private constructor
- */
- private JobPositions () {
- // No instance should be creatable
- }
-
-}
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
+import org.apache.commons.lang3.StringUtils;
import org.mxchange.jcoreutils.Comparables;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.Users;
/**
* A POJO for company logos
// Init comparisons
final int[] comparators = {
// First file name ...
- this.getLogoFileName().compareToIgnoreCase(logo.getLogoFileName()),
+ StringUtils.compareIgnoreCase(this.getLogoFileName(), logo.getLogoFileName()),
// ... then uploader instance
- this.getLogoUploaderUser().compareTo(logo.getLogoUploaderUser())
+ Users.compare(this.getLogoUploaderUser(), logo.getLogoUploaderUser())
};
// Check all values
--- /dev/null
+/*
+ * Copyright (C) 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.utils;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
+
+/**
+ * An utilities class for basic company data
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class BasicDataUtils implements Serializable {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 159_847_673_672_091L;
+
+ /**
+ * Compares both basic company data instances. This method returns -1 if
+ * second instance is null.
+ * <p>
+ * @param basicData1 Basic company data instance 1
+ * @param basicData2 Basic company data instance 2
+ * <p>
+ * @return Comparison value
+ */
+ public static int compare (final BasicData basicData1, final BasicData basicData2) {
+ // Check equality, then at least first must be given
+ if (Objects.equals(basicData1, basicData2)) {
+ // Both are same
+ return 0;
+ } else if (null == basicData1) {
+ // First is null
+ return -1;
+ } else if (null == basicData2) {
+ // Second is null
+ return 1;
+ }
+
+ // Invoke compareTo() method
+ return basicData1.compareTo(basicData2);
+ }
+
+ /**
+ * Utility classes should not have instances
+ */
+ private BasicDataUtils () {
+ // Private constructor
+ }
+
+}
--- /dev/null
+
+/*
+ * Copyright (C) 2017 - 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.utils;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+
+/**
+ * An utilities class for branch offices
+ *
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class BranchOfficeUtils implements Serializable {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 69_537_867_224_651L;
+
+ /**
+ * Compares both branch office instances. This method returns -1 if second
+ * instance is null.
+ * <p>
+ * @param branchOffice1 Branch office instance 1
+ * @param branchOffice2 Branch office instance 2
+ * <p>
+ * @return Comparison value
+ */
+ public static int compare (final BranchOffice branchOffice1, final BranchOffice branchOffice2) {
+ // Check equality, then at least first must be given
+ if (Objects.equals(branchOffice1, branchOffice2)) {
+ // Both are same
+ return 0;
+ } else if (null == branchOffice1) {
+ // First is null
+ return -1;
+ } else if (null == branchOffice2) {
+ // Second is null
+ return 1;
+ }
+
+ // Invoke compareTo() method
+ return branchOffice1.compareTo(branchOffice2);
+ }
+
+ /**
+ * Copies all fields from source to target branch office instance
+ * <p>
+ * @param sourceBranchOffice Source BranchOffice instance
+ * @param targetBranchOffice Target BranchOffice instance
+ */
+ public static void copyBranchOfficeData (final BranchOffice sourceBranchOffice, final BranchOffice targetBranchOffice) {
+ // Check that both parameters are not null
+ if (null == sourceBranchOffice) {
+ // Throw NPE
+ throw new NullPointerException("sourceBranchOffice is null"); //NOI18N
+ } else if (null == targetBranchOffice) {
+ // Throw NPE
+ throw new NullPointerException("targetBranchOffice is null"); //NOI18N
+ } else if (Objects.equals(sourceBranchOffice, targetBranchOffice)) {
+ // Throw IAE
+ throw new IllegalArgumentException("sourceBranchOffice and targetBranchOffice are the same"); //NOI18N
+ }
+
+ // Copy all fields
+ targetBranchOffice.setBranchCity(sourceBranchOffice.getBranchCity());
+ targetBranchOffice.setBranchCompany(sourceBranchOffice.getBranchCompany());
+ targetBranchOffice.setBranchContactEmployee(sourceBranchOffice.getBranchContactEmployee());
+ targetBranchOffice.setBranchCountry(sourceBranchOffice.getBranchCountry());
+ targetBranchOffice.setBranchEmailAddress(sourceBranchOffice.getBranchEmailAddress());
+ targetBranchOffice.setBranchFaxNumber(sourceBranchOffice.getBranchFaxNumber());
+ targetBranchOffice.setBranchHouseNumber(sourceBranchOffice.getBranchHouseNumber());
+ targetBranchOffice.setBranchHouseNumberExtension(sourceBranchOffice.getBranchHouseNumberExtension());
+ targetBranchOffice.setBranchId(sourceBranchOffice.getBranchId());
+ targetBranchOffice.setBranchLandLineNumber(sourceBranchOffice.getBranchLandLineNumber());
+ targetBranchOffice.setBranchLastHouseNumber(sourceBranchOffice.getBranchLastHouseNumber());
+ targetBranchOffice.setBranchNumber(sourceBranchOffice.getBranchNumber());
+ targetBranchOffice.setBranchOpeningTimes(sourceBranchOffice.getBranchOpeningTimes());
+ targetBranchOffice.setBranchOwnerEmployee(sourceBranchOffice.getBranchOwnerEmployee());
+ targetBranchOffice.setBranchStore(sourceBranchOffice.getBranchStore());
+ targetBranchOffice.setBranchStreet(sourceBranchOffice.getBranchStreet());
+ targetBranchOffice.setBranchSuiteNumber(sourceBranchOffice.getBranchSuiteNumber());
+ targetBranchOffice.setBranchUserOwner(sourceBranchOffice.getBranchUserOwner());
+ targetBranchOffice.setBranchZipCode(sourceBranchOffice.getBranchZipCode());
+ }
+
+ /**
+ * Checks if both branch offices have same address. This method will throw
+ * an {@code NullPointerException} if one of the instances is null.
+ * <p>
+ * @param branchOffice1 Branch office 1
+ * @param branchOffice2 Branch office 2
+ * <p>
+ * @return Whether both branch office addresses are the same
+ * <p>
+ * @throws NullPointerException If one of the instances is null
+ */
+ public static boolean isSameAddress (final BranchOffice branchOffice1, final BranchOffice branchOffice2) {
+ // Check that both parameters are not null
+ if (null == branchOffice1) {
+ // Throw NPE
+ throw new NullPointerException("branchOffice1 is null"); //NOI18N
+ } else if (null == branchOffice2) {
+ // Throw NPE
+ throw new NullPointerException("branchOffice2 is null"); //NOI18N
+ }
+
+ // Default is the same
+ boolean isSameAddress = true;
+
+ // Compare both addresses
+ if (!Objects.equals(branchOffice1.getBranchCompany(), branchOffice2.getBranchCompany())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(branchOffice1.getBranchCountry(), branchOffice2.getBranchCountry())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(branchOffice1.getBranchCity(), branchOffice2.getBranchCity())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(branchOffice1.getBranchZipCode(), branchOffice2.getBranchZipCode())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(branchOffice1.getBranchStreet(), branchOffice2.getBranchStreet())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(branchOffice1.getBranchHouseNumber(), branchOffice2.getBranchHouseNumber())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(branchOffice1.getBranchHouseNumberExtension(), branchOffice2.getBranchHouseNumberExtension())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(branchOffice1.getBranchStore(), branchOffice2.getBranchStore())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(branchOffice1.getBranchSuiteNumber(), branchOffice2.getBranchSuiteNumber())) {
+ // Not the same
+ isSameAddress = false;
+ }
+
+ // Return flag
+ return isSameAddress;
+ }
+
+ /**
+ * Private default constructor
+ */
+ private BranchOfficeUtils () {
+ // Utilities don't have instances
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 - 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.utils;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.Objects;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.department.Department;
+import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
+
+/**
+ * Utilities class for departments
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class DepartmentUtils implements Serializable {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 20_154_686_786_561L;
+
+ /**
+ * Compares both department instances. This method returns -1 if second
+ * instance is null.
+ * <p>
+ * @param department1 Department instance 1
+ * @param department2 Department instance 2
+ * <p>
+ * @return Comparison value
+ */
+ public static int compare (final Department department1, final Department department2) {
+ // Check equality, then at least first must be given
+ if (Objects.equals(department1, department2)) {
+ // Both are same
+ return 0;
+ } else if (null == department1) {
+ // First is null
+ return -1;
+ } else if (null == department2) {
+ // Second is null
+ return 1;
+ }
+
+ // Invoke compareTo() method
+ return department1.compareTo(department2);
+ }
+
+ /**
+ * Copies all data from source department to target department.
+ * <p>
+ * @param sourceDepartment Source department
+ * @param targetDepartment Target department
+ */
+ public static void copyDepartmentData (final Department sourceDepartment, final Department targetDepartment) {
+ // Check that both parameters are not null
+ if (null == sourceDepartment) {
+ // Throw NPE
+ throw new NullPointerException("sourceDepartment is null"); //NOI18N
+ } else if (null == targetDepartment) {
+ // Throw NPE
+ throw new NullPointerException("targetDepartment is null"); //NOI18N
+ } else if (Objects.equals(sourceDepartment, targetDepartment)) {
+ // Throw IAE
+ throw new IllegalArgumentException("sourceDepartment and targetDepartment are the same"); //NOI18N
+ }
+
+ // Copy all fields
+ targetDepartment.setDepartmentBranchOffice(sourceDepartment.getDepartmentBranchOffice());
+ targetDepartment.setDepartmentCompany(sourceDepartment.getDepartmentCompany());
+ targetDepartment.setDepartmentHeadquarter(sourceDepartment.getDepartmentHeadquarter());
+ targetDepartment.setDepartmentI18nKey(sourceDepartment.getDepartmentI18nKey());
+ targetDepartment.setDepartmentId(sourceDepartment.getDepartmentId());
+ targetDepartment.setDepartmentLead(sourceDepartment.getDepartmentLead());
+ targetDepartment.setDepartmentUserOwner(sourceDepartment.getDepartmentUserOwner());
+ }
+
+ /**
+ * Checks if both departments are the same (entity) or if at least basic
+ * company data and department name are matching.
+ * <p>
+ * @param department1 Department 1
+ * @param department2 Department 2
+ * <p>
+ * @return Whether both are the same
+ */
+ public static boolean isSameDepartment (final Department department1, final Department department2) {
+ // Now check it
+ if (null == department1) {
+ // Throw NPE
+ throw new NullPointerException("department1 is null"); //NOI18N
+ } else if (null == department2) {
+ // Throw it again
+ throw new NullPointerException("department2 is null"); //NOI18N
+ } else if (Objects.equals(department1, department2)) {
+ // Same department
+ return true;
+ } else if (department1.getDepartmentCompany() == null) {
+ // Throw NPE again
+ throw new NullPointerException("department1.departmentCompany is null"); //NOI18N
+ } else if (department1.getDepartmentCompany().getBasicDataId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("department1.departmentCompany.basicDataId is null"); //NOI18N
+ } else if (department1.getDepartmentCompany().getBasicDataId() < 1) {
+ // Throw NPE again
+ throw new NullPointerException(MessageFormat.format("department1.departmentCompany.basicDataId={0} is valid.", department1.getDepartmentCompany().getBasicDataId())); //NOI18N
+ } else if (department1.getDepartmentI18nKey() == null) {
+ // Throw it again
+ throw new NullPointerException("department1.departmentName is null"); //NOI18N
+ } else if (department1.getDepartmentI18nKey().isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("department1.departmentName is empty"); //NOI18N
+ } else if (department2.getDepartmentCompany() == null) {
+ // Throw NPE again
+ throw new NullPointerException("department2.departmentCompany is null"); //NOI18N
+ } else if (department2.getDepartmentCompany().getBasicDataId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("department2.departmentCompany.basicDataId is null"); //NOI18N
+ } else if (department2.getDepartmentCompany().getBasicDataId() < 1) {
+ // Throw NPE again
+ throw new NullPointerException(MessageFormat.format("department2.departmentCompany.basicDataId={0} is valid.", department2.getDepartmentCompany().getBasicDataId())); //NOI18N
+ } else if (department2.getDepartmentI18nKey() == null) {
+ // Throw it again
+ throw new NullPointerException("department2.departmentName is null"); //NOI18N
+ } else if (department2.getDepartmentI18nKey().isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("department2.departmentName is empty"); //NOI18N
+ }
+
+ // Same company and same name?
+ boolean isSame = ((Objects.equals(department1.getDepartmentCompany(), department2.getDepartmentCompany())) &&
+ (((department1.getDepartmentBranchOffice() instanceof BranchOffice) &&
+ (Objects.equals(department1.getDepartmentBranchOffice(), department2.getDepartmentBranchOffice()))) ||
+ ((department1.getDepartmentHeadquarter() instanceof Headquarter) &&
+ (Objects.equals(department1.getDepartmentHeadquarter(), department2.getDepartmentHeadquarter())))) &&
+ (Objects.equals(department1.getDepartmentI18nKey(), department2.getDepartmentI18nKey())));
+
+ // Return it
+ return isSame;
+ }
+
+ /**
+ * Private default constructor
+ */
+ private DepartmentUtils () {
+ // Prevent instances from utilities classes
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 - 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.utils;
+
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.Objects;
+import org.mxchange.jcontactsbusiness.model.employee.Employable;
+
+/**
+ * Utilities class for employees
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class EmployeeUtils implements Serializable {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 158_376_461_255_901L;
+
+ /**
+ * Compares both employee instances. This method returns -1 if second
+ * instance is null.
+ * <p>
+ * @param employable1 Employee instance 1
+ * @param employable2 Employee instance 2
+ * <p>
+ * @return Comparison value
+ */
+ public static int compare (final Employable employable1, final Employable employable2) {
+ // Check equality, then at least first must be given
+ if (Objects.equals(employable1, employable2)) {
+ // Both are same
+ return 0;
+ } else if (null == employable1) {
+ // First is null
+ return -1;
+ } else if (null == employable2) {
+ // Second is null
+ return 1;
+ }
+
+ // Invoke compareTo() method
+ return employable1.compareTo(employable2);
+ }
+
+ /**
+ * Checks whether both employees are the same
+ * <p>
+ * @param employee1 Employee 1
+ * @param employee2 Employee 2
+ * <p>
+ * @return Whether both are the same
+ */
+ public static boolean isSameEmployeeFound (final Employable employee1, final Employable employee2) {
+ // Validate parameter
+ if (null == employee1) {
+ // Throw NPE
+ throw new NullPointerException("employee1 is null"); //NOI18N
+ } else if (employee1.getEmployeeBasicData() == null) {
+ // Throw it again
+ throw new NullPointerException("employee1.employeeCompany is null"); //NOI18N
+ } else if (employee1.getEmployeeBasicData().getBasicDataId() == null) {
+ // Throw it again
+ throw new NullPointerException("employee1.employeeCompany.basicDataId is null"); //NOI18N
+ } else if (employee1.getEmployeeBasicData().getBasicDataId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("employee1.employeeCompany.basicDataId={0} is invalid.", employee1.getEmployeeBasicData().getBasicDataId())); //NOI18N
+ } else if (employee1.getEmployeeBranchOffice() == null && employee1.getEmployeeDepartment() == null && employee1.getEmployeeHeadquarter() == null) {
+ // At least one must be set
+ throw new NullPointerException("employee1.employeeBranchOffice, employee1.employeeDepartment and employee1.employeeHeadquarter is null"); //NOI18N
+ } else if (employee1.getEmployeeBranchOffice() != null && employee1.getEmployeeBranchOffice().getBranchId() == null) {
+ // Throw NPE
+ throw new NullPointerException("employee1.employeeBranchOffice.branchId is null"); //NOI18N
+ } else if (employee1.getEmployeeBranchOffice() != null && employee1.getEmployeeBranchOffice().getBranchId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("employee1.employeeBranchOffice.branchId={0} is invalid.", employee1.getEmployeeBranchOffice().getBranchId())); //NOI18N
+ } else if (employee1.getEmployeeDepartment() != null && employee1.getEmployeeDepartment().getDepartmentId() == null) {
+ // Throw NPE
+ throw new NullPointerException("employee1.employeeDepartment.departmentId is null"); //NOI18N
+ } else if (employee1.getEmployeeDepartment() != null && employee1.getEmployeeDepartment().getDepartmentId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("employee1.employeeDepartment.departmentId={0} is invalid.", employee1.getEmployeeDepartment().getDepartmentId())); //NOI18N
+ } else if (employee1.getEmployeeHeadquarter() != null && employee1.getEmployeeHeadquarter().getHeadquarterId() == null) {
+ // Throw NPE
+ throw new NullPointerException("employee1.employeeHeadquarter.headquarterId is null"); //NOI18N
+ } 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.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
+ } else if ((employee1.getEmployeePersonalData() != null) && (employee1.getEmployeePersonalData().getContactId() < 1)) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("employee1.employeePersonalData.contactId={0} is invalid.", employee1.getEmployeePersonalData().getContactId())); //NOI18N
+ } else if ((employee1.getEmployeeNumber() != null) && (employee1.getEmployeeNumber().isEmpty())) {
+ // Throw it again
+ throw new IllegalArgumentException("employee1.employeeNumber is empty"); //NOI18N
+ } else if (null == employee2) {
+ // Throw NPE
+ throw new NullPointerException("employee2 is null"); //NOI18N
+ } else if (employee2.getEmployeeBasicData() == null) {
+ // Throw it again
+ throw new NullPointerException("employee2.employeeCompany is null"); //NOI18N
+ } else if (employee2.getEmployeeBasicData().getBasicDataId() == null) {
+ // Throw it again
+ throw new NullPointerException("employee2.employeeCompany.basicDataId is null"); //NOI18N
+ } else if (employee2.getEmployeeBasicData().getBasicDataId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("employee2.employeeCompany.basicDataId={0} is invalid.", employee2.getEmployeeBasicData().getBasicDataId())); //NOI18N
+ } else if (employee2.getEmployeeBranchOffice() == null && employee2.getEmployeeDepartment() == null && employee2.getEmployeeHeadquarter() == null) {
+ // At least one must be set
+ throw new NullPointerException("employee2.employeeBranchOffice, employee2.employeeDepartment and employee2.employeeHeadquarter is null"); //NOI18N
+ } else if (employee2.getEmployeeBranchOffice() != null && employee2.getEmployeeBranchOffice().getBranchId() == null) {
+ // Throw NPE
+ throw new NullPointerException("employee2.employeeBranchOffice.branchId is null"); //NOI18N
+ } else if (employee2.getEmployeeBranchOffice() != null && employee2.getEmployeeBranchOffice().getBranchId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("employee2.employeeBranchOffice.branchId={0} is invalid.", employee2.getEmployeeBranchOffice().getBranchId())); //NOI18N
+ } else if (employee2.getEmployeeDepartment() != null && employee2.getEmployeeDepartment().getDepartmentId() == null) {
+ // Throw NPE
+ throw new NullPointerException("employee2.employeeDepartment.departmentId is null"); //NOI18N
+ } else if (employee2.getEmployeeDepartment() != null && employee2.getEmployeeDepartment().getDepartmentId() < 1) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("employee2.employeeDepartment.departmentId={0} is invalid.", employee2.getEmployeeDepartment().getDepartmentId())); //NOI18N
+ } else if (employee2.getEmployeeHeadquarter() != null && employee2.getEmployeeHeadquarter().getHeadquarterId() == null) {
+ // Throw NPE
+ throw new NullPointerException("employee2.employeeHeadquarter.headquarterId is null"); //NOI18N
+ } 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.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
+ } else if ((employee2.getEmployeePersonalData() != null) && (employee2.getEmployeePersonalData().getContactId() < 1)) {
+ // Throw IAE
+ throw new IllegalArgumentException(MessageFormat.format("employee2.employeePersonalData.contactId={0} is invalid.", employee2.getEmployeePersonalData().getContactId())); //NOI18N
+ } else if ((employee2.getEmployeeNumber() != null) && (employee2.getEmployeeNumber().isEmpty())) {
+ // Throw it again
+ throw new IllegalArgumentException("employee2.employeeNumber is empty"); //NOI18N
+ } else if (Objects.equals(employee1, employee2)) {
+ // Found equal entity
+ return true;
+ }
+
+ // Same data found?
+ if (!Objects.equals(employee1.getEmployeeBasicData(), employee2.getEmployeeBasicData())) {
+ // Not the same companies
+ return false;
+ } else if (!Objects.equals(employee1.getEmployeeNumber(), employee2.getEmployeeNumber())) {
+ // Not same number
+ return false;
+ } else if (!Objects.equals(employee1.getEmployeePersonalData(), employee2.getEmployeePersonalData())) {
+ // Not same personal data
+ return false;
+ }
+
+ // Is same employee
+ return true;
+ }
+
+ /**
+ * Private constructor
+ */
+ private EmployeeUtils () {
+ // No instances from utilities
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2017 - 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.utils;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
+
+/**
+ * An utilities class for headquarter
+ *
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class HeadquarterUtils implements Serializable {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 69_537_867_224_651L;
+
+ /**
+ * Compare null-reference-safe 2 headquarter instances with each other.
+ * <p>
+ * @param headquarter1 Headquarter 1
+ * @param headquarter2 Headquarter 2
+ * <p>
+ * @return Comparison value from invoking Comparable.compareTo()
+ */
+ public static int compare (final Headquarter headquarter1, final Headquarter headquarter2) {
+ // Compare both
+ if (Objects.equals(headquarter1, headquarter2)) {
+ // Same headquarters
+ return 0;
+ } else if (null == headquarter1) {
+ // First is null
+ return -1;
+ } else if (null == headquarter2) {
+ // Second headquarter is null
+ return 1;
+ }
+
+ // Now that both are not NULL, compare them
+ return headquarter1.compareTo(headquarter2);
+ }
+
+ /**
+ * Checks if both headquarter have same address. This method will throw an
+ * {@code NullPointerException} if one of the instances is null.
+ * <p>
+ * @param headquarter1 Headquarter 1
+ * @param headquarter2 Headquarter 2
+ * <p>
+ * @return Whether both branch office addresses are the same
+ * <p>
+ * @throws NullPointerException If one of the instances is null
+ */
+ public static boolean isSameAddress (final Headquarter headquarter1, final Headquarter headquarter2) {
+ // Check that both parameters are not null
+ if (null == headquarter1) {
+ // Throw NPE
+ throw new NullPointerException("headquarter1 is null"); //NOI18N
+ } else if (null == headquarter2) {
+ // Throw NPE
+ throw new NullPointerException("headquarter2 is null"); //NOI18N
+ }
+
+ // Default is the same
+ boolean isSameAddress = true;
+
+ // Compare both addresses
+ if (!Objects.equals(headquarter1.getHeadquarterCompanyName(), headquarter2.getHeadquarterCompanyName())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(headquarter1.getHeadquarterCountry(), headquarter2.getHeadquarterCountry())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(headquarter1.getHeadquarterCity(), headquarter2.getHeadquarterCity())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(headquarter1.getHeadquarterZipCode(), headquarter2.getHeadquarterZipCode())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(headquarter1.getHeadquarterStreet(), headquarter2.getHeadquarterStreet())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(headquarter1.getHeadquarterHouseNumber(), headquarter2.getHeadquarterHouseNumber())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(headquarter1.getHeadquarterHouseNumberExtension(), headquarter2.getHeadquarterHouseNumberExtension())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(headquarter1.getHeadquarterStore(), headquarter2.getHeadquarterStore())) {
+ // Not the same
+ isSameAddress = false;
+ } else if (!Objects.equals(headquarter1.getHeadquarterSuiteNumber(), headquarter2.getHeadquarterSuiteNumber())) {
+ // Not the same
+ isSameAddress = false;
+ }
+
+ // Return flag
+ return isSameAddress;
+ }
+
+ /**
+ * Private default constructor
+ */
+ private HeadquarterUtils () {
+ // Utilities don't have instances
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2022 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcontactsbusiness.model.utils;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition;
+
+/**
+ * Utilities class for job positions
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class JobPositionUtils implements Serializable {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 157_986_766_142_309L;
+
+ /**
+ * Compares both job position instances. This method returns -1 if second
+ * instance is null.
+ * <p>
+ * @param jobPosition1 Job position instance 1
+ * @param jobPosition2 Job position instance 2
+ * <p>
+ * @return Comparison value
+ */
+ public static int compare (final HireableJobPosition jobPosition1, final HireableJobPosition jobPosition2) {
+ // Check equality, then at least first must be given
+ if (Objects.equals(jobPosition1, jobPosition2)) {
+ // Both are same
+ return 0;
+ } else if (null == jobPosition1) {
+ // First is null
+ return -1;
+ } else if (null == jobPosition2) {
+ // Second is null
+ return 1;
+ }
+
+ // Invoke compareTo() method
+ return jobPosition1.compareTo(jobPosition2);
+ }
+
+ /**
+ * Private constructor
+ */
+ private JobPositionUtils () {
+ // No instance should be creatable
+ }
+
+}