From 624f57b84f94e6620e3a5d5ec9f5bfd3ecb9f641 Mon Sep 17 00:00:00 2001
From: Roland Haeder <roland@mxchange.org>
Date: Mon, 11 Apr 2016 16:31:40 +0200
Subject: [PATCH] The method equals() is for object-equality, not if a country
 with given country code or i18n key is already there. So with entities also
 the id number must be included.

---
 .../mxchange/jcountry/data/CountryData.java   | 22 ++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/org/mxchange/jcountry/data/CountryData.java b/src/org/mxchange/jcountry/data/CountryData.java
index 92020b9..28bdaa6 100644
--- a/src/org/mxchange/jcountry/data/CountryData.java
+++ b/src/org/mxchange/jcountry/data/CountryData.java
@@ -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;
 	}
 
-- 
2.39.5