2 * Copyright (C) 2016 - 2024 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.jphone.events.mobileprovider.added;
19 import java.text.MessageFormat;
20 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
23 * An event when a new mobile provider has been added
25 * @author Roland Häder<roland@mxchange.org>
27 public class AdminMobileProviderAddedEvent implements ObservableAdminMobileProviderAddedEvent {
32 private static final long serialVersionUID = 18_521_758_718_691_064L;
35 * Added mobile provider instance
37 private final MobileProvider addedMobileProvider;
40 * Constructor with added mobile provider instance
42 * @param addedMobileProvider Added mobile provider instance
44 public AdminMobileProviderAddedEvent (final MobileProvider addedMobileProvider) {
46 if (null == addedMobileProvider) {
48 throw new NullPointerException("Parameter 'addedMobileProvider' is null"); //NOI18M
49 } else if (addedMobileProvider.getProviderId() == null) {
51 throw new NullPointerException("addedMobileProvider.providerId is null"); //NOI18M
52 } else if (addedMobileProvider.getProviderId() < 1) {
54 throw new IllegalArgumentException(MessageFormat.format("addedMobileProvider.providerId={0} is invalid", addedMobileProvider.getProviderId())); //NOI18M
55 } else if (addedMobileProvider.getProviderName() == null) {
57 throw new NullPointerException("addedMobileProvider.providerMame is null"); //NOI18M
58 } else if (addedMobileProvider.getProviderName().isEmpty()) {
60 throw new IllegalArgumentException("addedMobileProvider.providerName is empty"); //NOI18M
61 } else if (addedMobileProvider.getProviderDialPrefix() == null) {
63 throw new NullPointerException("addedMobileProvider.providerDialPrefix is null"); //NOI18M
64 } else if (addedMobileProvider.getProviderDialPrefix() < 1) {
66 throw new IllegalArgumentException(MessageFormat.format("addedMobileProvider.providerDialPrefix={0} is invalid", addedMobileProvider.getProviderDialPrefix())); //NOI18M
67 } else if (addedMobileProvider.getProviderCountry() == null) {
69 throw new NullPointerException("addedMobileProvider.providerCountry is null"); //NOI18M
70 } else if (addedMobileProvider.getProviderCountry().getCountryId() == null) {
72 throw new NullPointerException("addedMobileProvider.providerCountry.countryId is null"); //NOI18M
73 } else if (addedMobileProvider.getProviderCountry().getCountryId() < 1) {
75 throw new NullPointerException(MessageFormat.format("addedMobileProvider.providerCountry.countryId={0} is invalid", addedMobileProvider.getProviderCountry().getCountryId())); //NOI18M
79 this.addedMobileProvider = addedMobileProvider;
83 public MobileProvider getAddedMobileProvider () {
84 return this.addedMobileProvider;