]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/model/branchoffice/BranchOffices.java
Changed copyright notice to the FSF, so after my death they will continue my
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / model / branchoffice / BranchOffices.java
1 /*
2  * Copyright (C) 2017 Free Software Foundation
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jcontactsbusiness.model.branchoffice;
18
19 import java.io.Serializable;
20 import java.util.Objects;
21
22 /**
23  * An utilities class for branch offices
24  *
25  * @author Roland Häder<roland@mxchange.org>
26  */
27 public class BranchOffices implements Serializable {
28
29         /**
30          * Serial number
31          */
32         private static final long serialVersionUID = 69_537_867_224_651L;
33
34         /**
35          * Checks if both branch offices have same address. This method will throw
36          * an {@code NullPointerException} if one of the instances is null.
37          * <p>
38          * @param branchOffice1 Branch office 1
39          * @param branchOffice2 Branch office 2
40          * <p>
41          * @return Whether both branch office addresses are the same
42          * <p>
43          * @throws NullPointerException If one of the instances is null
44          */
45         public static boolean isSameAddress (final BranchOffice branchOffice1, final BranchOffice branchOffice2) {
46                 // Check that both parameters are not null
47                 if (null == branchOffice1) {
48                         // Throw NPE
49                         throw new NullPointerException("branchOffice1 is null"); //NOI18N
50                 } else if (null == branchOffice2) {
51                         // Throw NPE
52                         throw new NullPointerException("branchOffice2 is null"); //NOI18N
53                 }
54
55                 // Default is the same
56                 boolean isSameAddress = true;
57
58                 // Compare both addresses
59                 if (!Objects.equals(branchOffice1.getBranchCompany(), branchOffice2.getBranchCompany())) {
60                         // Not the same
61                         isSameAddress = false;
62                 } else if (!Objects.equals(branchOffice1.getBranchCountry(), branchOffice2.getBranchCountry())) {
63                         // Not the same
64                         isSameAddress = false;
65                 } else if (!Objects.equals(branchOffice1.getBranchCity(), branchOffice2.getBranchCity())) {
66                         // Not the same
67                         isSameAddress = false;
68                 } else if (!Objects.equals(branchOffice1.getBranchZipCode(), branchOffice2.getBranchZipCode())) {
69                         // Not the same
70                         isSameAddress = false;
71                 } else if (!Objects.equals(branchOffice1.getBranchStreet(), branchOffice2.getBranchStreet())) {
72                         // Not the same
73                         isSameAddress = false;
74                 } else if (!Objects.equals(branchOffice1.getBranchHouseNumber(), branchOffice2.getBranchHouseNumber())) {
75                         // Not the same
76                         isSameAddress = false;
77                 } else if (!Objects.equals(branchOffice1.getBranchHouseNumberExtension(), branchOffice2.getBranchHouseNumberExtension())) {
78                         // Not the same
79                         isSameAddress = false;
80                 } else if (!Objects.equals(branchOffice1.getBranchStore(), branchOffice2.getBranchStore())) {
81                         // Not the same
82                         isSameAddress = false;
83                 } else if (!Objects.equals(branchOffice1.getBranchSuiteNumber(), branchOffice2.getBranchSuiteNumber())) {
84                         // Not the same
85                         isSameAddress = false;
86                 }
87
88                 // Return flag
89                 return isSameAddress;
90         }
91
92         /**
93          * Private default constructor
94          */
95         private BranchOffices () {
96                 // Utilities don't have instances
97         }
98
99 }