1 package com
.google
.appengine
.api
.mail
;
3 import javax
.mail
.internet
.MimeMessage
;
6 * The {@code BounceNotification} object represents an incoming bounce
10 public final class BounceNotification
{
12 * The {@code BounceNotification.Details} class describes either the original
13 * message that caused a bounce, or the notification message describing the
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
) {
25 this.subject
= subject
;
30 * @return the 'from' field for this detail item. Can be null.
32 public String
getFrom() {
37 * @return the 'to' field for this detail item. Can be null.
39 public String
getTo() {
44 * @return the 'subject' field for this detail item. Can be null.
46 public String
getSubject() {
51 * @return the 'text' field for this detail item. Can be null.
53 public String
getText() {
58 static class DetailsBuilder
{
61 private String subject
;
64 public Details
build() {
65 return new Details(from
, to
, subject
, text
);
68 public DetailsBuilder
withFrom(String from
) {
73 public DetailsBuilder
withTo(String to
) {
78 public DetailsBuilder
withSubject(String subject
) {
79 this.subject
= subject
;
83 public DetailsBuilder
withText(String text
) {
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
;
99 public BounceNotificationBuilder
withOriginal(BounceNotification
.Details original
) {
100 this.original
= original
;
104 public BounceNotificationBuilder
withNotification(BounceNotification
.Details notification
) {
105 this.notification
= notification
;
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() {
128 * @return the parsed Details of the original message. Can be null.
130 public final Details
getOriginal() {
135 * @return the parsed Details describing the bounce. Can be null.
137 public final Details
getNotification() {
141 private final MimeMessage rawMessage
;
142 private final Details original
;
143 private final Details notification
;