Class Notification

java.lang.Object
com.broadleafcommerce.notification.domain.Notification
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware

public class Notification extends Object implements com.broadleafcommerce.data.tracking.core.ContextStateAware
A Notification represents a message to send to a Recipient. Notifications have a notificationType which is a business defined value which can be used to resolve the message. Notifications have a deliveryType which can determine the provider that will send the message (for example, EMAIL and SMS).
Author:
Broadleaf Commerce
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addBcc(String emailAddress)
    Convenience method to easily add a "cc" recipient using just an email.
    void
    addBcc(String emailAddress, String name)
    Convenience method to easily add a "to" recipient using an email and name.
    void
    addCc(String emailAddress)
    Convenience method to easily add a "cc" recipient using just an email.
    void
    addCc(String emailAddress, String name)
    Convenience method to easily add a "to" recipient using an email and name.
    void
    addToEmail(String emailAddress)
    Convenience method to easily add a "to" recipient using just an email.
    void
    addToEmail(String emailAddress, String name)
    Convenience method to easily add a "to" recipient using an email and name.
    void
    addToMobile(String mobileNumber)
    Convenience method to easily add a "to" recipient mobile.
    void
    addToMobile(String mobileNumber, String name)
    Convenience method to easily add a "to" recipient using an email and name.
    protected boolean
     
    boolean
     
    com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState
    A subset of Tracking information to expose the context state for this object.
    The date that this notification was first created.
    A String (typically JSON structure) representing the data for the notification template.
    Delivery Type (EMAIL, SMS) represents how the message will be delivered.
    Unique identifier for the notification.
    The messageBody for the Notification.
    Message Type (RESET_PASSWORD, ORDER_CONFIRMATION) represents the type of notification being sent.
    Tracks the lifecycle of a notification.
    A generic set of properties that can be added to the notification.
    List of objects to receive this notification.
    int
    The number of times this message has been retried.
    The Sender for this notification.
    The date that this notification was first created.
    List of mediaUrls to send to supporting SMS provider.
    For Notifications with an EMAIL deliveryType, the subject of the EMAIL.
    Can be used to specify which templateName the provider should use to construct the messageBody.
    int
     
    void
    setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
    A subset of Tracking information to expose the context state for this object.
    void
    setCreateDate(Instant createDate)
    The date that this notification was first created.
    void
    A String (typically JSON structure) representing the data for the notification template.
    void
    setDeliveryType(String deliveryType)
    Delivery Type (EMAIL, SMS) represents how the message will be delivered.
    void
    Unique identifier for the notification.
    void
    setMessageBody(String messageBody)
    The messageBody for the Notification.
    void
    setMessageType(String messageType)
    Message Type (RESET_PASSWORD, ORDER_CONFIRMATION) represents the type of notification being sent.
    void
    setNotificationStatus(String notificationStatus)
    Tracks the lifecycle of a notification.
    void
    A generic set of properties that can be added to the notification.
    void
    List of objects to receive this notification.
    void
    setRetryCount(int retryCount)
    The number of times this message has been retried.
    void
    setSender(Sender sender)
    The Sender for this notification.
    void
    setSentDate(Instant sentDate)
    The date that this notification was first created.
    void
    setSmsMediaUrls(List<String> smsMediaUrls)
    List of mediaUrls to send to supporting SMS provider.
    void
    setSubject(String subject)
    For Notifications with an EMAIL deliveryType, the subject of the EMAIL.
    void
    setTemplateName(String templateName)
    Can be used to specify which templateName the provider should use to construct the messageBody.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Notification

      public Notification()
  • Method Details

    • addToEmail

      public void addToEmail(String emailAddress)
      Convenience method to easily add a "to" recipient using just an email.
      Parameters:
      emailAddress -
    • addToEmail

      public void addToEmail(String emailAddress, String name)
      Convenience method to easily add a "to" recipient using an email and name.
      Parameters:
      emailAddress -
    • addToMobile

      public void addToMobile(String mobileNumber)
      Convenience method to easily add a "to" recipient mobile.
      Parameters:
      mobileNumber -
    • addToMobile

      public void addToMobile(String mobileNumber, String name)
      Convenience method to easily add a "to" recipient using an email and name.
      Parameters:
      mobileNumber -
      name -
    • addCc

      public void addCc(String emailAddress)
      Convenience method to easily add a "cc" recipient using just an email.
      Parameters:
      emailAddress -
    • addCc

      public void addCc(String emailAddress, String name)
      Convenience method to easily add a "to" recipient using an email and name.
      Parameters:
      emailAddress -
    • addBcc

      public void addBcc(String emailAddress)
      Convenience method to easily add a "cc" recipient using just an email.
      Parameters:
      emailAddress -
    • addBcc

      public void addBcc(String emailAddress, String name)
      Convenience method to easily add a "to" recipient using an email and name.
      Parameters:
      emailAddress -
    • getId

      public String getId()
      Unique identifier for the notification. Typically a ULID.
      Returns:
      the id of this Notification
    • getNotificationStatus

      public String getNotificationStatus()
      Tracks the lifecycle of a notification.

      Default States

      • NEW : Default state indicating that the message is being prepared
      • READY_TO_SEND : Indicates the message is ready to be delivered
      • SENDING : The MessageSender has been called to send the message
      • SENT : The MessageSender has successfully delivered the message
      • RETRY : The MessageSender has indicated that the message could be retried
      • ERROR : The message received an error when building or sending.
      Returns:
      the notification status
    • getMessageType

      public String getMessageType()

      Message Type (RESET_PASSWORD, ORDER_CONFIRMATION) represents the type of notification being sent.

      The messageType is typically use along with the deliveryType to determine the appropriate provider to build and deliver the message.

      Returns:
      the message type of this Notification
    • getDeliveryType

      public String getDeliveryType()
      Delivery Type (EMAIL, SMS) represents how the message will be delivered. The deliveryType typically use along with the notificationType to determine the appropriate provider to build and deliver the message. Defaults to "EMAIL"
      Returns:
      the delivery type of this Notification
    • getSender

      public Sender getSender()
      The Sender for this notification. It is common for the Notification not to know the sender and instead for the NotificationHandler or MessageSender to have a default sender configured.
    • getRecipients

      public List<Recipient> getRecipients()
      List of objects to receive this notification. Typically, a notification has a single Recipient. This list provides support for multiple "TO", "CC", and "BCC" on the same notification.
    • getSubject

      public String getSubject()
      For Notifications with an EMAIL deliveryType, the subject of the EMAIL. Other deliveryTypes may use this field but it is not typical.
      Returns:
      the subject of the Notification
    • getTemplateName

      public String getTemplateName()
      Can be used to specify which templateName the provider should use to construct the messageBody. Typically not used as a MessageBuilder will rely on the notificationType (e.g. RESET_PASSWORD or ORDER_CONFIRMATION) and the deliveryType (e.g. SMS, EMAIL) to determine the correct template.
      Returns:
      the name of a template used for this notification
    • getData

      public String getData()
      A String (typically JSON structure) representing the data for the notification template. Most templates will be coded to expect a specific data content and structure.
      Returns:
      a JSON structure representing the data for the notification template.
    • getProperties

      public Map<String,Object> getProperties()
      A generic set of properties that can be added to the notification. These can be used by templates or to target an appropriate NotificationHandler.
    • getMessageBody

      public String getMessageBody()
      The messageBody for the Notification. Required for messages that are not built using a templateName and templateData. This field is typically not populated when using a 3rd party processor to process the template.
      Returns:
      the message
    • getRetryCount

      public int getRetryCount()
      The number of times this message has been retried.
      Returns:
      The number of retry attempts to send this notification.
    • getCreateDate

      public Instant getCreateDate()
      The date that this notification was first created.
      Returns:
      The date that this notification was first created.
    • getSentDate

      public Instant getSentDate()
      The date that this notification was first created.
      Returns:
      The date that this notification was sent to a provider.
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • getSmsMediaUrls

      public List<String> getSmsMediaUrls()
      List of mediaUrls to send to supporting SMS provider.
      Returns:
      the list of media urls.
      See Also:
    • setId

      public void setId(String id)
      Unique identifier for the notification. Typically a ULID.
      Parameters:
      id -
    • setNotificationStatus

      public void setNotificationStatus(String notificationStatus)
      Tracks the lifecycle of a notification.

      Default States

      • NEW : Default state indicating that the message is being prepared
      • READY_TO_SEND : Indicates the message is ready to be delivered
      • SENDING : The MessageSender has been called to send the message
      • SENT : The MessageSender has successfully delivered the message
      • RETRY : The MessageSender has indicated that the message could be retried
      • ERROR : The message received an error when building or sending.
      Parameters:
      notificationStatus -
    • setMessageType

      public void setMessageType(String messageType)

      Message Type (RESET_PASSWORD, ORDER_CONFIRMATION) represents the type of notification being sent.

      The messageType is typically use along with the deliveryType to determine the appropriate provider to build and deliver the message.

      Parameters:
      messageType -
    • setDeliveryType

      public void setDeliveryType(String deliveryType)
      Delivery Type (EMAIL, SMS) represents how the message will be delivered. The deliveryType typically use along with the notificationType to determine the appropriate provider to build and deliver the message. Defaults to "EMAIL"
      Parameters:
      deliveryType -
    • setSender

      public void setSender(Sender sender)
      The Sender for this notification. It is common for the Notification not to know the sender and instead for the NotificationHandler or MessageSender to have a default sender configured.
    • setRecipients

      public void setRecipients(List<Recipient> recipients)
      List of objects to receive this notification. Typically, a notification has a single Recipient. This list provides support for multiple "TO", "CC", and "BCC" on the same notification.
    • setSubject

      public void setSubject(String subject)
      For Notifications with an EMAIL deliveryType, the subject of the EMAIL. Other deliveryTypes may use this field but it is not typical.
      Parameters:
      subject -
    • setTemplateName

      public void setTemplateName(String templateName)
      Can be used to specify which templateName the provider should use to construct the messageBody. Typically not used as a MessageBuilder will rely on the notificationType (e.g. RESET_PASSWORD or ORDER_CONFIRMATION) and the deliveryType (e.g. SMS, EMAIL) to determine the correct template.
      Parameters:
      templateName -
    • setData

      public void setData(String data)
      A String (typically JSON structure) representing the data for the notification template. Most templates will be coded to expect a specific data content and structure.
      Parameters:
      templateData -
    • setProperties

      public void setProperties(Map<String,Object> properties)
      A generic set of properties that can be added to the notification. These can be used by templates or to target an appropriate NotificationHandler.
    • setMessageBody

      public void setMessageBody(String messageBody)
      The messageBody for the Notification. Required for messages that are not built using a templateName and templateData. This field is typically not populated when using a 3rd party processor to process the template.
      Parameters:
      messageBody -
    • setRetryCount

      public void setRetryCount(int retryCount)
      The number of times this message has been retried.
      Parameters:
      retryCount -
    • setCreateDate

      public void setCreateDate(Instant createDate)
      The date that this notification was first created.
      Parameters:
      createDate - The date that this notification was first created.
    • setSentDate

      public void setSentDate(Instant sentDate)
      The date that this notification was first created.
      Parameters:
      sentDate - The date that this notification was sent to a provider.
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • setSmsMediaUrls

      public void setSmsMediaUrls(List<String> smsMediaUrls)
      List of mediaUrls to send to supporting SMS provider.
      Parameters:
      list - of media urls to add to an SMS message
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object