]> git.mxchange.org Git - jmailer-ee.git/blob - src/org/mxchange/jmailee/model/delivery/wrapper/EmailDeliveryWrapper.java
moved to new location
[jmailer-ee.git] / src / org / mxchange / jmailee / model / delivery / wrapper / EmailDeliveryWrapper.java
1 /*
2  * Copyright (C) 2016 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jmailee.model.delivery.wrapper;
18
19 import java.util.Properties;
20
21 /**
22  * A wrapper class for email delivery.
23  * <p>
24  * @author Roland Haeder<roland@mxchange.org>
25  */
26 public class EmailDeliveryWrapper implements WrapableEmailDelivery {
27
28         /**
29          * Serial number
30          */
31         private static final long serialVersionUID = 518_209_689_877_185_914L;
32
33         /**
34          * Body of email
35          */
36         private String body;
37
38         /**
39          * Recipient email address
40          */
41         private String emailAddress;
42
43         /**
44          * (Optional) properties
45          */
46         private Properties[] properties;
47
48         /**
49          * Subject line
50          */
51         private String subjectLine;
52
53         /**
54          * Constructor with email address (recipient), subject line, body and
55          * optional properties
56          *
57          * @param emailAddress Recipient's email address
58          * @param subjectLine Subject line
59          * @param body Body content
60          * @param properties Optional properties to e.g. override from address
61          */
62         public EmailDeliveryWrapper (final String emailAddress, final String subjectLine, final String body, final Properties[] properties) {
63                 // Check all except properties as they are optional
64                 if (null == emailAddress) {
65                         // Throw NPE
66                         throw new NullPointerException("emailAddress is null"); //NOI18N
67                 } else if (emailAddress.trim().isEmpty()) {
68                         // Is empty
69                         throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
70                 } else if (null == subjectLine) {
71                         // Throw NPE
72                         throw new NullPointerException("subjectLine is null"); //NOI18N
73                 } else if (subjectLine.trim().isEmpty()) {
74                         // Is empty
75                         throw new IllegalArgumentException("subjectLine is empty"); //NOI18N
76                 } else if (null == body) {
77                         // Throw NPE
78                         throw new NullPointerException("body is null"); //NOI18N
79                 } else if (body.trim().isEmpty()) {
80                         // Is empty
81                         throw new IllegalArgumentException("body is empty"); //NOI18N
82                 }
83
84                 // Then set all
85                 this.emailAddress = emailAddress;
86                 this.subjectLine = subjectLine;
87                 this.body = body;
88                 this.properties = properties;
89         }
90
91         @Override
92         public String getBody () {
93                 return this.body;
94         }
95
96         @Override
97         public void setBody (final String body) {
98                 this.body = body;
99         }
100
101         @Override
102         public String getEmailAddress () {
103                 return this.emailAddress;
104         }
105
106         @Override
107         public void setEmailAddress (final String emailAddress) {
108                 this.emailAddress = emailAddress;
109         }
110
111         @Override
112         @SuppressWarnings ("ReturnOfCollectionOrArrayField")
113         public Properties[] getProperties () {
114                 return this.properties;
115         }
116
117         @Override
118         @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
119         public void setProperties (final Properties[] properties) {
120                 this.properties = properties;
121         }
122
123         @Override
124         public String getSubjectLine () {
125                 return this.subjectLine;
126         }
127
128         @Override
129         public void setSubjectLine (final String subjectLine) {
130                 this.subjectLine = subjectLine;
131         }
132
133 }