From: Roland Häder Date: Tue, 10 Jul 2018 22:38:17 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ac52ecf4254d115cbca4c8d3d0283ce4cb1beb2e;p=jcountry-core.git Continued: - documented all thrown exceptions - avoid invoking copyCountry() when both instances are the same Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jcountry/model/data/Countries.java b/src/org/mxchange/jcountry/model/data/Countries.java index faf2ccf..a6788a4 100644 --- a/src/org/mxchange/jcountry/model/data/Countries.java +++ b/src/org/mxchange/jcountry/model/data/Countries.java @@ -36,6 +36,9 @@ public class Countries implements Serializable { *

* @param sourceCountry Source Country instance to copy data from * @param targetCountry Target Country instance to copy data to + *

+ * @throws NullPointerException If sourceCountry or targetCountry is null + * @throws IllegalArgumentException If both Country instances are equal */ public static void copyCountry (final Country sourceCountry, final Country targetCountry) { // Parameters should not be null @@ -46,7 +49,11 @@ public class Countries implements Serializable { // Throw NPE throw new NullPointerException("targetCountry is null"); //NOI18N } else if (Objects.equals(sourceCountry, targetCountry)) { - // Should never be equal + /* + * Source and target country should never be equal, please check the + * condition before invoking this method. + */ + throw new IllegalArgumentException("Both sourceCountry and targetCountry are equal."); } // Copy all fields