}
// Parse from address
- Address senderAddress = new InternetAddress(this.properties.getProperty("mailer.from"));
+ final Address senderAddress = new InternetAddress(this.properties.getProperty("mailer.from"));
// Get MIME message instance
- MimeMessage message = new MimeMessage(mailSession);
+ final MimeMessage message = new MimeMessage(mailSession);
// Set subject, recipients and body
message.setFrom(senderAddress);
* @param locale Recipient's locale
*/
public EmailDeliveryWrapper (final Address recipientAddress, final String subjectLine, final String templateName, final Properties templateVariables, final Locale locale) {
+ // Are all parameter set?
+ if (null == recipientAddress) {
+ // Throw NPE
+ throw new NullPointerException("recipientAddress is null"); //NOI18N
+ } else if (null == subjectLine) {
+ // Throw it again
+ throw new NullPointerException("subjectLine is null"); //NOI18N
+ } else if (subjectLine.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("subjectLine is empty"); //NOI18N
+ } else if (null == templateName) {
+ // Throw NPE
+ throw new NullPointerException("templateName is null"); //NOI18N
+ } else if (templateName.isEmpty()) {
+ // Throw IAE
+ throw new IllegalArgumentException("templateName is empty"); //NOI18N
+ } else if (null == templateVariables) {
+ // Throw NPE
+ throw new NullPointerException("templateVariables is null"); //NOI18N
+ } else if (templateVariables.isEmpty()) {
+ // At least one parameter should be there
+ throw new IllegalArgumentException("templatesVariables should have at least one parameter set."); //NOI18N
+ } else if (null == locale) {
+ // Throw NPE
+ throw new NullPointerException("locale is null"); //NOI18N
+ }
+
// Set all fields
this.recipientAddress = recipientAddress;
this.subjectLine = subjectLine;