james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r737049 - /james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java
Date Fri, 23 Jan 2009 15:23:27 GMT
Author: mwiederkehr
Date: Fri Jan 23 07:23:27 2009
New Revision: 737049

URL: http://svn.apache.org/viewvc?rev=737049&view=rev
Log:
MIME4J-107: added hashCode() and equals() for Mailbox

Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java?rev=737049&r1=737048&r2=737049&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java Fri
Jan 23 07:23:27 2009
@@ -21,6 +21,7 @@
 
 import java.util.Collections;
 import java.util.List;
+import java.util.Locale;
 
 /**
  * Represents a single e-mail address.
@@ -190,8 +191,29 @@
     }
 
     @Override
+    public int hashCode() {
+        return getCanonicalizedAddress().hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this)
+            return true;
+        if (!(obj instanceof Mailbox))
+            return false;
+
+        Mailbox other = (Mailbox) obj;
+        return getCanonicalizedAddress()
+                .equals(other.getCanonicalizedAddress());
+    }
+
+    @Override
     protected final void doAddMailboxesTo(List<Mailbox> results) {
         results.add(this);
     }
 
+    private Object getCanonicalizedAddress() {
+        return getAddress().toLowerCase(Locale.US);
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message