]> git.mxchange.org Git - jphone-core.git/blob - src/org/mxchange/jphone/events/mobileprovider/added/AdminMobileProviderAddedEvent.java
Updated copyright year
[jphone-core.git] / src / org / mxchange / jphone / events / mobileprovider / added / AdminMobileProviderAddedEvent.java
1 /*
2  * Copyright (C) 2016 - 2024 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.jphone.events.mobileprovider.added;
18
19 import java.text.MessageFormat;
20 import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
21
22 /**
23  * An event when a new mobile provider has been added
24  * <p>
25  * @author Roland Häder<roland@mxchange.org>
26  */
27 public class AdminMobileProviderAddedEvent implements ObservableAdminMobileProviderAddedEvent {
28
29         /**
30          * Serial number
31          */
32         private static final long serialVersionUID = 18_521_758_718_691_064L;
33
34         /**
35          * Added mobile provider instance
36          */
37         private final MobileProvider addedMobileProvider;
38
39         /**
40          * Constructor with added mobile provider instance
41          * <p>
42          * @param addedMobileProvider Added mobile provider instance
43          */
44         public AdminMobileProviderAddedEvent (final MobileProvider addedMobileProvider) {
45                 // Check parameter
46                 if (null == addedMobileProvider) {
47                         // Throw NPE
48                         throw new NullPointerException("Parameter 'addedMobileProvider' is null"); //NOI18M
49                 } else if (addedMobileProvider.getProviderId() == null) {
50                         // Throw it again
51                         throw new NullPointerException("addedMobileProvider.providerId is null"); //NOI18M
52                 } else if (addedMobileProvider.getProviderId() < 1) {
53                         // Throw IAE
54                         throw new IllegalArgumentException(MessageFormat.format("addedMobileProvider.providerId={0} is invalid", addedMobileProvider.getProviderId())); //NOI18M
55                 } else if (addedMobileProvider.getProviderName() == null) {
56                         // Throw NPE again
57                         throw new NullPointerException("addedMobileProvider.providerMame is null"); //NOI18M
58                 } else if (addedMobileProvider.getProviderName().isEmpty()) {
59                         // Throw IAE
60                         throw new IllegalArgumentException("addedMobileProvider.providerName is empty"); //NOI18M
61                 } else if (addedMobileProvider.getProviderDialPrefix() == null) {
62                         // Throw NPE again
63                         throw new NullPointerException("addedMobileProvider.providerDialPrefix is null"); //NOI18M
64                 } else if (addedMobileProvider.getProviderDialPrefix() < 1) {
65                         // Throw IAE
66                         throw new IllegalArgumentException(MessageFormat.format("addedMobileProvider.providerDialPrefix={0} is invalid", addedMobileProvider.getProviderDialPrefix())); //NOI18M
67                 } else if (addedMobileProvider.getProviderCountry() == null) {
68                         // Throw it again
69                         throw new NullPointerException("addedMobileProvider.providerCountry is null"); //NOI18M
70                 } else if (addedMobileProvider.getProviderCountry().getCountryId() == null) {
71                         // Throw it again
72                         throw new NullPointerException("addedMobileProvider.providerCountry.countryId is null"); //NOI18M
73                 } else if (addedMobileProvider.getProviderCountry().getCountryId() < 1) {
74                         // Throw it again
75                         throw new NullPointerException(MessageFormat.format("addedMobileProvider.providerCountry.countryId={0} is invalid", addedMobileProvider.getProviderCountry().getCountryId())); //NOI18M
76                 }
77
78                 // Set it here
79                 this.addedMobileProvider = addedMobileProvider;
80         }
81
82         @Override
83         public MobileProvider getAddedMobileProvider () {
84                 return this.addedMobileProvider;
85         }
86
87 }