1.9.5
[gae.git] / java / src / main / com / google / appengine / api / mail / BounceNotification.java
blobd101db4a7c72a61995e6a10a61e9440d9e20768a
1 package com.google.appengine.api.mail;
3 import javax.mail.internet.MimeMessage;
5 /**
6 * The {@code BounceNotification} object represents an incoming bounce
7 * notification.
9 */
10 public final class BounceNotification {
11 /**
12 * The {@code BounceNotification.Details} class describes either the original
13 * message that caused a bounce, or the notification message describing the
14 * bounce.
16 public final static class Details {
17 private final String from;
18 private final String to;
19 private final String subject;
20 private final String text;
22 private Details(String from, String to, String subject, String text) {
23 this.from = from;
24 this.to = to;
25 this.subject = subject;
26 this.text = text;
29 /**
30 * @return the 'from' field for this detail item. Can be null.
32 public String getFrom() {
33 return from;
36 /**
37 * @return the 'to' field for this detail item. Can be null.
39 public String getTo() {
40 return to;
43 /**
44 * @return the 'subject' field for this detail item. Can be null.
46 public String getSubject() {
47 return subject;
50 /**
51 * @return the 'text' field for this detail item. Can be null.
53 public String getText() {
54 return text;
58 static class DetailsBuilder {
59 private String from;
60 private String to;
61 private String subject;
62 private String text;
64 public Details build() {
65 return new Details(from, to, subject, text);
68 public DetailsBuilder withFrom(String from) {
69 this.from = from;
70 return this;
73 public DetailsBuilder withTo(String to) {
74 this.to = to;
75 return this;
78 public DetailsBuilder withSubject(String subject) {
79 this.subject = subject;
80 return this;
83 public DetailsBuilder withText(String text) {
84 this.text = text;
85 return this;
89 static class BounceNotificationBuilder {
90 public BounceNotification build() {
91 return new BounceNotification(rawMessage, original, notification);
94 public BounceNotificationBuilder withRawMessage(MimeMessage rawMessage) {
95 this.rawMessage = rawMessage;
96 return this;
99 public BounceNotificationBuilder withOriginal(BounceNotification.Details original) {
100 this.original = original;
101 return this;
104 public BounceNotificationBuilder withNotification(BounceNotification.Details notification) {
105 this.notification = notification;
106 return this;
109 private MimeMessage rawMessage;
110 private BounceNotification.Details original;
111 private BounceNotification.Details notification;
114 BounceNotification(MimeMessage rawMessage, Details original, Details notification) {
115 this.rawMessage = rawMessage;
116 this.original = original;
117 this.notification = notification;
121 * @return the original MIME message that caused the bounce. Can be null.
123 public final MimeMessage getRawMessage() {
124 return rawMessage;
128 * @return the parsed Details of the original message. Can be null.
130 public final Details getOriginal() {
131 return original;
135 * @return the parsed Details describing the bounce. Can be null.
137 public final Details getNotification() {
138 return notification;
141 private final MimeMessage rawMessage;
142 private final Details original;
143 private final Details notification;