From: Roland Häder Date: Wed, 1 Nov 2017 21:05:05 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bdd5b5121ba1210b569b85595e27dd2154051072;p=jcontacts-business-core.git Continued: - added event being thrown when a new headquarters has been added Signed-off-by: Roland Häder --- 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 (); + +}