App Engine Java SDK version 1.9.25
[gae.git] / java / src / main / com / google / appengine / api / mail / BounceNotification.java
blob36381932b9df63036f1835eb851714591308a83b
1 package com.google.appengine.api.mail;
3 import javax.annotation.Nullable;
4 import javax.mail.internet.MimeMessage;
6 /**
7 * The {@code BounceNotification} object represents an incoming bounce
8 * notification.
11 public final class BounceNotification {
12 /**
13 * The {@code BounceNotification.Details} class describes either the original
14 * message that caused a bounce, or the notification message describing the
15 * bounce.
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) {
27 this.from = from;
28 this.to = to;
29 this.cc = cc;
30 this.bcc = bcc;
31 this.subject = subject;
32 this.text = text;
35 /**
36 * @return the 'from' field for this detail item.
38 @Nullable
39 public String getFrom() {
40 return from;
43 /**
44 * @return the 'to' field for this detail item.
46 @Nullable
47 public String getTo() {
48 return to;
51 /**
52 * @return the 'cc' field for this detail item.
54 @Nullable
55 public String getCc() {
56 return cc;
59 /**
60 * @return the 'bcc' field for this detail item.
62 @Nullable
63 public String getBcc() {
64 return bcc;
67 /**
68 * @return the 'subject' field for this detail item.
70 @Nullable
71 public String getSubject() {
72 return subject;
75 /**
76 * @return the 'text' field for this detail item.
78 @Nullable
79 public String getText() {
80 return text;
84 static class DetailsBuilder {
85 private String from;
86 private String to;
87 private String cc;
88 private String bcc;
89 private String subject;
90 private String text;
92 public Details build() {
93 return new Details(from, to, cc, bcc, subject, text);
96 public DetailsBuilder withFrom(@Nullable String from) {
97 this.from = from;
98 return this;
101 public DetailsBuilder withTo(@Nullable String to) {
102 this.to = to;
103 return this;
106 public DetailsBuilder withCc(@Nullable String cc) {
107 this.cc = cc;
108 return this;
111 public DetailsBuilder withBcc(@Nullable String bcc) {
112 this.bcc = bcc;
113 return this;
116 public DetailsBuilder withSubject(@Nullable String subject) {
117 this.subject = subject;
118 return this;
121 public DetailsBuilder withText(@Nullable String text) {
122 this.text = text;
123 return this;
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;
134 return this;
137 public BounceNotificationBuilder withOriginal(BounceNotification.Details original) {
138 this.original = original;
139 return this;
142 public BounceNotificationBuilder withNotification(BounceNotification.Details notification) {
143 this.notification = notification;
144 return this;
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.
162 @Nullable
163 public final MimeMessage getRawMessage() {
164 return rawMessage;
168 * @return the parsed Details of the original message.
170 @Nullable
171 public final Details getOriginal() {
172 return original;
176 * @return the parsed Details describing the bounce.
178 @Nullable
179 public final Details getNotification() {
180 return notification;
183 private final MimeMessage rawMessage;
184 private final Details original;
185 private final Details notification;