From: Roland Haeder Date: Sat, 7 May 2016 12:46:57 +0000 (+0200) Subject: Contined a bit: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9cc683eac464df7faa17776daa68002ecfbe26ec;p=jcustomer-core.git Contined a bit: - moved event (added) to proper place - added update-events --- diff --git a/src/org/mxchange/jcustomercore/events/AdminAddedCustomerEvent.java b/src/org/mxchange/jcustomercore/events/AdminAddedCustomerEvent.java deleted file mode 100644 index ea2c0dd..0000000 --- a/src/org/mxchange/jcustomercore/events/AdminAddedCustomerEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jcustomercore.events; - -import java.io.Serializable; -import org.mxchange.jcustomercore.model.customer.Customer; - -/** - * An interface for events being fired when an administrator has added a - * customer. - *

- * @author Roland Haeder - */ -public interface AdminAddedCustomerEvent extends Serializable { - - /** - * Getter for added customer instance - *

- * @return Added customer instance - */ - Customer getAddedCustomer (); - -} diff --git a/src/org/mxchange/jcustomercore/events/CustomerAdminAddedEvent.java b/src/org/mxchange/jcustomercore/events/CustomerAdminAddedEvent.java deleted file mode 100644 index a932797..0000000 --- a/src/org/mxchange/jcustomercore/events/CustomerAdminAddedEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jcustomercore.events; - -import java.text.MessageFormat; -import org.mxchange.jcustomercore.model.customer.Customer; - -/** - * An event being fired when an administrator has added a new customer - *

- * @author Roland Haeder - */ -public class CustomerAdminAddedEvent implements AdminAddedCustomerEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 1_782_358_678_347_190L; - - /** - * Added customer - */ - private final Customer addedCustomer; - - /** - * Constructor with valid customer instance being added (updated varriant) - *

- * @param addedCustomer Added customer instance - */ - public CustomerAdminAddedEvent (final Customer addedCustomer) { - // The instance should be valid - if (null == addedCustomer) { - // Throw NPE - throw new NullPointerException("addedCustomer is null"); //NOI18N - } else if (addedCustomer.getCustomerId() == null) { - // Throw NPE, again ... - throw new NullPointerException("addedCustomer.customerId is null"); //NOI18N - } else if (addedCustomer.getCustomerId() < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("addedCustomer.customerId={0} is not valid", addedCustomer.getCustomerId())); //NOI18N - } else if (addedCustomer.getCustomerNumber() == null) { - // Throw NPE, again ... - throw new NullPointerException("addedCustomer.customerNumber is null"); //NOI18N - } else if (addedCustomer.getCustomerNumber() == null) { - // Empty customer number - throw new IllegalArgumentException("addedCustomer.customerNumber is empty"); //NOI18N - } else if (addedCustomer.getCustomerContact() == null) { - // Throw again ... - throw new NullPointerException("addedCustomer.customerContact is null"); //NOI18N - } else if (addedCustomer.getCustomerContact().getContactId() == null) { - // ... and again ... - throw new NullPointerException("addedCustomer.customerContact.contactId is null"); //NOI18N - } else if (addedCustomer.getCustomerContact().getContactId() < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("addedCustomer.customerContact.contactId={0} is not valid", addedCustomer.getCustomerContact().getContactId())); //NOI18N - } - - // Set it here - this.addedCustomer = addedCustomer; - } - - @Override - public Customer getAddedCustomer () { - return this.addedCustomer; - } - -} diff --git a/src/org/mxchange/jcustomercore/events/customer/added/AdminAddedCustomerEvent.java b/src/org/mxchange/jcustomercore/events/customer/added/AdminAddedCustomerEvent.java new file mode 100644 index 0000000..21ce8f7 --- /dev/null +++ b/src/org/mxchange/jcustomercore/events/customer/added/AdminAddedCustomerEvent.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcustomercore.events.customer.added; + +import java.io.Serializable; +import org.mxchange.jcustomercore.model.customer.Customer; + +/** + * An interface for events being fired when an administrator has added a + * customer. + *

+ * @author Roland Haeder + */ +public interface AdminAddedCustomerEvent extends Serializable { + + /** + * Getter for added customer instance + *

+ * @return Added customer instance + */ + Customer getAddedCustomer (); + +} diff --git a/src/org/mxchange/jcustomercore/events/customer/added/CustomerAdminAddedEvent.java b/src/org/mxchange/jcustomercore/events/customer/added/CustomerAdminAddedEvent.java new file mode 100644 index 0000000..21050ee --- /dev/null +++ b/src/org/mxchange/jcustomercore/events/customer/added/CustomerAdminAddedEvent.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcustomercore.events.customer.added; + +import java.text.MessageFormat; +import org.mxchange.jcustomercore.model.customer.Customer; + +/** + * An event being fired when an administrator has added a new customer + *

+ * @author Roland Haeder + */ +public class CustomerAdminAddedEvent implements AdminAddedCustomerEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 1_782_358_678_347_190L; + + /** + * Added customer + */ + private final Customer addedCustomer; + + /** + * Constructor with valid customer instance being added (updated varriant) + *

+ * @param addedCustomer Added customer instance + */ + public CustomerAdminAddedEvent (final Customer addedCustomer) { + // The instance should be valid + if (null == addedCustomer) { + // Throw NPE + throw new NullPointerException("addedCustomer is null"); //NOI18N + } else if (addedCustomer.getCustomerId() == null) { + // Throw NPE, again ... + throw new NullPointerException("addedCustomer.customerId is null"); //NOI18N + } else if (addedCustomer.getCustomerId() < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("addedCustomer.customerId={0} is not valid", addedCustomer.getCustomerId())); //NOI18N + } else if (addedCustomer.getCustomerNumber() == null) { + // Throw NPE, again ... + throw new NullPointerException("addedCustomer.customerNumber is null"); //NOI18N + } else if (addedCustomer.getCustomerNumber() == null) { + // Empty customer number + throw new IllegalArgumentException("addedCustomer.customerNumber is empty"); //NOI18N + } else if (addedCustomer.getCustomerContact() == null) { + // Throw again ... + throw new NullPointerException("addedCustomer.customerContact is null"); //NOI18N + } else if (addedCustomer.getCustomerContact().getContactId() == null) { + // ... and again ... + throw new NullPointerException("addedCustomer.customerContact.contactId is null"); //NOI18N + } else if (addedCustomer.getCustomerContact().getContactId() < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("addedCustomer.customerContact.contactId={0} is not valid", addedCustomer.getCustomerContact().getContactId())); //NOI18N + } + + // Set it here + this.addedCustomer = addedCustomer; + } + + @Override + public Customer getAddedCustomer () { + return this.addedCustomer; + } + +} diff --git a/src/org/mxchange/jcustomercore/events/customer/update/AdminCustomerDataUpdatedEvent.java b/src/org/mxchange/jcustomercore/events/customer/update/AdminCustomerDataUpdatedEvent.java new file mode 100644 index 0000000..35c2b0e --- /dev/null +++ b/src/org/mxchange/jcustomercore/events/customer/update/AdminCustomerDataUpdatedEvent.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcustomercore.events.customer.update; + +import java.text.MessageFormat; +import org.mxchange.jcustomercore.model.customer.Customer; + +/** + * An event being fired when the administrator has updated customer data + *

+ * @author Roland Haeder + */ +public class AdminCustomerDataUpdatedEvent implements AdminUpdatedCustomerDataEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 14_785_787_174_676_290L; + + /** + * Updated customer instance + */ + private final Customer updatedCustomer; + + /** + * Constructor with updated customer instance + *

+ * @param updatedCustomer Updated customer instance + */ + public AdminCustomerDataUpdatedEvent (final Customer updatedCustomer) { + // Is the customer instance valid? + if (null == updatedCustomer) { + // Throw NPE + throw new NullPointerException("updatedCustomer is null"); //NOI18N + } else if (updatedCustomer.getCustomerId() == null) { + // 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 + } + + // Set it here + this.updatedCustomer = updatedCustomer; + } + + @Override + public Customer getUpdatedCustomer () { + return this.updatedCustomer; + } + +} diff --git a/src/org/mxchange/jcustomercore/events/customer/update/AdminUpdatedCustomerDataEvent.java b/src/org/mxchange/jcustomercore/events/customer/update/AdminUpdatedCustomerDataEvent.java new file mode 100644 index 0000000..c3afa89 --- /dev/null +++ b/src/org/mxchange/jcustomercore/events/customer/update/AdminUpdatedCustomerDataEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcustomercore.events.customer.update; + +import java.io.Serializable; +import org.mxchange.jcustomercore.model.customer.Customer; + +/** + * An interface for events being fired when an administrator updated customer data. + *

+ * @author Roland Haeder + */ +public interface AdminUpdatedCustomerDataEvent extends Serializable { + + /** + * Getter for updated customer instance + *

+ * @return Added customer instance + */ + Customer getUpdatedCustomer (); + +} diff --git a/src/org/mxchange/jcustomercore/exceptions/EmailAddressAlreadyRegisteredException.java b/src/org/mxchange/jcustomercore/exceptions/EmailAddressAlreadyRegisteredException.java new file mode 100644 index 0000000..fa7f1eb --- /dev/null +++ b/src/org/mxchange/jcustomercore/exceptions/EmailAddressAlreadyRegisteredException.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 Galdora e.K. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcustomercore.exceptions; + +import java.text.MessageFormat; +import org.mxchange.jcustomercore.model.customer.Customer; + +/** + * An exception thrown when the recruiter's email address is already registered. + *

+ * @author Roland Haeder + */ +public class EmailAddressAlreadyRegisteredException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 16_435_892_878_271L; + + /** + * Constructor with already registered recruiter instance + *

+ * @param customer Customer instance + */ + public EmailAddressAlreadyRegisteredException (final Customer customer) { + // Call super contructor + super(MessageFormat.format("Email address {0} already registered.", customer.getCustomerContact().getContactEmailAddress())); //NOI18N + } + +}