]> git.mxchange.org Git - jcountry-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 15 Mar 2018 23:44:40 +0000 (00:44 +0100)
committerRoland Häder <roland@mxchange.org>
Thu, 15 Mar 2018 23:44:40 +0000 (00:44 +0100)
- added dependency jcoreee.jar
- implemented compareTo() method, was a stub

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

index 9b9c3f6fa2004e797a423b487834c97f92a6cf86..3a15f7850ec3d056f3d9051cb5d4ddfe27d067bb 100644 (file)
@@ -30,10 +30,12 @@ dist.jar=${dist.dir}/jcountry-core.jar
 dist.javadoc.dir=${dist.dir}/javadoc
 endorsed.classpath=
 excludes=
+file.reference.jcoreee.jar=lib/jcoreee.jar
 includes=**
 jar.compress=false
 javac.classpath=\
-    ${libs.jpa20-persistence.classpath}
+    ${libs.jpa20-persistence.classpath}:\
+    ${file.reference.jcoreee.jar}
 # Space-separated list of extra javac options
 javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
 javac.deprecation=true
@@ -73,5 +75,6 @@ run.test.classpath=\
     ${javac.test.classpath}:\
     ${build.test.classes.dir}
 source.encoding=UTF-8
+source.reference.jcoreee.jar=../jcoreee/src/
 src.dir=src
 test.src.dir=test
index 8fd5d8e230969003a25b6661f32541e2f95e5aa5..15fdc95a6d7ca12388eb14fe979cef37ec84d82a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2018 Roland Häder<roland@mxchange.org>
+ * Copyright (C) 2018 Free Software Foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index f851abb2cdbd8dff6b2a25f9afe7b66a7d458c0a..75b7f82b283e6753768ead93da4f3c99677a6a20 100644 (file)
@@ -30,6 +30,7 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 import javax.persistence.Transient;
+import org.mxchange.jcoreee.utils.Comparables;
 
 /**
  * A POJO for country data
@@ -118,7 +119,30 @@ public class CountryData implements Country {
 
        @Override
        public int compareTo (final Country country) {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+               // For performance reasons
+               if (null == country) {
+                       // Should not happen
+                       throw new NullPointerException("country is null"); //NOI18N
+               } else if (Objects.equals(this, country)) {
+                       // Same object
+                       return 0;
+               }
+
+               // Init comparators
+               final int comparators[] = {
+                       // First check country code, clear indication ...
+                       this.getCountryCode().compareTo(country.getCountryCode()),
+                       // ... and phone code, too
+                       this.getCountryPhoneCode().compareTo(country.getCountryPhoneCode()),
+                       // ... then last i18n key
+                       this.getCountryI18nKey().compareTo(country.getCountryI18nKey())
+               };
+
+               // Check all values
+               final int comparison = Comparables.checkAll(comparators);
+
+               // Return value
+               return comparison;
        }
 
        @Override