Class Notification

java.lang.Object
com.globalmentor.beans.BoundPropertyObject
All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, LabelModel, Model

public class Notification extends DefaultLabelModel
A notification to the user of some event or state, such as an error or invalid user input. A notification also allows certain options indicating response choices for the user when presented with the notification.
Author:
Garret Wilson
  • Constructor Details

    • Notification

      public Notification(Throwable error, Notification.Option... options)
      Error constructor with a Notification.Severity.ERROR severity and a text/plain content type. If the error provides a message, it is used as the notification message; otherwise, the error's string value is used as the message.
      Parameters:
      error - The associated error or exception.
      options - The available response options; if no options are given, Notification.Option.OK will be assumed.
      Throws:
      NullPointerException - if the given error and/or options is null.
    • Notification

      public Notification(Throwable error, String message, Notification.Option... options)
      Error and message constructor with a Notification.Severity.ERROR severity and a text/plain content type.
      Parameters:
      error - The associated error or exception.
      message - The message text, which may include a resource reference.
      options - The available response options; if no options are given, Notification.Option.OK will be assumed.
      Throws:
      NullPointerException - if the given error, message, and/or options is null.
    • Notification

      public Notification(String message, Notification.Option... options)
      Message constructor with a Notification.Severity.INFO severity, no error, and a text/plain content type.
      Parameters:
      message - The message text, which may include a resource reference.
      options - The available response options; if no options are given, Notification.Option.OK will be assumed.
      Throws:
      NullPointerException - if the given message and/or options is null.
    • Notification

      public Notification(String message, Notification.Severity severity, Notification.Option... options)
      Message and severity constructor with no error and a text/plain content type.
      Parameters:
      message - The message text, which may include a resource reference.
      severity - The severity of the notification.
      options - The available response options; if no options are given, Notification.Option.OK will be assumed.
      Throws:
      NullPointerException - if the given message, severity, and/or options is null.
    • Notification

      public Notification(String message, Notification.Severity severity, Throwable error, Notification.Option... options)
      Message, severity, and error constructor with a text/plain content type.
      Parameters:
      message - The message text, which may include a resource reference.
      severity - The severity of the notification.
      error - The associated error or exception, or null if there is no related error.
      options - The available response options; if no options are given, Notification.Option.OK will be assumed.
      Throws:
      NullPointerException - if the given message, severity, and/or options is null.
    • Notification

      public Notification(String message, com.globalmentor.net.MediaType messageContentType, Notification.Option... options)
      Message and message content type constructor with a Notification.Severity.INFO severity and no associated error.
      Parameters:
      message - The message text, which may include a resource reference
      messageContentType - The message text content type.
      options - The available response options; if no options are given, Notification.Option.OK will be assumed.
      Throws:
      NullPointerException - if the given message, severity, and/or options is null.
      IllegalArgumentException - if the given content type is not a text content type.
    • Notification

      public Notification(String message, com.globalmentor.net.MediaType messageContentType, Notification.Severity severity, Notification.Option... options)
      Message, message content type, and severity constructor with no associated error.
      Parameters:
      message - The message text, which may include a resource reference.
      messageContentType - The message text content type.
      severity - The severity of the notification.
      options - The available response options; if no options are given, Notification.Option.OK will be assumed.
      Throws:
      NullPointerException - if the given message, severity, and/or options is null.
      IllegalArgumentException - if the given content type is not a text content type.
    • Notification

      public Notification(String message, com.globalmentor.net.MediaType messageContentType, Notification.Severity severity, Throwable error, Notification.Option... options)
      Message, message content type, severity, error, and options constructor.
      Parameters:
      message - The message text, which may include a resource reference.
      messageContentType - The message text content type.
      severity - The severity of the notification.
      error - The associated error or exception, or null if there is no related error.
      options - The available response options; if no options are given, Notification.Option.OK will be assumed.
      Throws:
      NullPointerException - if the given message and/or options is null.
      IllegalArgumentException - if the given content type is not a text content type.
  • Method Details

    • getError

      public Throwable getError()
      Returns:
      The associated error or exception, if any.
    • getSeverity

      public Notification.Severity getSeverity()
      Returns:
      The severity of the notification.
    • getOptions

      public List<Notification.Option> getOptions()
      Returns:
      The read-only list of available response options in order.
    • getMessage

      public String getMessage()
      Returns:
      The message text, which may include a resource reference.
    • getMessageContentType

      public com.globalmentor.net.MediaType getMessageContentType()
      Returns:
      The content type of the message text.
    • toString

      public String toString()
      Overrides:
      toString in class DefaultLabelModel