]> git.mxchange.org Git - jbonuscard-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 13 Oct 2017 21:29:17 +0000 (23:29 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 13 Oct 2017 21:32:52 +0000 (23:32 +0200)
- added event being fired when a receipt item has been added
- moved exception to own package
- added exception for being thrown when receipt item has already been added

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jfinancials/events/receipt_item/added/ObservableReceiptItemAddedEvent.java [new file with mode: 0644]
src/org/mxchange/jfinancials/events/receipt_item/added/ReceiptItemAddedEvent.java [new file with mode: 0644]
src/org/mxchange/jfinancials/exceptions/ReceiptAlreadyAddedException.java [deleted file]
src/org/mxchange/jfinancials/exceptions/receipt/ReceiptAlreadyAddedException.java [new file with mode: 0644]
src/org/mxchange/jfinancials/exceptions/receipt_item/ReceiptItemAlreadyAddedException.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jfinancials/events/receipt_item/added/ObservableReceiptItemAddedEvent.java b/src/org/mxchange/jfinancials/events/receipt_item/added/ObservableReceiptItemAddedEvent.java
new file mode 100644 (file)
index 0000000..4fb692b
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.events.receipt_item.added;
+
+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
+ * added.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableReceiptItemAddedEvent extends Serializable {
+
+       /**
+        * Getter for receipt item instance
+        * <p>
+        * @return Receipt item instance
+        */
+       BillableReceiptItem getReceiptItem ();
+
+}
diff --git a/src/org/mxchange/jfinancials/events/receipt_item/added/ReceiptItemAddedEvent.java b/src/org/mxchange/jfinancials/events/receipt_item/added/ReceiptItemAddedEvent.java
new file mode 100644 (file)
index 0000000..c844289
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2017 Roland Haeder<roland@mxchange.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.events.receipt_item.added;
+
+import java.text.MessageFormat;
+import org.mxchange.jfinancials.model.receipt.item.BillableReceiptItem;
+
+/**
+ * An event being fired when a new receipt item has been added
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class ReceiptItemAddedEvent implements ObservableReceiptItemAddedEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 157_582_667_163_548L;
+
+       /**
+        * New receipt item instance being added
+        */
+       private final BillableReceiptItem receiptItem;
+
+       /**
+        * Constructor with receipt instance
+        * <p>
+        * @param receiptItem Receipt instance
+        */
+       public ReceiptItemAddedEvent (final BillableReceiptItem receiptItem) {
+               // Validate parameter
+               if (null == receiptItem) {
+                       // Throw NPE
+                       throw new NullPointerException("receiptItem is null");
+               } else if (receiptItem.getItemId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("receiptItem.itemId is null");
+               } else if (receiptItem.getItemId() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("receiptItem.itemId={0} is not valid", receiptItem.getItemId()));
+               }
+
+               // Set it here
+               this.receiptItem = receiptItem;
+       }
+
+       @Override
+       public BillableReceiptItem getReceiptItem () {
+               return this.receiptItem;
+       }
+
+}
diff --git a/src/org/mxchange/jfinancials/exceptions/ReceiptAlreadyAddedException.java b/src/org/mxchange/jfinancials/exceptions/ReceiptAlreadyAddedException.java
deleted file mode 100644 (file)
index a2ccf07..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2017 Roland Häder
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jfinancials.exceptions;
-
-import java.text.MessageFormat;
-import org.mxchange.jfinancials.model.receipt.BillableReceipt;
-
-/**
- * This exception is thrown when a receipt was already added
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class ReceiptAlreadyAddedException extends Exception {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 19_065_867_127_647_624L;
-
-       /**
-        * Default constructor
-        */
-       public ReceiptAlreadyAddedException () {
-               super();
-       }
-
-       /**
-        * Constructor with receipt instance
-        * <p>
-        * @param receipt Receipt instance
-        */
-       public ReceiptAlreadyAddedException (final BillableReceipt receipt) {
-               // Call super constructor
-               super(MessageFormat.format("Receipt with id {0} and number {1} has already been added.", receipt.getReceiptId(), receipt.getReceiptNumber()));
-       }
-
-}
diff --git a/src/org/mxchange/jfinancials/exceptions/receipt/ReceiptAlreadyAddedException.java b/src/org/mxchange/jfinancials/exceptions/receipt/ReceiptAlreadyAddedException.java
new file mode 100644 (file)
index 0000000..ddc931c
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.exceptions.receipt;
+
+import java.text.MessageFormat;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+
+/**
+ * This exception is thrown when a receipt was already added
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class ReceiptAlreadyAddedException extends Exception {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 19_065_867_127_647_624L;
+
+       /**
+        * Default constructor
+        */
+       public ReceiptAlreadyAddedException () {
+               super();
+       }
+
+       /**
+        * Constructor with receipt instance
+        * <p>
+        * @param receipt Receipt instance
+        */
+       public ReceiptAlreadyAddedException (final BillableReceipt receipt) {
+               // Call super constructor
+               super(MessageFormat.format("Receipt with id {0} and number {1} has already been added.", receipt.getReceiptId(), receipt.getReceiptNumber()));
+       }
+
+}
diff --git a/src/org/mxchange/jfinancials/exceptions/receipt_item/ReceiptItemAlreadyAddedException.java b/src/org/mxchange/jfinancials/exceptions/receipt_item/ReceiptItemAlreadyAddedException.java
new file mode 100644 (file)
index 0000000..c622d30
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2017 Roland Häder
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.exceptions.receipt_item;
+
+import java.text.MessageFormat;
+import org.mxchange.jfinancials.model.receipt.item.BillableReceiptItem;
+
+/**
+ * This exception is thrown when a receipt item was already added
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class ReceiptItemAlreadyAddedException extends Exception {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 19_065_867_127_647_625L;
+
+       /**
+        * Default constructor
+        */
+       public ReceiptItemAlreadyAddedException () {
+               super();
+       }
+
+       /**
+        * Constructor with receipt item instance
+        * <p>
+        * @param receiptItem Receipt item instance
+        */
+       public ReceiptItemAlreadyAddedException (final BillableReceiptItem receiptItem) {
+               // Call super constructor
+               super(MessageFormat.format("Receipt item with id {0} has already been added.", receiptItem.getItemId()));
+       }
+
+}