Class WebNotificationOptions.Builder

java.lang.Object
com.vaadin.flow.component.webnotification.WebNotificationOptions.Builder
All Implemented Interfaces:
Serializable
Enclosing class:
WebNotificationOptions

public static final class WebNotificationOptions.Builder extends Object implements Serializable
Builds WebNotificationOptions. Every setter returns the builder for chaining.
See Also:
  • Method Details

    • body

      public WebNotificationOptions.Builder body(@Nullable String body)
      Sets the text shown below the title.
      Parameters:
      body - the text, or null for none
      Returns:
      this builder
    • icon

      public WebNotificationOptions.Builder icon(@Nullable String icon)
      Sets the URL of an image shown with the notification. A relative URL is resolved against the page.
      Parameters:
      icon - the image URL, or null for the browser's default
      Returns:
      this builder
    • tag

      public WebNotificationOptions.Builder tag(@Nullable String tag)
      Sets the group the notification belongs to. Showing a notification replaces a notification with the same tag that is still visible, so repeated updates about the same thing do not pile up.
      Parameters:
      tag - the tag, or null for none
      Returns:
      this builder
    • renotify

      public WebNotificationOptions.Builder renotify(boolean renotify)
      Sets whether replacing a notification with the same tag alerts the user again with sound or vibration. Without it the replacement is silent. Requires a tag, and cannot be combined with silent.
      Parameters:
      renotify - true to alert the user again
      Returns:
      this builder
    • requireInteraction

      public WebNotificationOptions.Builder requireInteraction(boolean requireInteraction)
      Sets whether the notification stays visible until the user clicks or dismisses it, instead of closing automatically after a while.
      Parameters:
      requireInteraction - true to keep the notification visible
      Returns:
      this builder
    • silent

      public WebNotificationOptions.Builder silent(boolean silent)
      Sets whether the notification is shown without sound or vibration.
      Parameters:
      silent - true to show the notification silently
      Returns:
      this builder
    • build

      public WebNotificationOptions build()
      Creates the options from the settings of this builder.
      Returns:
      the options
      Throws:
      IllegalArgumentException - if renotify is set without a tag or together with silent