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