Record Class WebNotificationOptions
java.lang.Object
java.lang.Record
com.vaadin.flow.component.webnotification.WebNotificationOptions
- Record Components:
body- the text shown below the title, ornullfor noneicon- the URL of an image shown with the notification, ornullfor the browser's defaulttag- the group the notification belongs to, ornullfor none; showing a notification replaces a notification with the same tag that is still visible instead of adding another onerenotify- whether replacing a notification with the same tag alerts the user again with sound or vibration;truerequires atagand cannot be combined withsilentrequireInteraction- whether the notification stays visible until the user clicks or dismisses it instead of closing automatically after a whilesilent- whether the notification is shown without sound or vibration
- All Implemented Interfaces:
Serializable
public record WebNotificationOptions(@Nullable String body, @Nullable String icon, @Nullable String tag, boolean renotify, boolean requireInteraction, boolean silent)
extends Record
implements Serializable
What a notification shows besides its title, and how it behaves. Every
setting is optional: a text that is not set is left out, and a flag that is
not set is
false, so a notification behaves the same in every
browser. Create instances with builder():
WebNotificationOptions options = WebNotificationOptions.builder()
.body("Report for March is ready").tag("report").build();
How a setting is presented is up to the browser and the operating system, and
some ignore settings they do not support — for example, Firefox and Safari
ignore requireInteraction.- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionWebNotificationOptions(@Nullable String body, @Nullable String icon, @Nullable String tag, boolean renotify, boolean requireInteraction, boolean silent) Validates the combination of settings. -
Method Summary
Modifier and TypeMethodDescription@Nullable Stringbody()Returns the value of thebodyrecord component.builder()Creates a builder with no settings set.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@Nullable Stringicon()Returns the value of theiconrecord component.booleanrenotify()Returns the value of therenotifyrecord component.booleanReturns the value of therequireInteractionrecord component.booleansilent()Returns the value of thesilentrecord component.@Nullable Stringtag()Returns the value of thetagrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
WebNotificationOptions
public WebNotificationOptions(@Nullable String body, @Nullable String icon, @Nullable String tag, boolean renotify, boolean requireInteraction, boolean silent) Validates the combination of settings.- Throws:
IllegalArgumentException- ifrenotifyistruewithout atagor together withsilent, which browsers reject
-
-
Method Details
-
builder
Creates a builder with no settings set.- Returns:
- a new builder
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
body
Returns the value of thebodyrecord component.- Returns:
- the value of the
bodyrecord component
-
icon
Returns the value of theiconrecord component.- Returns:
- the value of the
iconrecord component
-
tag
Returns the value of thetagrecord component.- Returns:
- the value of the
tagrecord component
-
renotify
public boolean renotify()Returns the value of therenotifyrecord component.- Returns:
- the value of the
renotifyrecord component
-
requireInteraction
public boolean requireInteraction()Returns the value of therequireInteractionrecord component.- Returns:
- the value of the
requireInteractionrecord component
-
silent
public boolean silent()Returns the value of thesilentrecord component.- Returns:
- the value of the
silentrecord component
-