1 package org.kuali.common.devops.jenkins.monitor.ses; 2 3 import static com.google.common.collect.Lists.newArrayList; 4 5 import java.util.List; 6 7 import javax.validation.constraints.Size; 8 9 import org.kuali.common.core.build.ValidatingBuilder; 10 import org.kuali.common.core.validate.annotation.IdiotProofImmutable; 11 12 import com.google.common.collect.ImmutableList; 13 14 @IdiotProofImmutable 15 public final class Email { 16 17 private final String from; 18 @Size(min = 1) 19 private final ImmutableList<String> to; 20 private final String subject; 21 private final String body; 22 private final boolean html; 23 24 private Email(Builder builder) { 25 this.from = builder.from; 26 this.to = ImmutableList.copyOf(builder.to); 27 this.subject = builder.subject; 28 this.body = builder.body; 29 this.html = builder.html; 30 } 31 32 public static Builder builder() { 33 return new Builder(); 34 } 35 36 public static class Builder extends ValidatingBuilder<Email> { 37 38 private String from; 39 private List<String> to = newArrayList(); 40 private String subject; 41 private String body; 42 private boolean html = true; 43 44 public Builder withHtml(boolean html) { 45 this.html = html; 46 return this; 47 } 48 49 public Builder withFrom(String from) { 50 this.from = from; 51 return this; 52 } 53 54 public Builder withTo(List<String> to) { 55 this.to = to; 56 return this; 57 } 58 59 public Builder withSubject(String subject) { 60 this.subject = subject; 61 return this; 62 } 63 64 public Builder withBody(String body) { 65 this.body = body; 66 return this; 67 } 68 69 @Override 70 public Email build() { 71 return validate(new Email(this)); 72 } 73 } 74 75 public String getFrom() { 76 return from; 77 } 78 79 public List<String> getTo() { 80 return to; 81 } 82 83 public String getSubject() { 84 return subject; 85 } 86 87 public String getBody() { 88 return body; 89 } 90 91 public boolean isHtml() { 92 return html; 93 } 94 95 }