From bdd5b5121ba1210b569b85595e27dd2154051072 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 1 Nov 2017 22:05:05 +0100 Subject: [PATCH] Continued: - added event being thrown when a new headquarters has been added MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../added/HeadquartersAddedEvent.java | 67 +++++++++++++++++++ .../ObservableHeadquartersAddedEvent.java | 36 ++++++++++ 2 files changed, 103 insertions(+) create mode 100644 src/org/mxchange/jcontactsbusiness/events/headquarters/added/HeadquartersAddedEvent.java create mode 100644 src/org/mxchange/jcontactsbusiness/events/headquarters/added/ObservableHeadquartersAddedEvent.java diff --git a/src/org/mxchange/jcontactsbusiness/events/headquarters/added/HeadquartersAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/headquarters/added/HeadquartersAddedEvent.java new file mode 100644 index 0000000..d03f1e1 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/events/headquarters/added/HeadquartersAddedEvent.java @@ -0,0 +1,67 @@ +/* + * 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.jcontactsbusiness.events.headquarters.added; + +import java.text.MessageFormat; +import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; + +/** + * An event being fired when a branch office has been added + *

+ * @author Roland Häder + */ +public class HeadquartersAddedEvent implements ObservableHeadquartersAddedEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 572_367_561_659_110L; + + /** + * Headquarters office instance being added + */ + private final Headquarter headquarters; + + /** + * Constructor with branch office instance + *

+ * @param headquarters Headquarters office instance + * @throws NullPointerException If the parameter is null + */ + public HeadquartersAddedEvent (final Headquarter headquarters) { + // Check parameter + if (null == headquarters) { + // Throw NPE + throw new NullPointerException("headquarters is null"); //NOI18N + } else if (headquarters.getHeadquartersId() == null) { + // Throw NPE again + throw new NullPointerException("headquarters.headquartersId is null"); //NOI18N + } else if (headquarters.getHeadquartersId() < 1) { + // Throw NPE again + throw new NullPointerException(MessageFormat.format("headquarters.headquartersId={0} is not valid", headquarters.getHeadquartersId())); //NOI18N + } + + // Set it + this.headquarters = headquarters; + } + + @Override + public Headquarter getHeadquarters () { + return this.headquarters; + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/events/headquarters/added/ObservableHeadquartersAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/headquarters/added/ObservableHeadquartersAddedEvent.java new file mode 100644 index 0000000..7cacdc3 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/events/headquarters/added/ObservableHeadquartersAddedEvent.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.jcontactsbusiness.events.headquarters.added; + +import java.io.Serializable; +import org.mxchange.jcontactsbusiness.model.headquarters.Headquarter; + +/** + * An interface for events being triggered when a headquarters has been added. + *

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

+ * @return Headquarters instance + */ + Headquarter getHeadquarters (); + +} -- 2.39.5