From 9ee24a8a002abe805b8e257fd61cd9c5280d4078 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Thu, 18 Aug 2016 16:18:23 +0200
Subject: [PATCH] added new exception when a fax, land-line or mobile number is
 already set in target instance (e.g. contact, employee)

---
 .../PhoneNumberAlreadyLinkedException.java    | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 src/org/mxchange/jphone/exceptions/PhoneNumberAlreadyLinkedException.java

diff --git a/src/org/mxchange/jphone/exceptions/PhoneNumberAlreadyLinkedException.java b/src/org/mxchange/jphone/exceptions/PhoneNumberAlreadyLinkedException.java
new file mode 100644
index 0000000..4c4676c
--- /dev/null
+++ b/src/org/mxchange/jphone/exceptions/PhoneNumberAlreadyLinkedException.java
@@ -0,0 +1,67 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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 fax, land-line or mobile number is not linked but
+ * should be.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class PhoneNumberAlreadyLinkedException extends Exception {
+
+	/**
+	 * Serial number
+	 */
+	private static final long serialVersionUID = 18_964_581_681_985_598L;
+
+	/**
+	 * Counstructor with fax number
+	 * <p>
+	 * @param faxNumber Fax number
+	 */
+	public PhoneNumberAlreadyLinkedException (final DialableFaxNumber faxNumber) {
+		// Call super constructor with message
+		super(MessageFormat.format("faxNumber={0} with phoneId={1} cannot be linked, link target has already fax number linked.", faxNumber, faxNumber.getPhoneId())); //NOI18N
+	}
+
+	/**
+		* Counstructor with landLine number
+	 * <p>
+	 * @param landLineNumber Land-line number
+	 */
+	public PhoneNumberAlreadyLinkedException (final DialableLandLineNumber landLineNumber) {
+		// Call super constructor with message
+		super(MessageFormat.format("landLineNumber={0} with phoneId={1} cannot be linked, link target has already land-line number linked.", landLineNumber, landLineNumber.getPhoneId())); //NOI18N
+	}
+
+	/**
+	 * Counstructor with mobile number
+	 * <p>
+	 * @param mobileNumber Mobile number
+	 */
+	public PhoneNumberAlreadyLinkedException (final DialableMobileNumber mobileNumber) {
+		// Call super constructor with message
+		super(MessageFormat.format("mobileNumber={0} with phoneId={1} cannot be linked, link target has already mobile number linked.", mobileNumber, mobileNumber.getPhoneId())); //NOI18N
+	}
+
+}
-- 
2.39.5