From: Roland Haeder Date: Tue, 13 Oct 2015 12:31:15 +0000 (+0200) Subject: Added equals() hashCode() for easy comparison + updated jar(s) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cb3d405ce32698cd8c22068238d4ade58ebb945d;p=jphone-core.git Added equals() hashCode() for easy comparison + updated jar(s) Signed-off-by:Roland Häder --- diff --git a/lib/jcountry-core.jar b/lib/jcountry-core.jar index 049ef5f..7166776 100644 Binary files a/lib/jcountry-core.jar and b/lib/jcountry-core.jar differ diff --git a/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java b/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java index af396ba..0e536ec 100644 --- a/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java +++ b/src/org/mxchange/jphone/phonenumbers/cellphone/CellphoneNumber.java @@ -16,6 +16,7 @@ */ package org.mxchange.jphone.phonenumbers.cellphone; +import java.util.Objects; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; @@ -83,6 +84,25 @@ public class CellphoneNumber implements DialableCellphoneNumber, Comparable * @author Roland Haeder */ public interface DialableLandLineNumber extends DialableNumber { + + @Override + public boolean equals (final Object object); + + @Override + public int hashCode (); } diff --git a/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java b/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java index 70285f7..aca8d08 100644 --- a/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java +++ b/src/org/mxchange/jphone/phonenumbers/landline/LandLineNumber.java @@ -16,6 +16,7 @@ */ package org.mxchange.jphone.phonenumbers.landline; +import java.util.Objects; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; @@ -69,7 +70,7 @@ public class LandLineNumber implements DialableLandLineNumber, Comparable { /** * Serial number @@ -74,9 +75,35 @@ public class CellphoneProvider implements SmsProvider { * Country instance ('s dial data) */ @JoinColumn (name = "provider_country_id", nullable = false) - @OneToOne(targetEntity = CountryData.class, optional = false, fetch = FetchType.EAGER) + @OneToOne (targetEntity = CountryData.class, optional = false, fetch = FetchType.EAGER) private Country providerCountry; + @Override + public int compareTo (final SmsProvider provider) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public boolean equals (final Object object) { + if (object == null) { + return false; + } else if (getClass() != object.getClass()) { + return false; + } + + final SmsProvider other = (SmsProvider) object; + + if (!Objects.equals(this.getProviderDialPrefix(), other.getProviderDialPrefix())) { + return false; + } else if (!Objects.equals(this.getProviderName(), other.getProviderName())) { + return false; + } else if (!Objects.equals(this.getProviderCountry(), other.getProviderCountry())) { + return false; + } + + return true; + } + @Override public Long getProviderId () { return providerId; @@ -117,4 +144,13 @@ public class CellphoneProvider implements SmsProvider { this.providerCountry = providerCountry; } + @Override + public int hashCode () { + int hash = 7; + hash = 19 * hash + Objects.hashCode(this.getProviderDialPrefix()); + hash = 19 * hash + Objects.hashCode(this.getProviderName()); + hash = 19 * hash + Objects.hashCode(this.getProviderCountry()); + return hash; + } + } diff --git a/src/org/mxchange/jphone/phonenumbers/smsprovider/SmsProvider.java b/src/org/mxchange/jphone/phonenumbers/smsprovider/SmsProvider.java index 65354f9..619a07c 100644 --- a/src/org/mxchange/jphone/phonenumbers/smsprovider/SmsProvider.java +++ b/src/org/mxchange/jphone/phonenumbers/smsprovider/SmsProvider.java @@ -81,4 +81,10 @@ public interface SmsProvider extends Serializable { * @param country Country instance */ public void setProviderCountry (final Country country); + + @Override + public boolean equals (final Object object); + + @Override + public int hashCode (); }