]> git.mxchange.org Git - jcontacts-business-core.git/blob - src/org/mxchange/jcontactsbusiness/events/basicdata/added/AdminAddedBusinessBasicDataEvent.java
Updated copyright year
[jcontacts-business-core.git] / src / org / mxchange / jcontactsbusiness / events / basicdata / added / AdminAddedBusinessBasicDataEvent.java
1 /*
2  * Copyright (C) 2017, 2020 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.jcontactsbusiness.events.basicdata.added;
18
19 import java.text.MessageFormat;
20 import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
21
22 /**
23  * An event being thrown when new basic business data has been added.
24  * <p>
25  * @author Roland Häder<roland@mxchange.org>
26  */
27 public class AdminAddedBusinessBasicDataEvent implements ObservableAdminAddedBusinessBasicDataEvent {
28
29         /**
30          * Serial number
31          */
32         private static final long serialVersionUID = 41_908_266_873_657_271L;
33
34         /**
35          * Basic data instance just being created. It must bear aside company name
36          * also a primary key.
37          */
38         private final BasicData basicData;
39
40         /**
41          * Constructor with basic data
42          * <p>
43          * @param basicData Basic data with at least company name and primary key
44          */
45         public AdminAddedBusinessBasicDataEvent (final BasicData basicData) {
46                 // Is company name and primary key set?
47                 if (null == basicData) {
48                         // Throw NPE
49                         throw new NullPointerException("basicData is null"); //NOI18N
50                 } else if (basicData.getCompanyShortName() == null) {
51                         // Throw NPE again
52                         throw new NullPointerException("basicData.companyShortName is null"); //NOI18N
53                 } else if (basicData.getCompanyShortName().isEmpty()) {
54                         // Throw NPE again
55                         throw new IllegalArgumentException("basicData.companyShortName is empty"); //NOI18N
56                 } else if (basicData.getBasicDataId() == null) {
57                         // Throw NPE again
58                         throw new NullPointerException("basicData.basicDataId is null"); //NOI18N
59                 } else if (basicData.getBasicDataId() < 1) {
60                         // Throw NPE again
61                         throw new IllegalArgumentException(MessageFormat.format("basicData.basicDataId={0} is not valid.", basicData.getBasicDataId())); //NOI18N
62                 }
63
64                 // Set it here
65                 this.basicData = basicData;
66         }
67
68         @Override
69         public BasicData getBasicData () {
70                 return this.basicData;
71         }
72
73 }