diff options
author | Ingo Bauersachs <ingo@jitsi.org> | 2017-01-07 20:47:20 +0100 |
---|---|---|
committer | Ingo Bauersachs <ingo@jitsi.org> | 2017-01-07 20:47:20 +0100 |
commit | 589fd0b457db6d188de1a5961abb56586e136add (patch) | |
tree | f3e2cf81a280c23c392d0a1f8e88cd4436ca5cb0 /src | |
parent | cb3f6a35e91e23915663b54d579071a8d37e9394 (diff) | |
download | jitsi-589fd0b457db6d188de1a5961abb56586e136add.zip jitsi-589fd0b457db6d188de1a5961abb56586e136add.tar.gz jitsi-589fd0b457db6d188de1a5961abb56586e136add.tar.bz2 |
Add hashCode to classes overriding equals
Diffstat (limited to 'src')
11 files changed, 140 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/UINotification.java b/src/net/java/sip/communicator/impl/gui/main/UINotification.java index fbfb6da..4304907 100644 --- a/src/net/java/sip/communicator/impl/gui/main/UINotification.java +++ b/src/net/java/sip/communicator/impl/gui/main/UINotification.java @@ -17,6 +17,8 @@ */ package net.java.sip.communicator.impl.gui.main; +import java.util.Objects; + /** * The <tt>UINotification</tt> class represents a notification received in the * user interface. This could be a missed call, voicemail, email notification or @@ -172,4 +174,10 @@ public class UINotification return true; } + + @Override + public int hashCode() + { + return Objects.hash(notificationName, parentGroup); + } } diff --git a/src/net/java/sip/communicator/impl/ldap/LdapPersonFoundImpl.java b/src/net/java/sip/communicator/impl/ldap/LdapPersonFoundImpl.java index 3d8e6bf..36632fa 100644 --- a/src/net/java/sip/communicator/impl/ldap/LdapPersonFoundImpl.java +++ b/src/net/java/sip/communicator/impl/ldap/LdapPersonFoundImpl.java @@ -433,4 +433,10 @@ public class LdapPersonFoundImpl return this.toString().equals(o.toString()) && this.getDN().equals(((LdapPersonFound) o).getDN()); } + + @Override + public int hashCode() + { + return Objects.hash(toString(), getDN()); + } } diff --git a/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGroupGibberishImpl.java b/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGroupGibberishImpl.java index 2a95493..8528267 100644 --- a/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGroupGibberishImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGroupGibberishImpl.java @@ -577,4 +577,29 @@ public class ContactGroupGibberishImpl return true; } + + @Override + public int hashCode() + { + List<Object> objects = new ArrayList<Object>(); + objects.add(getGroupName()); + objects.add(getUID()); + objects.add(countContacts()); + objects.add(countSubgroups()); + + //traverse child contacts + for (Contact c : contacts) + { + objects.add(c.getAddress()); + } + + + //traverse subgroups + for (ContactGroup g : subGroups) + { + objects.add(g.getGroupName()); + } + + return Objects.hash(objects.toArray()); + } } diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/CryptoPacketExtension.java b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/CryptoPacketExtension.java index 69b2e47..3ccbd72 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/CryptoPacketExtension.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/CryptoPacketExtension.java @@ -17,6 +17,8 @@ */ package net.java.sip.communicator.impl.protocol.jabber.extensions.jingle; +import java.util.Objects; + import ch.imvs.sdes4j.srtp.*; import net.java.sip.communicator.impl.protocol.jabber.extensions.*; @@ -332,4 +334,14 @@ public class CryptoPacketExtension } return false; } + + @Override + public int hashCode() + { + return Objects.hash( + getCryptoSuite(), + getKeyParams(), + getSessionParams(), + getTag()); + } } diff --git a/src/net/java/sip/communicator/impl/protocol/mock/MockContactGroup.java b/src/net/java/sip/communicator/impl/protocol/mock/MockContactGroup.java index fa4fff1..e6cdd36 100644 --- a/src/net/java/sip/communicator/impl/protocol/mock/MockContactGroup.java +++ b/src/net/java/sip/communicator/impl/protocol/mock/MockContactGroup.java @@ -506,6 +506,31 @@ public class MockContactGroup return true; } + @Override + public int hashCode() + { + List<Object> objects = new ArrayList<Object>(); + objects.add(getGroupName()); + objects.add(getUID()); + objects.add(countContacts()); + objects.add(countSubgroups()); + + //traverse child contacts + for (Contact c : contacts) + { + objects.add(c.getAddress()); + } + + + //traverse subgroups + for (ContactGroup g : subGroups) + { + objects.add(g.getGroupName()); + } + + return Objects.hash(objects.toArray()); + } + public void setPersistent(boolean isPersistent) { this.isPersistent = isPersistent; diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ContactGroupSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ContactGroupSipImpl.java index f5782f1..3c2aeb5 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ContactGroupSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ContactGroupSipImpl.java @@ -641,5 +641,31 @@ public class ContactGroupSipImpl return true; } + + @Override + public int hashCode() + { + List<Object> objects = new ArrayList<Object>(); + objects.add(getGroupName()); + objects.add(getUID()); + objects.add(countContacts()); + objects.add(countSubgroups()); + objects.add(getProtocolProvider()); + + //traverse child contacts + for (Contact c : contacts) + { + objects.add(c.getAddress()); + } + + + //traverse subgroups + for (ContactGroup g : subGroups) + { + objects.add(g.getGroupName()); + } + + return Objects.hash(objects.toArray()); + } } diff --git a/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberSourceContact.java b/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberSourceContact.java index ef7352f..d7ec804 100644 --- a/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberSourceContact.java +++ b/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberSourceContact.java @@ -107,6 +107,18 @@ public class PhoneNumberSourceContact return true; } + @Override + public int hashCode() + { + String dn = getDisplayName(); + if (dn != null) + { + return getDisplayName().hashCode(); + } + + return 37; + } + /** * Returns the protocol contact used. * @return the protocol contact used. diff --git a/src/net/java/sip/communicator/service/gui/Container.java b/src/net/java/sip/communicator/service/gui/Container.java index 1b5e144..d0fcab7 100644 --- a/src/net/java/sip/communicator/service/gui/Container.java +++ b/src/net/java/sip/communicator/service/gui/Container.java @@ -257,4 +257,10 @@ public class Container else return false; } + + @Override + public int hashCode() + { + return containerName.hashCode(); + } } diff --git a/src/net/java/sip/communicator/service/protocol/RegistrationState.java b/src/net/java/sip/communicator/service/protocol/RegistrationState.java index 9bd3eb0..368e5b1 100644 --- a/src/net/java/sip/communicator/service/protocol/RegistrationState.java +++ b/src/net/java/sip/communicator/service/protocol/RegistrationState.java @@ -177,4 +177,10 @@ public class RegistrationState && obj != null && statusString.equals(((RegistrationState)obj).statusString); } + + @Override + public int hashCode() + { + return statusString.hashCode(); + } } diff --git a/src/net/java/sip/communicator/service/protocol/ServerStoredDetails.java b/src/net/java/sip/communicator/service/protocol/ServerStoredDetails.java index 23cb895..4d21864 100644 --- a/src/net/java/sip/communicator/service/protocol/ServerStoredDetails.java +++ b/src/net/java/sip/communicator/service/protocol/ServerStoredDetails.java @@ -156,6 +156,12 @@ public class ServerStoredDetails else return false; } + + @Override + public int hashCode() + { + return Objects.hash(detailDisplayName, value); + } } /** diff --git a/src/net/java/sip/communicator/service/protocol/WhiteboardPoint.java b/src/net/java/sip/communicator/service/protocol/WhiteboardPoint.java index 1774718..3e26e7a 100644 --- a/src/net/java/sip/communicator/service/protocol/WhiteboardPoint.java +++ b/src/net/java/sip/communicator/service/protocol/WhiteboardPoint.java @@ -17,6 +17,8 @@ */ package net.java.sip.communicator.service.protocol; +import java.util.Objects; + /** * A point representing a location in {@code (x,y)} coordinate space, * specified in integer precision. @@ -126,6 +128,12 @@ public class WhiteboardPoint implements Cloneable return false; } + @Override + public int hashCode() + { + return Objects.hash(x, y); + } + /** * Returns a string representation of this point and its location * in the {@code (x,y)} coordinate space. This method is intended to be |