]> git.mxchange.org Git - jcountry-core.git/commitdiff
The method equals() is for object-equality, not if a country with given country code...
authorRoland Haeder <roland@mxchange.org>
Mon, 11 Apr 2016 14:31:40 +0000 (16:31 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 11 Apr 2016 14:31:40 +0000 (16:31 +0200)
src/org/mxchange/jcountry/data/CountryData.java

index 92020b982c07a8ca5dafa6862ae8fe3141a5f8f7..28bdaa6b73a99f00984aa7820179181503a17b69 100644 (file)
@@ -112,21 +112,33 @@ public class CountryData implements Country {
 
        @Override
        public boolean equals (final Object object) {
-               if (null == object) {
+               if (this == object) {
+                       return true;
+               } else if (null == object) {
                        return false;
                } else if (this.getClass() != object.getClass()) {
                        return false;
                }
 
-               final CountryData other = (CountryData) object;
+               final Country other = (Country) object;
 
-               return Objects.equals(this.getCountryCode(), other.getCountryCode());
+               if (!Objects.equals(this.getCountryCode(), other.getCountryCode())) {
+                       return false;
+               } else if (!Objects.equals(this.getCountryI18nkey(), other.getCountryI18nkey())) {
+                       return false;
+               } else if (!Objects.equals(this.getCountryId(), other.getCountryId())) {
+                       return false;
+               }
+
+               return true;
        }
 
        @Override
        public int hashCode () {
-               int hash = 5;
-               hash = 37 * hash + Objects.hashCode(this.getCountryCode());
+               int hash = 7;
+               hash = 41 * hash + Objects.hashCode(this.getCountryCode());
+               hash = 41 * hash + Objects.hashCode(this.getCountryI18nkey());
+               hash = 41 * hash + Objects.hashCode(this.getCountryId());
                return hash;
        }