From ac52ecf4254d115cbca4c8d3d0283ce4cb1beb2e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 11 Jul 2018 00:38:17 +0200 Subject: [PATCH] Continued: - documented all thrown exceptions - avoid invoking copyCountry() when both instances are the same MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- src/org/mxchange/jcountry/model/data/Countries.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.39.5