2 * Copyright (C) 2017 Free Software Foundation
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.branchoffice;
19 import java.io.Serializable;
20 import java.util.Objects;
23 * An utilities class for branch offices
25 * @author Roland Häder<roland@mxchange.org>
27 public class BranchOffices implements Serializable {
32 private static final long serialVersionUID = 69_537_867_224_651L;
35 * Checks if both branch offices have same address. This method will throw
36 * an {@code NullPointerException} if one of the instances is null.
38 * @param branchOffice1 Branch office 1
39 * @param branchOffice2 Branch office 2
41 * @return Whether both branch office addresses are the same
43 * @throws NullPointerException If one of the instances is null
45 public static boolean isSameAddress (final BranchOffice branchOffice1, final BranchOffice branchOffice2) {
46 // Check that both parameters are not null
47 if (null == branchOffice1) {
49 throw new NullPointerException("branchOffice1 is null"); //NOI18N
50 } else if (null == branchOffice2) {
52 throw new NullPointerException("branchOffice2 is null"); //NOI18N
55 // Default is the same
56 boolean isSameAddress = true;
58 // Compare both addresses
59 if (!Objects.equals(branchOffice1.getBranchCompany(), branchOffice2.getBranchCompany())) {
61 isSameAddress = false;
62 } else if (!Objects.equals(branchOffice1.getBranchCountry(), branchOffice2.getBranchCountry())) {
64 isSameAddress = false;
65 } else if (!Objects.equals(branchOffice1.getBranchCity(), branchOffice2.getBranchCity())) {
67 isSameAddress = false;
68 } else if (!Objects.equals(branchOffice1.getBranchZipCode(), branchOffice2.getBranchZipCode())) {
70 isSameAddress = false;
71 } else if (!Objects.equals(branchOffice1.getBranchStreet(), branchOffice2.getBranchStreet())) {
73 isSameAddress = false;
74 } else if (!Objects.equals(branchOffice1.getBranchHouseNumber(), branchOffice2.getBranchHouseNumber())) {
76 isSameAddress = false;
77 } else if (!Objects.equals(branchOffice1.getBranchHouseNumberExtension(), branchOffice2.getBranchHouseNumberExtension())) {
79 isSameAddress = false;
80 } else if (!Objects.equals(branchOffice1.getBranchStore(), branchOffice2.getBranchStore())) {
82 isSameAddress = false;
83 } else if (!Objects.equals(branchOffice1.getBranchSuiteNumber(), branchOffice2.getBranchSuiteNumber())) {
85 isSameAddress = false;
93 * Private default constructor
95 private BranchOffices () {
96 // Utilities don't have instances