// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.organization;

import com.google.common.collect.ImmutableList;

import java.util.Collection;
import java.util.Objects;

/**
 * A message with a subject and a nonempty set of recipients.
 *
 * @author jonmv
 */
public class Mail {

    private final Collection<String> recipients;
    private final String subject;
    private final String message;

    public Mail(Collection<String> recipients, String subject, String message) {
        if (recipients.isEmpty())
            throw new IllegalArgumentException("Empty recipient list is not allowed.");
        recipients.forEach(Objects::requireNonNull);
        this.recipients = ImmutableList.copyOf(recipients);
        this.subject = Objects.requireNonNull(subject);
        this.message = Objects.requireNonNull(message);
    }

    public Collection<String> recipients() { return recipients; }
    public String subject() { return subject; }
    public String message() { return message; }

}

@@ -274,16 +274,43 @@
 Objects;
+%0Aimport java.util.Optional;
 %0A%0A/**%0A *
@@ -530,16 +530,64 @@
 message;
+%0A    private final Optional%3CString%3E htmlMessage;
 %0A%0A    pu
@@ -661,16 +661,367 @@
 sage) %7B%0A
+        this(recipients, subject, message, Optional.empty());%0A    %7D%0A%0A    public Mail(Collection%3CString%3E recipients, String subject, String message, String htmlMessage) %7B%0A        this(recipients, subject, message, Optional.of(htmlMessage));%0A    %7D%0A%0A    Mail(Collection%3CString%3E recipients, String subject, String message, Optional%3CString%3E htmlMessage) %7B%0A
         
@@ -1359,16 +1359,80 @@
 ssage);%0A
+        this.htmlMessage = Objects.requireNonNull(htmlMessage);%0A
     %7D%0A%0A 
@@ -1540,24 +1540,24 @@
  subject; %7D%0A
-
     public S
@@ -1591,12 +1591,78 @@
 ssage; %7D
+%0A    public Optional%3CString%3E htmlMessage() %7B return htmlMessage; %7D
 %0A%0A%7D%0A

Add support for html content