From: Roland Häder Date: Wed, 20 Sep 2017 20:15:55 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cfea5c35700bae96a73bb5c271a8779e6741c1fb;p=jbonuscard-core.git Continued: - added event which is being fired when a new receipt has been added Signed-off-by: Roland Häder --- 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 index 0000000..18a6e78 --- /dev/null +++ b/src/org/mxchange/jfinancials/events/receipt/added/ObservableReceiptAddedEvent.java @@ -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 . + */ +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. + *

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

+ * @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 index 0000000..5696c04 --- /dev/null +++ b/src/org/mxchange/jfinancials/events/receipt/added/ReceiptAddedEvent.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2017 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.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 + *

+ * @author Roland Haeder + */ +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 + *

+ * @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; + } + +}