From 9ac34bb3b05b43f131b9a5496827d5e068e2695b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 15 Oct 2017 22:39:34 +0200 Subject: [PATCH] Continued: - moved exceptions to own packages - added exception when a mobile provider was not found - added constructor with only phoneId MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../MobileProviderAlreadyAddedException.java | 2 +- .../MobileProviderNotFoundException.java | 43 +++++++++++++++++++ .../PhoneEntityNotFoundException.java | 14 +++++- .../PhoneNumberAlreadyLinkedException.java | 2 +- .../PhoneNumberNotLinkedException.java | 2 +- 5 files changed, 58 insertions(+), 5 deletions(-) rename src/org/mxchange/jphone/exceptions/{ => mobileprovider}/MobileProviderAlreadyAddedException.java (96%) create mode 100644 src/org/mxchange/jphone/exceptions/mobileprovider/MobileProviderNotFoundException.java rename src/org/mxchange/jphone/exceptions/{ => phone}/PhoneEntityNotFoundException.java (76%) rename src/org/mxchange/jphone/exceptions/{ => phone}/PhoneNumberAlreadyLinkedException.java (98%) rename src/org/mxchange/jphone/exceptions/{ => phone}/PhoneNumberNotLinkedException.java (98%) diff --git a/src/org/mxchange/jphone/exceptions/MobileProviderAlreadyAddedException.java b/src/org/mxchange/jphone/exceptions/mobileprovider/MobileProviderAlreadyAddedException.java similarity index 96% rename from src/org/mxchange/jphone/exceptions/MobileProviderAlreadyAddedException.java rename to src/org/mxchange/jphone/exceptions/mobileprovider/MobileProviderAlreadyAddedException.java index 18477fd..f8a78bb 100644 --- a/src/org/mxchange/jphone/exceptions/MobileProviderAlreadyAddedException.java +++ b/src/org/mxchange/jphone/exceptions/mobileprovider/MobileProviderAlreadyAddedException.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jphone.exceptions; +package org.mxchange.jphone.exceptions.mobileprovider; import java.text.MessageFormat; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; diff --git a/src/org/mxchange/jphone/exceptions/mobileprovider/MobileProviderNotFoundException.java b/src/org/mxchange/jphone/exceptions/mobileprovider/MobileProviderNotFoundException.java new file mode 100644 index 0000000..d08af97 --- /dev/null +++ b/src/org/mxchange/jphone/exceptions/mobileprovider/MobileProviderNotFoundException.java @@ -0,0 +1,43 @@ +/* + * 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.jphone.exceptions.mobileprovider; + +import java.text.MessageFormat; + +/** + * An exception thrown when the mobile provider was not found. + *

+ * @author Roland Häder + */ +public class MobileProviderNotFoundException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 16_857_128_756_894_187L; + + /** + * Constructor with primary key + *

+ * @param mobileProviderId Primary key + */ + public MobileProviderNotFoundException (final Long mobileProviderId) { + // Create message an call super constructor + super(MessageFormat.format("Mobile provider with id={0} was not found.", mobileProviderId)); //NOI18N + } + +} diff --git a/src/org/mxchange/jphone/exceptions/PhoneEntityNotFoundException.java b/src/org/mxchange/jphone/exceptions/phone/PhoneEntityNotFoundException.java similarity index 76% rename from src/org/mxchange/jphone/exceptions/PhoneEntityNotFoundException.java rename to src/org/mxchange/jphone/exceptions/phone/PhoneEntityNotFoundException.java index 6cd95bd..3ea07bd 100644 --- a/src/org/mxchange/jphone/exceptions/PhoneEntityNotFoundException.java +++ b/src/org/mxchange/jphone/exceptions/phone/PhoneEntityNotFoundException.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jphone.exceptions; +package org.mxchange.jphone.exceptions.phone; import java.text.MessageFormat; @@ -31,7 +31,7 @@ public class PhoneEntityNotFoundException extends Exception { private static final long serialVersionUID = 18_964_581_681_985_597L; /** - * Counstructor with id number and causing exception + * Constructor with id number and causing exception *

* @param phoneId Id number that has no corresponding entity * @param cause Causing exception @@ -41,4 +41,14 @@ public class PhoneEntityNotFoundException extends Exception { super(MessageFormat.format("Phone entity with id {0} not found.", phoneId), cause); //NOI18N } + /** + * Constructor with id number + *

+ * @param phoneId Id number that has no corresponding entity + */ + public PhoneEntityNotFoundException (final Long phoneId) { + // Construct message and call super constructor + super(MessageFormat.format("Phone entity with id {0} not found.", phoneId)); //NOI18N + } + } diff --git a/src/org/mxchange/jphone/exceptions/PhoneNumberAlreadyLinkedException.java b/src/org/mxchange/jphone/exceptions/phone/PhoneNumberAlreadyLinkedException.java similarity index 98% rename from src/org/mxchange/jphone/exceptions/PhoneNumberAlreadyLinkedException.java rename to src/org/mxchange/jphone/exceptions/phone/PhoneNumberAlreadyLinkedException.java index 2b2f278..56ebd4f 100644 --- a/src/org/mxchange/jphone/exceptions/PhoneNumberAlreadyLinkedException.java +++ b/src/org/mxchange/jphone/exceptions/phone/PhoneNumberAlreadyLinkedException.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jphone.exceptions; +package org.mxchange.jphone.exceptions.phone; import java.text.MessageFormat; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; diff --git a/src/org/mxchange/jphone/exceptions/PhoneNumberNotLinkedException.java b/src/org/mxchange/jphone/exceptions/phone/PhoneNumberNotLinkedException.java similarity index 98% rename from src/org/mxchange/jphone/exceptions/PhoneNumberNotLinkedException.java rename to src/org/mxchange/jphone/exceptions/phone/PhoneNumberNotLinkedException.java index 7d12f65..c138603 100644 --- a/src/org/mxchange/jphone/exceptions/PhoneNumberNotLinkedException.java +++ b/src/org/mxchange/jphone/exceptions/phone/PhoneNumberNotLinkedException.java @@ -14,7 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.jphone.exceptions; +package org.mxchange.jphone.exceptions.phone; import java.text.MessageFormat; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; -- 2.39.5