Class PushMessageBuilder
java.lang.Object
com.iizix.server.push.engine.PushMessageBuilder
- All Implemented Interfaces:
IPushNotificationMessageBuilder
The fluent builder of a
PushMessage.The builder is bound to nothing: the TTL default is applied by the engine at dispatch, from its settings, when the message carries a negative TTL. Not thread-safe; not reusable after build().
- Author:
- Christopher Mindus
Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionSets the notification badge URL (theoptions.badgefield) — the monochrome glyph a device shows in its status area.Sets the notification body (theoptions.bodyfield) — the secondary text shown beneath the title.build()Validates the accumulated fields and builds the immutable notification.Adds one key/value pair to the notification's application data (theoptions.dataobject), which the service worker receives verbatim and the application interprets.Sets the notification icon URL (theoptions.iconfield).Sets an arbitrary option directly into theoptionsmap, for fields not covered by a dedicated setter (e.g.Sets the notification tag (theoptions.tagfield).timeToLive(long millis) Sets this notification's time-to-live in milliseconds, overriding the server default.Sets the notification title (theshowNotificationtitle argument).
Constructor Details
PushMessageBuilder
public PushMessageBuilder()Creates an empty builder.
Method Details
title
Description copied from interface:IPushNotificationMessageBuilderSets the notification title (theshowNotificationtitle argument). Required.- Specified by:
titlein interfaceIPushNotificationMessageBuilder- Parameters:
title- The title; must be non-null and non-empty.- Returns:
this, for chaining.
body
Description copied from interface:IPushNotificationMessageBuilderSets the notification body (theoptions.bodyfield) — the secondary text shown beneath the title.- Specified by:
bodyin interfaceIPushNotificationMessageBuilder- Parameters:
body- The body text.- Returns:
this, for chaining.
icon
Description copied from interface:IPushNotificationMessageBuilderSets the notification icon URL (theoptions.iconfield).- Specified by:
iconin interfaceIPushNotificationMessageBuilder- Parameters:
iconUrl- The icon URL.- Returns:
this, for chaining.
badge
Description copied from interface:IPushNotificationMessageBuilderSets the notification badge URL (theoptions.badgefield) — the monochrome glyph a device shows in its status area.- Specified by:
badgein interfaceIPushNotificationMessageBuilder- Parameters:
badgeUrl- The badge URL.- Returns:
this, for chaining.
tag
Description copied from interface:IPushNotificationMessageBuilderSets the notification tag (theoptions.tagfield). Notifications sharing a tag coalesce on the device, replacing rather than stacking.- Specified by:
tagin interfaceIPushNotificationMessageBuilder- Parameters:
tag- The tag.- Returns:
this, for chaining.
data
Description copied from interface:IPushNotificationMessageBuilderAdds one key/value pair to the notification's application data (theoptions.dataobject), which the service worker receives verbatim and the application interprets. Repeated calls accumulate; a repeated key overwrites.- Specified by:
datain interfaceIPushNotificationMessageBuilder- Parameters:
key- The data key; must be non-null.value- The data value.- Returns:
this, for chaining.
option
Description copied from interface:IPushNotificationMessageBuilderSets an arbitrary option directly into theoptionsmap, for fields not covered by a dedicated setter (e.g.requireInteraction,silent,actions).- Specified by:
optionin interfaceIPushNotificationMessageBuilder- Parameters:
key- The option key; must be non-null.value- The option value.- Returns:
this, for chaining.
timeToLive
Description copied from interface:IPushNotificationMessageBuilderSets this notification's time-to-live in milliseconds, overriding the server default. Clamped by the engine to the configured TTL range; a notification left without an explicit TTL usesIPushSettings.getDefaultTTL().- Specified by:
timeToLivein interfaceIPushNotificationMessageBuilder- Parameters:
millis- The TTL in milliseconds.- Returns:
this, for chaining.
build
Description copied from interface:IPushNotificationMessageBuilderValidates the accumulated fields and builds the immutable notification.- Specified by:
buildin interfaceIPushNotificationMessageBuilder- Returns:
- The built
IPushNotification; nevernull.