Class MpnBuilder
- java.lang.Object
-
- com.lightstreamer.client.mpn.util.MpnBuilder
-
public class MpnBuilder extends java.lang.ObjectUtility class that provides methods to build or parse the JSON structure used to represent the format of a push notification.
It provides getters and setters for the fields of a push notification, following the format specified by Google's Firebase Cloud Messaging (FCM). This format is compatible withMpnSubscription.setNotificationFormat(String).
-
-
Constructor Summary
Constructors Constructor Description MpnBuilder()Creates an empty object to be used to create a push notification format from scratch.
Use setters methods to set the value of push notification fields.MpnBuilder(java.lang.String notificationFormat)Creates an object based on the specified push notification format.
Use getter methods to obtain the value of push notification fields.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.Stringbody()Gets the value ofandroid.notification.bodyfield.MpnBuilderbody(java.lang.String body)Sets theandroid.notification.bodyfield.java.util.List<java.lang.String>bodyLocArguments()Gets the value ofandroid.notification.body_loc_argsfield.MpnBuilderbodyLocArguments(java.util.List<java.lang.String> bodyLocArguments)Sets theandroid.notification.body_loc_argsfield.java.lang.StringbodyLocKey()Gets the value ofandroid.notification.body_loc_keyfield.MpnBuilderbodyLocKey(java.lang.String bodyLocKey)Sets theandroid.notification.body_loc_keyfield.java.lang.Stringbuild()Produces the JSON structure for the push notification format specified by this object.java.lang.StringclickAction()Gets the value ofandroid.notification.click_actionfield.MpnBuilderclickAction(java.lang.String clickAction)Sets theandroid.notification.click_actionfield.java.lang.StringcollapseKey()Gets the value ofandroid.collapse_keyfield.MpnBuildercollapseKey(java.lang.String collapseKey)Sets theandroid.collapse_keyfield.java.lang.Stringcolor()Gets the value ofandroid.notification.colorfield.MpnBuildercolor(java.lang.String color)Sets theandroid.notification.colorfield.MpnBuildercontentAvailable(java.lang.Boolean contentAvailable)Deprecated.Thecontent_availableis no more supported on Firebase Cloud Messaging.MpnBuildercontentAvailable(java.lang.String contentAvailable)Deprecated.Thecontent_availableis no more supported on Firebase Cloud Messaging.java.lang.BooleancontentAvailableAsBoolean()Deprecated.Thecontent_availableis no more supported on Firebase Cloud Messaging.java.lang.StringcontentAvailableAsString()Deprecated.Thecontent_availableis no more supported on Firebase Cloud Messaging.java.util.Map<java.lang.String,java.lang.String>data()Gets sub-fields of theandroid.datafield.MpnBuilderdata(java.util.Map<java.lang.String,java.lang.String> data)Sets sub-fields of theandroid.datafield.java.lang.Stringicon()Gets the value ofandroid.notification.iconfield.MpnBuildericon(java.lang.String icon)Sets theandroid.notification.iconfield.java.lang.Stringpriority()Gets the value ofandroid.priorityfield.MpnBuilderpriority(java.lang.String priority)Sets theandroid.priorityfield.java.lang.Stringsound()Gets the value ofandroid.notification.soundfield.MpnBuildersound(java.lang.String sound)Sets theandroid.notification.soundfield.java.lang.Stringtag()Gets the value ofandroid.notification.tagfield.MpnBuildertag(java.lang.String tag)Sets theandroid.notification.tagfield.MpnBuildertimeToLive(java.lang.Integer timeToLive)Sets theandroid.ttlfield with an integer value.MpnBuildertimeToLive(java.lang.String timeToLive)Sets theandroid.ttlfield with a string value.java.lang.IntegertimeToLiveAsInteger()Gets the value ofandroid.ttlfield as an integer.java.lang.StringtimeToLiveAsString()Gets the value ofandroid.ttlfield as a string.java.lang.Stringtitle()Gets the value ofandroid.notification.titlefield.MpnBuildertitle(java.lang.String title)Sets theandroid.notification.titlefield.java.util.List<java.lang.String>titleLocArguments()Gets the value ofandroid.notification.title_loc_argsfield.MpnBuildertitleLocArguments(java.util.List<java.lang.String> titleLocArguments)Sets theandroid.notification.title_loc_argsfield.java.lang.StringtitleLocKey()Gets the value ofandroid.notification.title_loc_keyfield.MpnBuildertitleLocKey(java.lang.String titleLocKey)Sets theandroid.notification.title_loc_keyfield.
-
-
-
Constructor Detail
-
MpnBuilder
public MpnBuilder()
Creates an empty object to be used to create a push notification format from scratch.
Use setters methods to set the value of push notification fields.
-
MpnBuilder
public MpnBuilder(@Nonnull java.lang.String notificationFormat)Creates an object based on the specified push notification format.
Use getter methods to obtain the value of push notification fields.- Parameters:
notificationFormat- A JSON structure representing a push notification format.- Throws:
java.lang.IllegalArgumentException- if the notification is not a valid JSON structure.
-
-
Method Detail
-
build
@Nonnull public java.lang.String build()
Produces the JSON structure for the push notification format specified by this object.- Returns:
- the JSON structure for the push notification format.
-
collapseKey
public MpnBuilder collapseKey(java.lang.String collapseKey)
Sets theandroid.collapse_keyfield.- Parameters:
collapseKey- A string to be used for theandroid.collapse_keyfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
collapseKey
public java.lang.String collapseKey()
Gets the value ofandroid.collapse_keyfield.- Returns:
- the value of
android.collapse_keyfield, or null if absent.
-
priority
public MpnBuilder priority(java.lang.String priority)
Sets theandroid.priorityfield.- Parameters:
priority- A string to be used for theandroid.priorityfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
priority
public java.lang.String priority()
Gets the value ofandroid.priorityfield.- Returns:
- the value of
android.priorityfield, or null if absent.
-
contentAvailable
@Deprecated public MpnBuilder contentAvailable(java.lang.String contentAvailable)
Deprecated.Thecontent_availableis no more supported on Firebase Cloud Messaging.- Parameters:
contentAvailable- Ignored.- Returns:
- this MpnBuilder object, for fluent use.
-
contentAvailableAsString
@Deprecated public java.lang.String contentAvailableAsString()
Deprecated.Thecontent_availableis no more supported on Firebase Cloud Messaging.- Returns:
- always null.
-
contentAvailable
@Deprecated public MpnBuilder contentAvailable(java.lang.Boolean contentAvailable)
Deprecated.Thecontent_availableis no more supported on Firebase Cloud Messaging.- Parameters:
contentAvailable- Ignored.- Returns:
- this MpnBuilder object, for fluent use.
-
contentAvailableAsBoolean
@Deprecated public java.lang.Boolean contentAvailableAsBoolean()
Deprecated.Thecontent_availableis no more supported on Firebase Cloud Messaging.- Returns:
- always null.
-
timeToLive
public MpnBuilder timeToLive(java.lang.String timeToLive)
Sets theandroid.ttlfield with a string value.- Parameters:
timeToLive- A string to be used for theandroid.ttlfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
timeToLiveAsString
public java.lang.String timeToLiveAsString()
Gets the value ofandroid.ttlfield as a string.- Returns:
- a string with the value of
android.ttlfield, or null if absent.
-
timeToLive
public MpnBuilder timeToLive(java.lang.Integer timeToLive)
Sets theandroid.ttlfield with an integer value.- Parameters:
timeToLive- An integer to be used for theandroid.ttlfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
timeToLiveAsInteger
public java.lang.Integer timeToLiveAsInteger()
Gets the value ofandroid.ttlfield as an integer.- Returns:
- an integer with the value of
android.ttlfield, or null if absent.
-
title
public MpnBuilder title(java.lang.String title)
Sets theandroid.notification.titlefield.- Parameters:
title- A string to be used for theandroid.notification.titlefield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
title
public java.lang.String title()
Gets the value ofandroid.notification.titlefield.- Returns:
- the value of
android.notification.titlefield, or null if absent.
-
titleLocKey
public MpnBuilder titleLocKey(java.lang.String titleLocKey)
Sets theandroid.notification.title_loc_keyfield.- Parameters:
titleLocKey- A string to be used for theandroid.notification.title_loc_keyfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
titleLocKey
public java.lang.String titleLocKey()
Gets the value ofandroid.notification.title_loc_keyfield.- Returns:
- the value of
android.notification.title_loc_keyfield, or null if absent.
-
titleLocArguments
public MpnBuilder titleLocArguments(java.util.List<java.lang.String> titleLocArguments)
Sets theandroid.notification.title_loc_argsfield.- Parameters:
titleLocArguments- A list of strings to be used for theandroid.notification.title_loc_argsfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
titleLocArguments
public java.util.List<java.lang.String> titleLocArguments()
Gets the value ofandroid.notification.title_loc_argsfield.- Returns:
- a list of strings with the value of
android.notification.title_loc_argsfield, or null if absent.
-
body
public MpnBuilder body(java.lang.String body)
Sets theandroid.notification.bodyfield.- Parameters:
body- A string to be used for theandroid.notification.bodyfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
body
public java.lang.String body()
Gets the value ofandroid.notification.bodyfield.- Returns:
- the value of
android.notification.bodyfield, or null if absent.
-
bodyLocKey
public MpnBuilder bodyLocKey(java.lang.String bodyLocKey)
Sets theandroid.notification.body_loc_keyfield.- Parameters:
bodyLocKey- A string to be used for theandroid.notification.body_loc_keyfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
bodyLocKey
public java.lang.String bodyLocKey()
Gets the value ofandroid.notification.body_loc_keyfield.- Returns:
- the value of
android.notification.body_loc_keyfield, or null if absent.
-
bodyLocArguments
public MpnBuilder bodyLocArguments(java.util.List<java.lang.String> bodyLocArguments)
Sets theandroid.notification.body_loc_argsfield.- Parameters:
bodyLocArguments- A list of strings to be used for theandroid.notification.body_loc_argsfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
bodyLocArguments
public java.util.List<java.lang.String> bodyLocArguments()
Gets the value ofandroid.notification.body_loc_argsfield.- Returns:
- a list of strings with the value of
android.notification.body_loc_argsfield, or null if absent.
-
icon
public MpnBuilder icon(java.lang.String icon)
Sets theandroid.notification.iconfield.- Parameters:
icon- A string to be used for theandroid.notification.iconfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
icon
public java.lang.String icon()
Gets the value ofandroid.notification.iconfield.- Returns:
- the value of
android.notification.iconfield, or null if absent.
-
sound
public MpnBuilder sound(java.lang.String sound)
Sets theandroid.notification.soundfield.- Parameters:
sound- A string to be used for theandroid.notification.soundfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
sound
public java.lang.String sound()
Gets the value ofandroid.notification.soundfield.- Returns:
- the value of
android.notification.soundfield, or null if absent.
-
tag
public MpnBuilder tag(java.lang.String tag)
Sets theandroid.notification.tagfield.- Parameters:
tag- A string to be used for theandroid.notification.tagfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
tag
public java.lang.String tag()
Gets the value ofandroid.notification.tagfield.- Returns:
- the value of
android.notification.tagfield, or null if absent.
-
color
public MpnBuilder color(java.lang.String color)
Sets theandroid.notification.colorfield.- Parameters:
color- A string to be used for theandroid.notification.colorfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
color
public java.lang.String color()
Gets the value ofandroid.notification.colorfield.- Returns:
- the value of
android.notification.colorfield, or null if absent.
-
clickAction
public MpnBuilder clickAction(java.lang.String clickAction)
Sets theandroid.notification.click_actionfield.- Parameters:
clickAction- A string to be used for theandroid.notification.click_actionfield value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
clickAction
public java.lang.String clickAction()
Gets the value ofandroid.notification.click_actionfield.- Returns:
- the value of
android.notification.click_actionfield, or null if absent.
-
data
public MpnBuilder data(java.util.Map<java.lang.String,java.lang.String> data)
Sets sub-fields of theandroid.datafield.- Parameters:
data- A map to be used for sub-fields of theandroid.datafield, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
data
public java.util.Map<java.lang.String,java.lang.String> data()
Gets sub-fields of theandroid.datafield.- Returns:
- A map with sub-fields of the
android.datafield, or null if absent.
-
-