From d97c0cb309aebb12f6940f85eee33d27f25ac6bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 8 Oct 2017 01:18:32 +0200 Subject: [PATCH] Continued: - added event for employees being added MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../employee/added/EmployeeAddedEvent.java | 67 +++++++++++++++++++ .../added/ObservableEmployeeAddedEvent.java | 36 ++++++++++ 2 files changed, 103 insertions(+) create mode 100644 src/org/mxchange/jcontactsbusiness/events/employee/added/EmployeeAddedEvent.java create mode 100644 src/org/mxchange/jcontactsbusiness/events/employee/added/ObservableEmployeeAddedEvent.java diff --git a/src/org/mxchange/jcontactsbusiness/events/employee/added/EmployeeAddedEvent.java b/src/org/mxchange/jcontactsbusiness/events/employee/added/EmployeeAddedEvent.java new file mode 100644 index 0000000..483ee51 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/events/employee/added/EmployeeAddedEvent.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.employee.added; + +import java.text.MessageFormat; +import org.mxchange.jcontactsbusiness.model.employee.Employee; + +/** + * An event being fired when a employee has been added + *

+ * @author Roland Häder + */ +public class EmployeeAddedEvent implements ObservableEmployeeAddedEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 572_367_561_659_112L; + + /** + * Branch office instance being added + */ + private final Employee employee; + + /** + * Constructor with employee instance + *

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

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

+ * @return Employee instance + */ + Employee getEmployee (); + +} -- 2.39.5