From: Roland Haeder Date: Mon, 11 Apr 2016 14:25:31 +0000 (+0200) Subject: Added checked exception if a country is already added with code or i18n key X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2b573c3b0a15ee476039ce078e40bc73a70a5143;p=jcountry-core.git Added checked exception if a country is already added with code or i18n key --- diff --git a/src/org/mxchange/jcountry/exceptions/CountryAlreadyAddedException.java b/src/org/mxchange/jcountry/exceptions/CountryAlreadyAddedException.java new file mode 100644 index 0000000..1cb74d7 --- /dev/null +++ b/src/org/mxchange/jcountry/exceptions/CountryAlreadyAddedException.java @@ -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 . + */ +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. + *

+ * @author Roland Haeder + */ +public class CountryAlreadyAddedException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 186_971_766_917_042L; + + /** + * Constructor with newly country (no id number) + *

+ * @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())); + } + +}