2 * Copyright (C) 2017 - 2024 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.created;
19 import java.text.MessageFormat;
20 import org.mxchange.jcustomercore.model.customer.Customer;
23 * An interface for observable events being fired when a customer instance has
24 * been successfully created. This may happen when a customer profile was
27 * @author Roland Häder<roland@mxchange.org>
29 public class CreatedCustomerEvent implements ObservableCreatedCustomerEvent {
34 private static final long serialVersionUID = 24_138_056_876_716_451L;
37 * Customer instance being created
39 private final Customer createdCustomer;
42 * Constructor with customer instance
44 * @param createdCustomer Customer instance being created by helper
46 public CreatedCustomerEvent (final Customer createdCustomer) {
47 // The instance should be valid
48 if (null == createdCustomer) {
50 throw new NullPointerException("createdCustomer is null"); //NOI18N
51 } else if (createdCustomer.getCustomerId() == null) {
52 // Throw NPE, again ...
53 throw new NullPointerException("createdCustomer.customerId is null"); //NOI18N
54 } else if (createdCustomer.getCustomerId() < 1) {
56 throw new IllegalArgumentException(MessageFormat.format("createdCustomer.customerId={0} is not valid", createdCustomer.getCustomerId())); //NOI18N
57 } else if (createdCustomer.getCustomerNumber() == null) {
58 // Throw NPE, again ...
59 throw new NullPointerException("createdCustomer.customerNumber is null"); //NOI18N
60 } else if (createdCustomer.getCustomerNumber() == null) {
61 // Empty customer number
62 throw new IllegalArgumentException("createdCustomer.customerNumber is empty"); //NOI18N
63 } else if (createdCustomer.getCustomerContact() == null) {
65 throw new NullPointerException("createdCustomer.customerContact is null"); //NOI18N
66 } else if (createdCustomer.getCustomerContact().getContactId() == null) {
68 throw new NullPointerException("createdCustomer.customerContact.contactId is null"); //NOI18N
69 } else if (createdCustomer.getCustomerContact().getContactId() < 1) {
71 throw new IllegalArgumentException(MessageFormat.format("createdCustomer.customerContact.contactId={0} is not valid", createdCustomer.getCustomerContact().getContactId())); //NOI18N
74 // Set customer instance
75 this.createdCustomer = createdCustomer;
79 public Customer getCreatedCustomer () {
80 return this.createdCustomer;