1 package com
.google
.appengine
.api
.mail
;
3 import javax
.annotation
.Nullable
;
4 import javax
.mail
.internet
.MimeMessage
;
7 * The {@code BounceNotification} object represents an incoming bounce
11 public final class BounceNotification
{
13 * The {@code BounceNotification.Details} class describes either the original
14 * message that caused a bounce, or the notification message describing the
17 public final static class Details
{
18 private final String from
;
19 private final String to
;
20 private final String cc
;
21 private final String bcc
;
22 private final String subject
;
23 private final String text
;
25 private Details(@Nullable String from
, @Nullable String to
, @Nullable String cc
,
26 @Nullable String bcc
, @Nullable String subject
, @Nullable String text
) {
31 this.subject
= subject
;
36 * @return the 'from' field for this detail item.
39 public String
getFrom() {
44 * @return the 'to' field for this detail item.
47 public String
getTo() {
52 * @return the 'cc' field for this detail item.
55 public String
getCc() {
60 * @return the 'bcc' field for this detail item.
63 public String
getBcc() {
68 * @return the 'subject' field for this detail item.
71 public String
getSubject() {
76 * @return the 'text' field for this detail item.
79 public String
getText() {
84 static class DetailsBuilder
{
89 private String subject
;
92 public Details
build() {
93 return new Details(from
, to
, cc
, bcc
, subject
, text
);
96 public DetailsBuilder
withFrom(@Nullable String from
) {
101 public DetailsBuilder
withTo(@Nullable String to
) {
106 public DetailsBuilder
withCc(@Nullable String cc
) {
111 public DetailsBuilder
withBcc(@Nullable String bcc
) {
116 public DetailsBuilder
withSubject(@Nullable String subject
) {
117 this.subject
= subject
;
121 public DetailsBuilder
withText(@Nullable String text
) {
127 static class BounceNotificationBuilder
{
128 public BounceNotification
build() {
129 return new BounceNotification(rawMessage
, original
, notification
);
132 public BounceNotificationBuilder
withRawMessage(MimeMessage rawMessage
) {
133 this.rawMessage
= rawMessage
;
137 public BounceNotificationBuilder
withOriginal(BounceNotification
.Details original
) {
138 this.original
= original
;
142 public BounceNotificationBuilder
withNotification(BounceNotification
.Details notification
) {
143 this.notification
= notification
;
147 private MimeMessage rawMessage
;
148 private BounceNotification
.Details original
;
149 private BounceNotification
.Details notification
;
152 BounceNotification(@Nullable MimeMessage rawMessage
, @Nullable Details original
,
153 @Nullable Details notification
) {
154 this.rawMessage
= rawMessage
;
155 this.original
= original
;
156 this.notification
= notification
;
160 * @return the original MIME message that caused the bounce.
163 public final MimeMessage
getRawMessage() {
168 * @return the parsed Details of the original message.
171 public final Details
getOriginal() {
176 * @return the parsed Details describing the bounce.
179 public final Details
getNotification() {
183 private final MimeMessage rawMessage
;
184 private final Details original
;
185 private final Details notification
;