2 * Copyright (C) 2016, 2017 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.jcustomercore.events.customer.added;
19 import java.text.MessageFormat;
20 import org.mxchange.jcustomercore.model.customer.Customer;
23 * An event being fired when an administrator has added a new customer
25 * @author Roland Häder<roland@mxchange.org>
27 public class AdminAddedCustomerEvent implements ObservableAdminAddedCustomerEvent {
32 private static final long serialVersionUID = 1_782_358_678_347_190L;
37 private final Customer addedCustomer;
40 * Constructor with valid customer instance being added (updated varriant)
42 * @param addedCustomer Added customer instance
44 public AdminAddedCustomerEvent (final Customer addedCustomer) {
45 // The instance should be valid
46 if (null == addedCustomer) {
48 throw new NullPointerException("addedCustomer is null"); //NOI18N
49 } else if (addedCustomer.getCustomerId() == null) {
50 // Throw NPE, again ...
51 throw new NullPointerException("addedCustomer.customerId is null"); //NOI18N
52 } else if (addedCustomer.getCustomerId() < 1) {
54 throw new IllegalArgumentException(MessageFormat.format("addedCustomer.customerId={0} is not valid", addedCustomer.getCustomerId())); //NOI18N
55 } else if (addedCustomer.getCustomerNumber() == null) {
56 // Throw NPE, again ...
57 throw new NullPointerException("addedCustomer.customerNumber is null"); //NOI18N
58 } else if (addedCustomer.getCustomerNumber() == null) {
59 // Empty customer number
60 throw new IllegalArgumentException("addedCustomer.customerNumber is empty"); //NOI18N
61 } else if (addedCustomer.getCustomerContact() == null) {
63 throw new NullPointerException("addedCustomer.customerContact is null"); //NOI18N
64 } else if (addedCustomer.getCustomerContact().getContactId() == null) {
66 throw new NullPointerException("addedCustomer.customerContact.contactId is null"); //NOI18N
67 } else if (addedCustomer.getCustomerContact().getContactId() < 1) {
69 throw new IllegalArgumentException(MessageFormat.format("addedCustomer.customerContact.contactId={0} is not valid", addedCustomer.getCustomerContact().getContactId())); //NOI18N
73 this.addedCustomer = addedCustomer;
77 public Customer getAddedCustomer () {
78 return this.addedCustomer;