]> git.mxchange.org Git - jphone-core.git/blob - src/org/mxchange/jphone/events/landline/created/CreatedLandLineNumberEvent.java
27e75bffe3f6064552ebcefe639dbc3a4b463c7f
[jphone-core.git] / src / org / mxchange / jphone / events / landline / created / CreatedLandLineNumberEvent.java
1 /*
2  * Copyright (C) 2017 - 2022 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.landline.created;
18
19 import java.text.MessageFormat;
20 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
21
22 /**
23  * An event being fired when a land-line number instance has been successfully
24  * created..
25  * <p>
26  * @author Roland Häder<roland@mxchange.org>
27  */
28 public class CreatedLandLineNumberEvent implements ObservableCreatedLandLineNumberEvent {
29
30         /**
31          * Serial number
32          */
33         private static final long serialVersionUID = 50_498_269_827_582L;
34
35         /**
36          * Land-line number
37          */
38         private DialableLandLineNumber landLineNumber;
39
40         /**
41          * Constructor with fax number instance
42          * <p>
43          * @param landLineNumber Land-line number instance
44          */
45         public CreatedLandLineNumberEvent (final DialableLandLineNumber landLineNumber) {
46                 // Check parameter
47                 if (null == landLineNumber) {
48                         // Throw NPE
49                         throw new NullPointerException("Parameter 'landLineNumber' is null"); //NOI18M
50                 } else if (landLineNumber.getPhoneId() == null) {
51                         // Throw it again
52                         throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18M
53                 } else if (landLineNumber.getPhoneId() < 1) {
54                         // Throw IAE
55                         throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneId={0} is invalid", landLineNumber.getPhoneId())); //NOI18M
56                 } else if (landLineNumber.getPhoneAreaCode() == null) {
57                         // Throw it again
58                         throw new NullPointerException("landLineNumber.phoneAreaCode is null"); //NOI18M
59                 } else if (landLineNumber.getPhoneAreaCode() < 1) {
60                         // Throw IAE
61                         throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneAreaCode={0} is invalid", landLineNumber.getPhoneAreaCode())); //NOI18M
62                 } else if (landLineNumber.getPhoneNumber() == null) {
63                         // Throw it again
64                         throw new NullPointerException("landLineNumber.phoneNumber is null"); //NOI18M
65                 } else if (landLineNumber.getPhoneNumber() < 1) {
66                         // Throw IAE
67                         throw new IllegalArgumentException(MessageFormat.format("landLineNumber.phoneNumber={0} is invalid", landLineNumber.getPhoneNumber())); //NOI18M
68                 } else if (landLineNumber.getPhoneCountry() == null) {
69                         // Throw it again
70                         throw new NullPointerException("landLineNumber.phoneCountry is null"); //NOI18M
71                 } else if (landLineNumber.getPhoneCountry().getCountryId() == null) {
72                         // Throw it again
73                         throw new NullPointerException("landLineNumber.phoneCountry.countryId is null"); //NOI18M
74                 } else if (landLineNumber.getPhoneCountry().getCountryId() < 1) {
75                         // Throw it again
76                         throw new NullPointerException(MessageFormat.format("landLineNumber.phoneCountry.countryId={0} is invalid", landLineNumber.getPhoneCountry().getCountryId())); //NOI18M
77                 }
78
79                 // Set it here
80                 this.landLineNumber = landLineNumber;
81         }
82
83         @Override
84         public DialableLandLineNumber getLandLineNumber () {
85                 return this.landLineNumber;
86         }
87
88         @Override
89         public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {
90                 this.landLineNumber = landLineNumber;
91         }
92
93 }