]> git.mxchange.org Git - jcountry-core.git/commitdiff
Added checked exception if a country is already added with code or i18n key
authorRoland Haeder <roland@mxchange.org>
Mon, 11 Apr 2016 14:25:31 +0000 (16:25 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 11 Apr 2016 14:25:31 +0000 (16:25 +0200)
src/org/mxchange/jcountry/exceptions/CountryAlreadyAddedException.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jcountry/exceptions/CountryAlreadyAddedException.java b/src/org/mxchange/jcountry/exceptions/CountryAlreadyAddedException.java
new file mode 100644 (file)
index 0000000..1cb74d7
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcountry.exceptions;
+
+import java.text.MessageFormat;
+import org.mxchange.jcountry.data.Country;
+
+/**
+ * An exception thrown when a country is already registered. This can be easily
+ * checked if the country code is already there.
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class CountryAlreadyAddedException extends Exception {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 186_971_766_917_042L;
+
+       /**
+        * Constructor with newly country (no id number)
+        * <p>
+        * @param country Country instance
+        */
+       public CountryAlreadyAddedException (final Country country) {
+               // Call super constructor
+               super(MessageFormat.format("Country with code {0} or i18n key {1} has already been added.", country.getCountryCode(), country.getCountryI18nkey()));
+       }
+
+}