From: Roland Häder Date: Sat, 7 Oct 2017 23:18:32 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d97c0cb309aebb12f6940f85eee33d27f25ac6bb;p=jcontacts-business-core.git Continued: - added event for employees being added Signed-off-by: Roland Häder --- 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 (); + +}