2 * Copyright (C) 2017 Roland Häder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jcontactsbusiness.model.department;
19 import java.io.Serializable;
20 import java.util.Objects;
23 * Utilities class for departments
25 * @author Roland Häder<roland@mxchange.org>
27 public class Departments implements Serializable {
32 private static final long serialVersionUID = 20_154_686_786_561L;
35 * Checks if both departments are the same (entity) or if at least basic
36 * company data and department name are matching.
38 * @param department1 Department 1
39 * @param department2 Department 2
41 * @return Whether both are the same
43 public static boolean isSameDepartment (final Department department1, final Department department2) {
45 if (null == department1) {
47 throw new NullPointerException("department1 is null"); //NOI18N
48 } else if (null == department2) {
50 throw new NullPointerException("department2 is null"); //NOI18N
51 } else if (Objects.equals(department1, department2)) {
54 } else if (department1.getDepartmentCompany() == null) {
56 throw new NullPointerException("department1.departmentCompany is null"); //NOI18N
57 } else if (department1.getDepartmentName() == null) {
59 throw new NullPointerException("department1.departmentName is null"); //NOI18N
60 } else if (department1.getDepartmentName().isEmpty()) {
62 throw new IllegalArgumentException("department1.departmentName is empty"); //NOI18N
63 } else if (department2.getDepartmentCompany() == null) {
65 throw new NullPointerException("department2.departmentCompany is null"); //NOI18N
66 } else if (department2.getDepartmentName() == null) {
68 throw new NullPointerException("department2.departmentName is null"); //NOI18N
69 } else if (department2.getDepartmentName().isEmpty()) {
71 throw new IllegalArgumentException("department2.departmentName is empty"); //NOI18N
74 // Same company and same name?
75 boolean isSame = ((Objects.equals(department1.getDepartmentCompany(), department2.getDepartmentCompany())) &&
76 (Objects.equals(department1.getDepartmentName(), department2.getDepartmentName())));
83 * Private default constructor
85 private Departments () {
86 // Prevent instances from utilities classes