From d1d42b96b371c980daf6baa8dca0110642d77fd9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 24 Apr 2020 18:18:36 +0200 Subject: [PATCH] Continued: - renamed added-event as this is for administrators - added administrative updated-event for receipt items MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- ...t.java => AdminReceiptItemAddedEvent.java} | 29 ++++---- ...ObservableAdminReceiptItemAddedEvent.java} | 8 +-- .../updated/AdminReceiptItemUpdatedEvent.java | 67 +++++++++++++++++++ ...bservableAdminReceiptItemUpdatedEvent.java | 37 ++++++++++ 4 files changed, 123 insertions(+), 18 deletions(-) rename src/org/mxchange/jfinancials/events/receipt_item/added/{ReceiptItemAddedEvent.java => AdminReceiptItemAddedEvent.java} (58%) rename src/org/mxchange/jfinancials/events/receipt_item/added/{ObservableReceiptItemAddedEvent.java => ObservableAdminReceiptItemAddedEvent.java} (84%) create mode 100644 src/org/mxchange/jfinancials/events/receipt_item/updated/AdminReceiptItemUpdatedEvent.java create mode 100644 src/org/mxchange/jfinancials/events/receipt_item/updated/ObservableAdminReceiptItemUpdatedEvent.java diff --git a/src/org/mxchange/jfinancials/events/receipt_item/added/ReceiptItemAddedEvent.java b/src/org/mxchange/jfinancials/events/receipt_item/added/AdminReceiptItemAddedEvent.java similarity index 58% rename from src/org/mxchange/jfinancials/events/receipt_item/added/ReceiptItemAddedEvent.java rename to src/org/mxchange/jfinancials/events/receipt_item/added/AdminReceiptItemAddedEvent.java index 04ce960..fc8dbc9 100644 --- a/src/org/mxchange/jfinancials/events/receipt_item/added/ReceiptItemAddedEvent.java +++ b/src/org/mxchange/jfinancials/events/receipt_item/added/AdminReceiptItemAddedEvent.java @@ -20,11 +20,12 @@ import java.text.MessageFormat; import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem; /** - * An event being fired when a new receipt item has been added + * An event being fired when a new receipt item has been added by an + * administrator. *

* @author Roland Haeder */ -public class ReceiptItemAddedEvent implements ObservableReceiptItemAddedEvent { +public class AdminReceiptItemAddedEvent implements ObservableAdminReceiptItemAddedEvent { /** * Serial number @@ -34,33 +35,33 @@ public class ReceiptItemAddedEvent implements ObservableReceiptItemAddedEvent { /** * New receipt item instance being added */ - private final BillableReceiptItem receiptItem; + private final BillableReceiptItem addedReceiptItem; /** * Constructor with receipt instance *

- * @param receiptItem Receipt instance + * @param addedReceiptItem Receipt instance */ - public ReceiptItemAddedEvent (final BillableReceiptItem receiptItem) { + public AdminReceiptItemAddedEvent (final BillableReceiptItem addedReceiptItem) { // Validate parameter - if (null == receiptItem) { + if (null == addedReceiptItem) { // Throw NPE - throw new NullPointerException("receiptItem is null"); - } else if (receiptItem.getItemId() == null) { + throw new NullPointerException("addedReceiptItem is null"); + } else if (addedReceiptItem.getItemId() == null) { // Throw NPE again - throw new NullPointerException("receiptItem.itemId is null"); - } else if (receiptItem.getItemId() < 1) { + throw new NullPointerException("addedReceiptItem.itemId is null"); + } else if (addedReceiptItem.getItemId() < 1) { // Throw NPE again - throw new NullPointerException(MessageFormat.format("receiptItem.itemId={0} is not valid", receiptItem.getItemId())); + throw new NullPointerException(MessageFormat.format("addedReceiptItem.itemId={0} is not valid", addedReceiptItem.getItemId())); } // Set it here - this.receiptItem = receiptItem; + this.addedReceiptItem = addedReceiptItem; } @Override - public BillableReceiptItem getReceiptItem () { - return this.receiptItem; + public BillableReceiptItem getAddedReceiptItem () { + return this.addedReceiptItem; } } diff --git a/src/org/mxchange/jfinancials/events/receipt_item/added/ObservableReceiptItemAddedEvent.java b/src/org/mxchange/jfinancials/events/receipt_item/added/ObservableAdminReceiptItemAddedEvent.java similarity index 84% rename from src/org/mxchange/jfinancials/events/receipt_item/added/ObservableReceiptItemAddedEvent.java rename to src/org/mxchange/jfinancials/events/receipt_item/added/ObservableAdminReceiptItemAddedEvent.java index 0379ff7..893af3d 100644 --- a/src/org/mxchange/jfinancials/events/receipt_item/added/ObservableReceiptItemAddedEvent.java +++ b/src/org/mxchange/jfinancials/events/receipt_item/added/ObservableAdminReceiptItemAddedEvent.java @@ -21,17 +21,17 @@ import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem; /** * An interface for events being fired when a receipt item instance has been - * added. + * added by an administrator. *

* @author Roland Häder */ -public interface ObservableReceiptItemAddedEvent extends Serializable { +public interface ObservableAdminReceiptItemAddedEvent extends Serializable { /** - * Getter for receipt item instance + * Getter for added receipt item instance *

* @return Receipt item instance */ - BillableReceiptItem getReceiptItem (); + BillableReceiptItem getAddedReceiptItem (); } diff --git a/src/org/mxchange/jfinancials/events/receipt_item/updated/AdminReceiptItemUpdatedEvent.java b/src/org/mxchange/jfinancials/events/receipt_item/updated/AdminReceiptItemUpdatedEvent.java new file mode 100644 index 0000000..c35879a --- /dev/null +++ b/src/org/mxchange/jfinancials/events/receipt_item/updated/AdminReceiptItemUpdatedEvent.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2017 - 2020 Free Software Foundation + * + * 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.jfinancials.events.receipt_item.updated; + +import java.text.MessageFormat; +import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem; + +/** + * An event being fired when a new receipt item has been added by an + * administrator. + *

+ * @author Roland Haeder + */ +public class AdminReceiptItemUpdatedEvent implements ObservableAdminReceiptItemUpdatedEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 157_582_667_163_548L; + + /** + * New receipt item instance being updated + */ + private final BillableReceiptItem updatedReceiptItem; + + /** + * Constructor with receipt instance + *

+ * @param updatedReceiptItem Receipt instance + */ + public AdminReceiptItemUpdatedEvent (final BillableReceiptItem updatedReceiptItem) { + // Validate parameter + if (null == updatedReceiptItem) { + // Throw NPE + throw new NullPointerException("updatedReceiptItem is null"); + } else if (updatedReceiptItem.getItemId() == null) { + // Throw NPE again + throw new NullPointerException("updatedReceiptItem.itemId is null"); + } else if (updatedReceiptItem.getItemId() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("updatedReceiptItem.itemId={0} is not valid", updatedReceiptItem.getItemId())); + } + + // Set it here + this.updatedReceiptItem = updatedReceiptItem; + } + + @Override + public BillableReceiptItem getUpdatedReceiptItem () { + return this.updatedReceiptItem; + } + +} diff --git a/src/org/mxchange/jfinancials/events/receipt_item/updated/ObservableAdminReceiptItemUpdatedEvent.java b/src/org/mxchange/jfinancials/events/receipt_item/updated/ObservableAdminReceiptItemUpdatedEvent.java new file mode 100644 index 0000000..af7e20f --- /dev/null +++ b/src/org/mxchange/jfinancials/events/receipt_item/updated/ObservableAdminReceiptItemUpdatedEvent.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2017 - 2020 Free Software Foundation + * + * 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.jfinancials.events.receipt_item.updated; + +import java.io.Serializable; +import org.mxchange.jfinancials.model.receipt_item.BillableReceiptItem; + +/** + * An interface for events being fired when a receipt item instance has been + * updated by an administrator. + *

+ * @author Roland Häder + */ +public interface ObservableAdminReceiptItemUpdatedEvent extends Serializable { + + /** + * Getter for updated receipt item instance + *

+ * @return Receipt item instance + */ + BillableReceiptItem getUpdatedReceiptItem (); + +} -- 2.39.5