<commit_before>package org.sagebionetworks.bridge.services.email;

import static com.google.common.base.Preconditions.checkArgument;
import static org.apache.commons.lang3.StringUtils.isNotBlank;

import java.util.List;

import javax.mail.internet.MimeBodyPart;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

/**
 * This is a light wrapper around the information needed to construct a MIME multi-part email 
 * message using the Java mail API.
 */
public final class MimeTypeEmail {
    
    private static final String QUOTE = "\"";
    private static final String QUOTED_QUOTE = "\\\\\"";

    private final String subject;
    private final String senderAddress;
    private final List<String> recipientAddresses;
    private final List<MimeBodyPart> messageParts;
    
    MimeTypeEmail(String subject, String senderAddress, List<String> recipientAddresses, List<MimeBodyPart> messageParts) {
        checkArgument(isNotBlank(senderAddress));
        checkArgument(isNotBlank(subject));
        checkArgument(isNotBlank(senderAddress));
        checkArgument(recipientAddresses != null && !recipientAddresses.isEmpty());
        checkArgument(messageParts != null && !messageParts.isEmpty());
        
        this.subject = subject;
        this.senderAddress = escapeEmailAddress(senderAddress);
        this.recipientAddresses = Lists.transform(recipientAddresses, new Function<String,String>() {
            @Override public String apply(String address) {
                return escapeEmailAddress(address);
            }
        });
        this.messageParts = ImmutableList.copyOf(messageParts);
    }
    
    public String getSubject() {
        return subject;
    }
    public String getSenderAddress() {
        return senderAddress;
    }
    public List<String> getRecipientAddresses() {
        return recipientAddresses;
    }
    public List<MimeBodyPart> getMessageParts() {
        return messageParts;
    }
    /**<commit_msg>Making this a static property<commit_after>package org.sagebionetworks.bridge.services.email;

import static com.google.common.base.Preconditions.checkArgument;
import static org.apache.commons.lang3.StringUtils.isNotBlank;

import java.util.List;

import javax.mail.internet.MimeBodyPart;

import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

/**
 * This is a light wrapper around the information needed to construct a MIME multi-part email 
 * message using the Java mail API.
 */
public final class MimeTypeEmail {
    
    private static final String QUOTE = "\"";
    private static final String QUOTED_QUOTE = "\\\\\"";
    
    private final Function<String,String> APPLY_EMAIL_ESCAPER = new Function<String,String>() {
        @Override public String apply(final String address) {
            return escapeEmailAddress(address);
        }
    };

    private final String subject;
    private final String senderAddress;
    private final List<String> recipientAddresses;
    private final List<MimeBodyPart> messageParts;
    
    MimeTypeEmail(String subject, String senderAddress, List<String> recipientAddresses, List<MimeBodyPart> messageParts) {
        checkArgument(isNotBlank(senderAddress));
        checkArgument(isNotBlank(subject));
        checkArgument(isNotBlank(senderAddress));
        checkArgument(recipientAddresses != null && !recipientAddresses.isEmpty());
        checkArgument(messageParts != null && !messageParts.isEmpty());
        
        this.subject = subject;
        this.senderAddress = escapeEmailAddress(senderAddress);
        this.recipientAddresses = Lists.transform(recipientAddresses, APPLY_EMAIL_ESCAPER);
        this.messageParts = ImmutableList.copyOf(messageParts);
    }
    
    public String getSubject() {
        return subject;
    }
    public String getSenderAddress() {
        return senderAddress;
    }
    public List<String> getRecipientAddresses() {
        return recipientAddresses;
    }
    public List<MimeBodyPart> getMessageParts() {
        return messageParts;
    }
    /**
{'fraction_non_alphanumeric': 0.09106198942815955, 'fraction_numerical': 0.0004805382027871216, 'mean_word_length': 3.520086862106406, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5904792', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1107, 'n_words': 256}