From: Roland Häder Date: Sun, 24 Sep 2017 20:58:15 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=20b2a6b376a42bd4438f7323ef40c35fb0646294;p=jcontacts-business-core.git Continued: - added checked exceptions for already/not found company departments Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeAlreadyAddedException.java b/src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeAlreadyAddedException.java index fcbd471..0ca35e8 100644 --- a/src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeAlreadyAddedException.java +++ b/src/org/mxchange/jcontactsbusiness/exceptions/branchoffice/BranchOfficeAlreadyAddedException.java @@ -29,7 +29,7 @@ public class BranchOfficeAlreadyAddedException extends Exception { /** * Serial number */ - private static final long serialVersionUID = 75_844_851_467L; + private static final long serialVersionUID = 129_075_844_851_467L; /** * Constructor with a branch office instance diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/department/CompanyDepartmentAlreadyAddedException.java b/src/org/mxchange/jcontactsbusiness/exceptions/department/CompanyDepartmentAlreadyAddedException.java new file mode 100644 index 0000000..4ac6bd9 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/exceptions/department/CompanyDepartmentAlreadyAddedException.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2016, 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.exceptions.department; + +import java.text.MessageFormat; +import org.mxchange.jcontactsbusiness.model.department.Department; + +/** + * Thrown if the given BusinessBasicData instance is already added + *

+ * @author Roland Häder + */ +public class CompanyDepartmentAlreadyAddedException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 129_075_844_851_468L; + + /** + * Constructor with a company department instance + *

+ * @param department Company department that is already found + */ + public CompanyDepartmentAlreadyAddedException (final Department department) { + super(MessageFormat.format("Company department with name {0} already created.", department.getDepartmentName())); + } + + /** + * Default constructor, may be used if no contact instance is available + */ + public CompanyDepartmentAlreadyAddedException () { + super("Company department already added"); //NOI18N + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/department/CompanyDepartmentNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/department/CompanyDepartmentNotFoundException.java new file mode 100644 index 0000000..68e568e --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/exceptions/department/CompanyDepartmentNotFoundException.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2016, 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.exceptions.department; + +import java.text.MessageFormat; + +/** + * An exception thrown when a company department (entity) has not found. + *

+ * @author Roland Häder + */ +public class CompanyDepartmentNotFoundException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 23_759_801_876_416_573L; + + /** + * Constructor with company department id + *

+ * @param departmentId Company department id + */ + public CompanyDepartmentNotFoundException (final Long departmentId) { + // Call super constructor with message and cause + super(MessageFormat.format("Company department with id {0} was not found.", departmentId)); //NOI18N + } + + /** + * Constructor with company department id and causing exception + *

+ * @param departmentId Company department id + * @param cause Causing exception + */ + public CompanyDepartmentNotFoundException (final Long departmentId, final Throwable cause) { + // Call super constructor with message and cause + super(MessageFormat.format("Company department with id {0} was not found.", departmentId), cause); //NOI18N + } + +}