From 13bf42176ea436e22b475ae1b3039b853afa1249 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 18 Aug 2016 16:12:15 +0200 Subject: [PATCH] Got rid of redundant excepts, better make it generic and put all constructors in it, far enough --- .../FaxNumberNotLinkedException.java | 44 ------------------- .../LandLineNumberNotLinkedException.java | 44 ------------------- ...ava => PhoneNumberNotLinkedException.java} | 31 +++++++++++-- 3 files changed, 27 insertions(+), 92 deletions(-) delete mode 100644 src/org/mxchange/jphone/exceptions/FaxNumberNotLinkedException.java delete mode 100644 src/org/mxchange/jphone/exceptions/LandLineNumberNotLinkedException.java rename src/org/mxchange/jphone/exceptions/{MobileNumberNotLinkedException.java => PhoneNumberNotLinkedException.java} (53%) diff --git a/src/org/mxchange/jphone/exceptions/FaxNumberNotLinkedException.java b/src/org/mxchange/jphone/exceptions/FaxNumberNotLinkedException.java deleted file mode 100644 index 971f8c8..0000000 --- a/src/org/mxchange/jphone/exceptions/FaxNumberNotLinkedException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * 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; - -import java.text.MessageFormat; -import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; - -/** - * An exception thrown when a fax number is not linked but should be. - *

- * @author Roland Haeder - */ -public class FaxNumberNotLinkedException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 18_964_581_681_985_599L; - - /** - * Counstructor with fax number - *

- * @param faxNumber Fax number - */ - public FaxNumberNotLinkedException (final DialableFaxNumber faxNumber) { - // Call super constructor with message - super(MessageFormat.format("faxNumber={0} with phoneId={1} is not linked.", faxNumber, faxNumber.getPhoneId())); //NOI18N - } - -} diff --git a/src/org/mxchange/jphone/exceptions/LandLineNumberNotLinkedException.java b/src/org/mxchange/jphone/exceptions/LandLineNumberNotLinkedException.java deleted file mode 100644 index 3fc798b..0000000 --- a/src/org/mxchange/jphone/exceptions/LandLineNumberNotLinkedException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016 Roland Haeder - * - * 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; - -import java.text.MessageFormat; -import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; - -/** - * An exception thrown when a land-line number is not linked but should be. - *

- * @author Roland Haeder - */ -public class LandLineNumberNotLinkedException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 18_964_581_681_985_598L; - - /** - * Counstructor with land-line number - *

- * @param landLineNumber Cell phone number - */ - public LandLineNumberNotLinkedException (final DialableLandLineNumber landLineNumber) { - // Call super constructor with message - super(MessageFormat.format("landLineNumber={0} with phoneId={1} is not linked.", landLineNumber, landLineNumber.getPhoneId())); //NOI18N - } - -} diff --git a/src/org/mxchange/jphone/exceptions/MobileNumberNotLinkedException.java b/src/org/mxchange/jphone/exceptions/PhoneNumberNotLinkedException.java similarity index 53% rename from src/org/mxchange/jphone/exceptions/MobileNumberNotLinkedException.java rename to src/org/mxchange/jphone/exceptions/PhoneNumberNotLinkedException.java index fefe450..22a352e 100644 --- a/src/org/mxchange/jphone/exceptions/MobileNumberNotLinkedException.java +++ b/src/org/mxchange/jphone/exceptions/PhoneNumberNotLinkedException.java @@ -17,26 +17,49 @@ package org.mxchange.jphone.exceptions; import java.text.MessageFormat; +import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber; +import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber; import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber; /** - * An exception thrown when a mobile number is not linked but should be. + * An exception thrown when a fax, land-line or mobile number is not linked but + * should be. *

* @author Roland Haeder */ -public class MobileNumberNotLinkedException extends Exception { +public class PhoneNumberNotLinkedException extends Exception { /** * Serial number */ - private static final long serialVersionUID = 18_964_581_681_985_597L; + private static final long serialVersionUID = 18_964_581_681_985_599L; + + /** + * Counstructor with fax number + *

+ * @param faxNumber Fax number + */ + public PhoneNumberNotLinkedException (final DialableFaxNumber faxNumber) { + // Call super constructor with message + super(MessageFormat.format("faxNumber={0} with phoneId={1} is not linked.", faxNumber, faxNumber.getPhoneId())); //NOI18N + } + + /** + * Counstructor with landLine number + *

+ * @param landLineNumber Land-line number + */ + public PhoneNumberNotLinkedException (final DialableLandLineNumber landLineNumber) { + // Call super constructor with message + super(MessageFormat.format("landLineNumber={0} with phoneId={1} is not linked.", landLineNumber, landLineNumber.getPhoneId())); //NOI18N + } /** * Counstructor with mobile number *

* @param mobileNumber Mobile number */ - public MobileNumberNotLinkedException (final DialableMobileNumber mobileNumber) { + public PhoneNumberNotLinkedException (final DialableMobileNumber mobileNumber) { // Call super constructor with message super(MessageFormat.format("mobileNumber={0} with phoneId={1} is not linked.", mobileNumber, mobileNumber.getPhoneId())); //NOI18N } -- 2.39.5