]> git.mxchange.org Git - jmailer-ee.git/blobdiff - src/org/mxchange/jmailee/model/delivery/wrapper/EmailDeliveryWrapper.java
Updated copyright year
[jmailer-ee.git] / src / org / mxchange / jmailee / model / delivery / wrapper / EmailDeliveryWrapper.java
index 89d49783ea40b3c5d03976efa5a50a540357e968..304d5fc99ad647b7a1b652d1d599587f7ca91931 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Roland Haeder
+ * Copyright (C) 2016 - 2022 Free Software Foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  */
 package org.mxchange.jmailee.model.delivery.wrapper;
 
+import java.util.Locale;
 import java.util.Properties;
+import javax.mail.Address;
 
 /**
  * A wrapper class for email delivery.
  * <p>
- * @author Roland Haeder<roland@mxchange.org>
+ * @author Roland Hรคder<roland@mxchange.org>
  */
 public class EmailDeliveryWrapper implements WrapableEmailDelivery {
 
@@ -31,103 +33,98 @@ public class EmailDeliveryWrapper implements WrapableEmailDelivery {
        private static final long serialVersionUID = 518_209_689_877_185_914L;
 
        /**
-        * Body of email
+        * Locale instance for language
         */
-       private String body;
+       private Locale locale;
 
        /**
         * Recipient email address
         */
-       private String emailAddress;
+       private Address recipientAddress;
 
        /**
-        * (Optional) properties
+        * Subject line
         */
-       private Properties[] properties;
+       private String subjectLine;
 
        /**
-        * Subject line
+        * Template name
         */
-       private String subjectLine;
+       private String templateName;
+
+       /**
+        * Template variables
+        */
+       private Properties templateVariables;
 
        /**
-        * Constructor with email address (recipient), subject line, body and
-        * optional properties
-        *
-        * @param emailAddress Recipient's email address
-        * @param subjectLine Subject line
-        * @param body Body content
-        * @param properties Optional properties to e.g. override from address
+        * Constructor with all required fields
+        * <p>
+        * @param recipientAddress  Recipient's email address
+        * @param subjectLine       Subject line (internationalized)
+        * @param templateName      Template name
+        * @param templateVariables Any template variables, at least one
+        * @param locale            Recipient's locale
         */
-       public EmailDeliveryWrapper (final String emailAddress, final String subjectLine, final String body, final Properties[] properties) {
-               // Check all except properties as they are optional
-               if (null == emailAddress) {
-                       // Throw NPE
-                       throw new NullPointerException("emailAddress is null"); //NOI18N
-               } else if (emailAddress.trim().isEmpty()) {
-                       // Is empty
-                       throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
-               } else if (null == subjectLine) {
-                       // Throw NPE
-                       throw new NullPointerException("subjectLine is null"); //NOI18N
-               } else if (subjectLine.trim().isEmpty()) {
-                       // Is empty
-                       throw new IllegalArgumentException("subjectLine is empty"); //NOI18N
-               } else if (null == body) {
-                       // Throw NPE
-                       throw new NullPointerException("body is null"); //NOI18N
-               } else if (body.trim().isEmpty()) {
-                       // Is empty
-                       throw new IllegalArgumentException("body is empty"); //NOI18N
-               }
-
-               // Then set all
-               this.emailAddress = emailAddress;
+       public EmailDeliveryWrapper (final Address recipientAddress, final String subjectLine, final String templateName, final Properties templateVariables, final Locale locale) {
+               // Set all fields
+               this.recipientAddress = recipientAddress;
                this.subjectLine = subjectLine;
-               this.body = body;
-               this.properties = properties;
+               this.templateName = templateName;
+               this.templateVariables = templateVariables;
+               this.locale = locale;
        }
 
        @Override
-       public String getBody () {
-               return this.body;
+       public Locale getLocale () {
+               return this.locale;
        }
 
        @Override
-       public void setBody (final String body) {
-               this.body = body;
+       public void setLocale (final Locale locale) {
+               this.locale = locale;
        }
 
        @Override
-       public String getEmailAddress () {
-               return this.emailAddress;
+       public Address getRecipientAddress () {
+               return this.recipientAddress;
        }
 
        @Override
-       public void setEmailAddress (final String emailAddress) {
-               this.emailAddress = emailAddress;
+       public void setRecipientAddress (final Address recipientAddress) {
+               this.recipientAddress = recipientAddress;
        }
 
        @Override
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public Properties[] getProperties () {
-               return this.properties;
+       public String getSubjectLine () {
+               return this.subjectLine;
        }
 
        @Override
-       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
-       public void setProperties (final Properties[] properties) {
-               this.properties = properties;
+       public void setSubjectLine (final String subjectLine) {
+               this.subjectLine = subjectLine;
        }
 
        @Override
-       public String getSubjectLine () {
-               return this.subjectLine;
+       public String getTemplateName () {
+               return this.templateName;
        }
 
        @Override
-       public void setSubjectLine (final String subjectLine) {
-               this.subjectLine = subjectLine;
+       public void setTemplateName (final String templateName) {
+               this.templateName = templateName;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public Properties getTemplateVariables () {
+               return this.templateVariables;
+       }
+
+       @Override
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       public void setTemplateVariables (final Properties templateVariables) {
+               this.templateVariables = templateVariables;
        }
 
 }