From: Roland Häder <roland@mxchange.org>
Date: Wed, 19 Oct 2022 12:02:31 +0000 (+0200)
Subject: Continued:
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=791171ef690374f67fc0244262bc29999d44aea6;p=jmailer-ee.git

Continued:
- added checks on each parameter
- made some (local) variables final
---

diff --git a/src/org/mxchange/jmailee/model/delivery/BaseMailerBean.java b/src/org/mxchange/jmailee/model/delivery/BaseMailerBean.java
index f859ba8..7d16adb 100644
--- a/src/org/mxchange/jmailee/model/delivery/BaseMailerBean.java
+++ b/src/org/mxchange/jmailee/model/delivery/BaseMailerBean.java
@@ -133,10 +133,10 @@ public abstract class BaseMailerBean extends BaseEnterpriseBean implements Deliv
 		}
 
 		// 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);
diff --git a/src/org/mxchange/jmailee/model/delivery/wrapper/EmailDeliveryWrapper.java b/src/org/mxchange/jmailee/model/delivery/wrapper/EmailDeliveryWrapper.java
index 304d5fc..479dbe0 100644
--- a/src/org/mxchange/jmailee/model/delivery/wrapper/EmailDeliveryWrapper.java
+++ b/src/org/mxchange/jmailee/model/delivery/wrapper/EmailDeliveryWrapper.java
@@ -67,6 +67,33 @@ public class EmailDeliveryWrapper implements WrapableEmailDelivery {
 	 * @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;