|
20 | 20 | import java.util.Set; |
21 | 21 | import java.util.TimeZone; |
22 | 22 |
|
| 23 | +import static jakarta.mail.Message.RecipientType.BCC; |
| 24 | +import static jakarta.mail.Message.RecipientType.CC; |
| 25 | +import static jakarta.mail.Message.RecipientType.TO; |
23 | 26 | import static java.lang.Boolean.TRUE; |
24 | 27 | import static java.lang.String.format; |
25 | 28 | import static java.util.Collections.unmodifiableList; |
26 | 29 | import static java.util.Collections.unmodifiableMap; |
| 30 | +import static java.util.stream.Collectors.toList; |
27 | 31 | import static org.simplejavamail.internal.util.ListUtil.merge; |
28 | 32 | import static org.simplejavamail.internal.util.Preconditions.checkNonEmptyArgument; |
29 | 33 |
|
@@ -520,6 +524,36 @@ public List<AttachmentResource> getEmbeddedImages() { |
520 | 524 | public List<Recipient> getRecipients() { |
521 | 525 | return recipients; |
522 | 526 | } |
| 527 | + |
| 528 | + /** |
| 529 | + * @see EmailPopulatingBuilder#to(Recipient...) |
| 530 | + * @see EmailPopulatingBuilder#cc(Recipient...) |
| 531 | + * @see EmailPopulatingBuilder#bcc(Recipient...) |
| 532 | + */ |
| 533 | + @NotNull |
| 534 | + public List<Recipient> getToRecipients() { |
| 535 | + return recipients.stream().filter(r -> r.getType() == TO).collect(toList()); |
| 536 | + } |
| 537 | + |
| 538 | + /** |
| 539 | + * @see EmailPopulatingBuilder#to(Recipient...) |
| 540 | + * @see EmailPopulatingBuilder#cc(Recipient...) |
| 541 | + * @see EmailPopulatingBuilder#bcc(Recipient...) |
| 542 | + */ |
| 543 | + @NotNull |
| 544 | + public List<Recipient> getCcRecipients() { |
| 545 | + return recipients.stream().filter(r -> r.getType() == CC).collect(toList()); |
| 546 | + } |
| 547 | + |
| 548 | + /** |
| 549 | + * @see EmailPopulatingBuilder#to(Recipient...) |
| 550 | + * @see EmailPopulatingBuilder#cc(Recipient...) |
| 551 | + * @see EmailPopulatingBuilder#bcc(Recipient...) |
| 552 | + */ |
| 553 | + @NotNull |
| 554 | + public List<Recipient> getBccRecipients() { |
| 555 | + return recipients.stream().filter(r -> r.getType() == BCC).collect(toList()); |
| 556 | + } |
523 | 557 |
|
524 | 558 | /** |
525 | 559 | * @see EmailPopulatingBuilder#withHeader(String, Object) |
|
0 commit comments