Interface NotificationBuilder

All Known Implementing Classes:
StandardNotificationBuilder

public interface NotificationBuilder
Builds instances of Notification based on input parameters. Instances of NotificationBuilder may be configured partially by the container, therefore they should be created using a Provider or Injected into client code. In general a new instance of NotificationBuilder should be obtained for each use as they should not be considered thread-safe. Likewise, they should not be bound in the container as Singleton types and should be created on-demand. Typically instances of this interface will throw NotificationConfigurationException in the event notifications are not configured properly, such as missing the correct ApplicationConfiguration assocaited with the requesting Application.
  • Method Details

    • sender

      default NotificationBuilder sender(Profile sourceProfile)
      Specifies the profile which is sending the notification. The default implementation of this should just defaults to using the Profile.getApplication() and supplying it directly to Application. Implementations may include more detailed information about the sender of the Notification
      Parameters:
      sourceProfile - the Profile of the source of the Notification
      Returns:
      this instance
    • application

      NotificationBuilder application(Application application)
      Specifies the Application sourcing the Notification. This will scan the associated ApplicationConfiguration instances and select a suitable configuration (or combination thereof) which will be used to configure the means by which the underlying Notification will be sent.
      Parameters:
      application - the Application sending the Notification
      Returns:
      this instance
    • recipient

      NotificationBuilder recipient(Profile recipient)
      Specifies the Profile which will receive the Notification.
      Parameters:
      recipient - the Profile which will recieve the Notification
      Returns:
      this instance
    • title

      Specifies the title text of the Notification.
      Parameters:
      title - the title text
      Returns:
      this instance
    • message

      NotificationBuilder message(String message)
      Specifies the text to send along with the Notification.
      Parameters:
      message - the message to send
      Returns:
      this instance
    • sound

      default NotificationBuilder sound()
      Specifies the default sound to play when sending a message. The default implementation just specifies the sound using "default." passed to sound(String).
      Returns:
      this instance
    • sound

      Specifies the sound to play when delivering the message.
      Parameters:
      sound - the sound to play when delivering the message
      Returns:
      this instance
    • add

      NotificationBuilder add(@Nonnull String key, @Nonnull String value)
      Adds a single key/value property. Individual keys should be non-empty and all values should be non-null
      Parameters:
      key - - A non-empty string key for the property
      value - - A non-null string value for the property
      Returns:
      this instance
    • addAll

      NotificationBuilder addAll(Map<String,String> properties)
      Adds all properties in the passed in mapping to the notification being built. Any keys which are null or empty Strings will be ignored. Any values which are null will be ignored. For all other entries, if any keys previously exist in the notification, they will be replaced by the value specified in the passed in Map. If a value is null, then that
      Parameters:
      properties - - A Map of all properties to be added in bulk to this notification.
      Returns:
      this instance
    • build

      Notification build()
      Constructs the instance of Notification with all of the configured information. This returns a new instance of Notification for each call which can be treated independently.
      Returns:
      the Notification