Example usage for javax.mail Address equals

List of usage examples for javax.mail Address equals

Introduction

In this page you can find the example usage for javax.mail Address equals.

Prototype

@Override
public abstract boolean equals(Object address);

Source Link

Document

The equality operator.

Usage

From source file:com.cubusmail.mail.util.MessageUtils.java

/**
 * @param addressArray/*from   w  w  w.  j  ava 2s .c  o m*/
 * @param emailAddress
 * @return
 */
public static boolean findEmailAddress(Address[] addressArray, Address addressToFind) {

    if (addressArray != null) {
        for (Address address : addressArray) {
            if (address.equals(addressToFind)) {
                return true;
            }
        }
    }
    return false;
}

From source file:org.awknet.commons.mail.Mail.java

/**
 * Delete duplicates recipients. It is not allowed a same e-mail in 2
 * recipients fields. In this case, all new occurrence is removed.
 */// w w w .  j a  va2 s. co  m
private void deleteDuplicates() {
    for (int i = 0; i < recipientsTo.size(); i++) {
        Address to = recipientsTo.get(i);
        for (int y = i + 1; y < recipientsTo.size(); y++) {
            if (to.equals(recipientsTo.get(y)))
                recipientsTo.remove(y--);
        }
        for (int y = 0; y < recipientsCc.size(); y++) {
            if (to.equals(recipientsCc.get(y)))
                recipientsCc.remove(y--);
        }
        for (int y = 0; y < recipientsBcc.size(); y++) {
            if (to.equals(recipientsBcc.get(y)))
                recipientsBcc.remove(y--);
        }
    }
    for (int i = 0; i < recipientsCc.size(); i++) {
        Address cc = recipientsCc.get(i);
        for (int y = i + 1; y < recipientsCc.size(); y++) {
            if (cc.equals(recipientsCc.get(y)))
                recipientsCc.remove(y--);
        }
        for (int y = 0; y < recipientsBcc.size(); y++) {
            if (cc.equals(recipientsBcc.get(y)))
                recipientsBcc.remove(y--);
        }
    }
    for (int i = 0; i < recipientsBcc.size(); i++) {
        Address bcc = recipientsBcc.get(i);
        for (int y = i + 1; y < recipientsBcc.size(); y++) {
            if (bcc.equals(recipientsBcc.get(y)))
                recipientsBcc.remove(y--);
        }
    }
}