# HG changeset patch # User Da Risk # Date 1274916449 -7200 # Node ID de343f195f37b192770058326ae9733c4d99492d # Parent 151841f2b1a165f8686128056dc54ed3a517e6b0 Add an equals method to Contact. A contact is equals to an other if they got the same bare Jid. diff -r 151841f2b1a1 -r de343f195f37 src/com/beem/project/beem/service/Contact.java --- a/src/com/beem/project/beem/service/Contact.java Mon May 24 20:45:31 2010 +0200 +++ b/src/com/beem/project/beem/service/Contact.java Thu May 27 01:27:29 2010 +0200 @@ -79,20 +79,14 @@ private int mID; private int mStatus; - private String mJID; + private final String mJID; private String mSelectedRes; private String mMsgState; private List mRes; - private List mGroups; + private final List mGroups = new ArrayList(); private String mName; /** - * Constructor. - */ - public Contact() { - } - - /** * Construct a contact from a parcel. * @param in parcel to use for construction */ @@ -104,7 +98,6 @@ mName = in.readString(); mMsgState = in.readString(); mRes = new ArrayList(); - mGroups = new ArrayList(); in.readStringList(mRes); in.readStringList(mGroups); } @@ -123,7 +116,6 @@ mSelectedRes = res; if (!"".equals(res)) mRes.add(res); - mGroups = new ArrayList(); } /** @@ -143,7 +135,6 @@ String res = StringUtils.parseResource(enduri); mSelectedRes = res; mRes.add(res); - mGroups = new ArrayList(); } /** @@ -283,7 +274,8 @@ * @param groups the mGroups to set */ public void setGroups(List groups) { - this.mGroups = groups; + mGroups.clear(); + mGroups.addAll(groups); } /** @@ -295,14 +287,6 @@ } /** - * Set the Jabber ID of the contact. - * @param jid the jabber ID to set - */ - public void setJID(String jid) { - mJID = jid; - } - - /** * Set the resource of the contact. * @param resource to set. */ @@ -365,7 +349,6 @@ public void setStatus(PresenceAdapter presence) { mStatus = presence.getStatus(); mMsgState = presence.getStatusText(); - } /** @@ -423,4 +406,14 @@ build.append('/').append(mSelectedRes); return build.toString(); } + + @Override + public boolean equals(Object other) { + if (!(other instanceof Contact) ) + return false; + if (other == this) + return true; + Contact c = (Contact) other; + return c.getJID().equals(getJID()); + } }