2 * Copyright (C) 2022 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.jcountry.model.data;
19 import java.io.Serializable;
20 import java.util.Objects;
23 * An utilities class for countries
25 * @author Roland Häder<roland@mxchange.org>
27 public class Countries implements Serializable {
32 private static final long serialVersionUID = 286_956_737_410L;
35 * Copies data from sourceCountry to targetCountry.
37 * @param sourceCountry Source Country instance to copy data from
38 * @param targetCountry Target Country instance to copy data to
40 * @throws NullPointerException If sourceCountry or targetCountry is null
41 * @throws IllegalArgumentException If both Country instances are equal
43 public static void copyCountryData (final Country sourceCountry, final Country targetCountry) {
44 // Parameters should not be null
45 if (null == sourceCountry) {
47 throw new NullPointerException("sourceCountry is null"); //NOI18N
48 } else if (null == targetCountry) {
50 throw new NullPointerException("targetCountry is null"); //NOI18N
51 } else if (Objects.equals(sourceCountry, targetCountry)) {
53 * Source and target country should never be equal, please check the
54 * condition before invoking this method.
56 throw new IllegalArgumentException("Both sourceCountry and targetCountry are equal.");
60 targetCountry.setCountryAbroadDialPrefix(sourceCountry.getCountryAbroadDialPrefix());
61 targetCountry.setCountryCode(sourceCountry.getCountryCode());
62 targetCountry.setCountryExternalDialPrefix(sourceCountry.getCountryExternalDialPrefix());
63 targetCountry.setCountryI18nKey(sourceCountry.getCountryI18nKey());
64 targetCountry.setCountryId(sourceCountry.getCountryId());
65 targetCountry.setCountryIsLocalPrefixRequired(sourceCountry.getCountryIsLocalPrefixRequired());
66 targetCountry.setCountryPhoneCode(sourceCountry.getCountryPhoneCode());
70 * Utility classes should not have instances
72 private Countries () {