*/
package org.mxchange.jcustomercore.events.customer.created;
+import java.text.MessageFormat;
import org.mxchange.jcustomercore.model.customer.Customer;
/**
* An interface for observable events being fired when a customer instance has
- * been successfully created. This may happen when a customer profile was called.
+ * been successfully created. This may happen when a customer profile was
+ * called.
* <p>
* @author Roland Häder<roland@mxchange.org>
*/
* @param createdCustomer Customer instance being created by helper
*/
public CreatedCustomerEvent (final Customer createdCustomer) {
+ // The instance should be valid
+ if (null == createdCustomer) {
+ // Throw NPE
+ throw new NullPointerException("createdCustomer is null"); //NOI18N
+ } else if (createdCustomer.getCustomerId() == null) {
+ // Throw NPE, again ...
+ throw new NullPointerException("createdCustomer.customerId is null"); //NOI18N
+ } else if (createdCustomer.getCustomerId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("createdCustomer.customerId={0} is not valid", createdCustomer.getCustomerId())); //NOI18N
+ } else if (createdCustomer.getCustomerNumber() == null) {
+ // Throw NPE, again ...
+ throw new NullPointerException("createdCustomer.customerNumber is null"); //NOI18N
+ } else if (createdCustomer.getCustomerNumber() == null) {
+ // Empty customer number
+ throw new IllegalArgumentException("createdCustomer.customerNumber is empty"); //NOI18N
+ } else if (createdCustomer.getCustomerContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("createdCustomer.customerContact is null"); //NOI18N
+ } else if (createdCustomer.getCustomerContact().getContactId() == null) {
+ // ... and again ...
+ throw new NullPointerException("createdCustomer.customerContact.contactId is null"); //NOI18N
+ } else if (createdCustomer.getCustomerContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("createdCustomer.customerContact.contactId={0} is not valid", createdCustomer.getCustomerContact().getContactId())); //NOI18N
+ }
+
// Set customer instance
this.createdCustomer = createdCustomer;
}
* @param updatedCustomer Updated customer instance
*/
public AdminUpdatedCustomerDataEvent (final Customer updatedCustomer) {
- // Is the customer instance valid?
+ // The instance should be valid
if (null == updatedCustomer) {
// Throw NPE
throw new NullPointerException("updatedCustomer is null"); //NOI18N
} else if (updatedCustomer.getCustomerId() == null) {
- // Throw NPE again
+ // Throw NPE, again ...
throw new NullPointerException("updatedCustomer.customerId is null"); //NOI18N
} else if (updatedCustomer.getCustomerId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("updatedCustomer.customerId={0} is invalid.", updatedCustomer.getCustomerId())); //NOI18N
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("updatedCustomer.customerId={0} is not valid", updatedCustomer.getCustomerId())); //NOI18N
+ } else if (updatedCustomer.getCustomerNumber() == null) {
+ // Throw NPE, again ...
+ throw new NullPointerException("updatedCustomer.customerNumber is null"); //NOI18N
+ } else if (updatedCustomer.getCustomerNumber() == null) {
+ // Empty customer number
+ throw new IllegalArgumentException("updatedCustomer.customerNumber is empty"); //NOI18N
+ } else if (updatedCustomer.getCustomerContact() == null) {
+ // Throw again ...
+ throw new NullPointerException("updatedCustomer.customerContact is null"); //NOI18N
+ } else if (updatedCustomer.getCustomerContact().getContactId() == null) {
+ // ... and again ...
+ throw new NullPointerException("updatedCustomer.customerContact.contactId is null"); //NOI18N
+ } else if (updatedCustomer.getCustomerContact().getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("updatedCustomer.customerContact.contactId={0} is not valid", updatedCustomer.getCustomerContact().getContactId())); //NOI18N
}
// Set it here
import org.mxchange.jcontacts.model.contact.UserContact;
import org.mxchange.jcontacts.model.utils.ContactUtils;
import org.mxchange.jcoreutils.comparable.ComparableUtils;
+import org.mxchange.jcoreutils.enums.EnumUtils;
import org.mxchange.jcustomercore.model.customer.status.CustomerAccountStatus;
/**
ContactUtils.compare(this.getCustomerContact(), customer.getCustomerContact()),
// ... then customer number
StringUtils.compare(this.getCustomerNumber(), customer.getCustomerNumber()),
- // ... last is confirmation key
- StringUtils.compare(this.getCustomerConfirmKey(), customer.getCustomerConfirmKey())
+ // ... next is confirmation key
+ StringUtils.compare(this.getCustomerConfirmKey(), customer.getCustomerConfirmKey()),
+ // ... next account status
+ EnumUtils.compare(this.getCustomerAccountStatus(), customer.getCustomerAccountStatus())
};
// Check all values
* @param styleClass CSS style class
*/
private CustomerAccountStatus (final String messageKey, final String styleClass) {
- // Validate parameter
- if (null == messageKey) {
- // Throw NPE
- throw new NullPointerException("messageKey is null"); //NOI18N
- } else if (messageKey.isEmpty()) {
- // Throw IAE
- throw new IllegalArgumentException("messageKey is empty"); //NOI18N
- } else if (null == styleClass) {
- // Throw NPE
- throw new NullPointerException("styleClass is null"); //NOI18N
- } else if (styleClass.isEmpty()) {
- // Throw IAE
- throw new IllegalArgumentException("styleClass is empty"); //NOI18N
- }
-
// Set it here
this.messageKey = messageKey;
this.styleClass = styleClass;