]> git.mxchange.org Git - jfinancials-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 20 Sep 2017 20:15:55 +0000 (22:15 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 20 Sep 2017 20:15:55 +0000 (22:15 +0200)
- added event which is being fired when a new receipt has been added

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jfinancials/events/receipt/added/ObservableReceiptAddedEvent.java [new file with mode: 0644]
src/org/mxchange/jfinancials/events/receipt/added/ReceiptAddedEvent.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jfinancials/events/receipt/added/ObservableReceiptAddedEvent.java b/src/org/mxchange/jfinancials/events/receipt/added/ObservableReceiptAddedEvent.java
new file mode 100644 (file)
index 0000000..18a6e78
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.added;
+
+import java.io.Serializable;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+
+/**
+ * An interface for events being fired when a receipt instance has been added.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableReceiptAddedEvent extends Serializable {
+
+       /**
+        * Getter for receipt instance
+        * <p>
+        * @return Receipt instance
+        */
+       BillableReceipt getReceipt ();
+
+}
diff --git a/src/org/mxchange/jfinancials/events/receipt/added/ReceiptAddedEvent.java b/src/org/mxchange/jfinancials/events/receipt/added/ReceiptAddedEvent.java
new file mode 100644 (file)
index 0000000..5696c04
--- /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.added;
+
+import java.text.MessageFormat;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+
+/**
+ * An event being fired when a new receipt has been added
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class ReceiptAddedEvent implements ObservableReceiptAddedEvent {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 157_582_667_163_547L;
+
+       /**
+        * New receipt instance being added
+        */
+       private final BillableReceipt receipt;
+
+       /**
+        * Constructor with receipt instance
+        * <p>
+        * @param receipt Receipt instance
+        */
+       public ReceiptAddedEvent (final BillableReceipt receipt) {
+               // Validate parameter
+               if (null == receipt) {
+                       // Throw NPE
+                       throw new NullPointerException("receipt is null");
+               } else if (receipt.getReceiptId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("receipt.receiptId is null");
+               } else if (receipt.getReceiptId() < 1) {
+                       // Throw NPE again
+                       throw new NullPointerException(MessageFormat.format("receipt.receiptId={0} is not valid", receipt.getReceiptId()));
+               }
+
+               // Set it here
+               this.receipt = receipt;
+       }
+
+       @Override
+       public BillableReceipt getReceipt () {
+               return this.receipt;
+       }
+
+}