]> git.mxchange.org Git - jcountry-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 10 Jul 2018 22:38:17 +0000 (00:38 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 10 Jul 2018 22:38:17 +0000 (00:38 +0200)
- documented all thrown exceptions
- avoid invoking copyCountry() when both instances are the same

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jcountry/model/data/Countries.java

index faf2ccfbe4d38d102052a90d8a421f1d3e1f28b3..a6788a4c82cbbcc662698fe7ee8f2de59cc5b897 100644 (file)
@@ -36,6 +36,9 @@ public class Countries implements Serializable {
         * <p>
         * @param sourceCountry Source Country instance to copy data from
         * @param targetCountry Target Country instance to copy data to
+        * <p>
+        * @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