Package com.lightstreamer.client.mpn
Class MpnBuilder
java.lang.Object
com.lightstreamer.client.mpn.MpnBuilder
Utility 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 FCM REST API. This format is compatible with
It provides getters and setters for the fields of a push notification, following the format specified by FCM REST API. This format is compatible with
MpnSubscription.setNotificationFormat(String)
.- See Also:
-
Constructor Summary
ConstructorDescriptionCreates 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
(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
Modifier and TypeMethodDescriptionbody()
Gets the value ofandroid.notification.body
field.Sets theandroid.notification.body
field.Gets the value ofandroid.notification.body_loc_args
field.bodyLocArguments
(List<String> bodyLocArguments) Sets theandroid.notification.body_loc_args
field.Gets the value ofandroid.notification.body_loc_key
field.bodyLocKey
(String bodyLocKey) Sets theandroid.notification.body_loc_key
field.build()
Produces the JSON structure for the push notification format specified by this object.Gets the value ofandroid.notification.click_action
field.clickAction
(String clickAction) Sets theandroid.notification.click_action
field.Gets the value ofandroid.collapse_key
field.collapseKey
(String collapseKey) Sets theandroid.collapse_key
field.color()
Gets the value ofandroid.notification.color
field.Sets theandroid.notification.color
field.data()
Gets sub-fields of theandroid.data
field.Sets sub-fields of theandroid.data
field.icon()
Gets the value ofandroid.notification.icon
field.Sets theandroid.notification.icon
field.priority()
Gets the value ofandroid.priority
field.Sets theandroid.priority
field.sound()
Gets the value ofandroid.notification.sound
field.Sets theandroid.notification.sound
field.tag()
Gets the value ofandroid.notification.tag
field.Sets theandroid.notification.tag
field.timeToLive
(Integer timeToLive) Sets theandroid.ttl
field with an integer value.timeToLive
(String timeToLive) Sets theandroid.ttl
field with a string value.Gets the value ofandroid.ttl
field as an integer.Gets the value ofandroid.ttl
field as a string.title()
Gets the value ofandroid.notification.title
field.Sets theandroid.notification.title
field.Gets the value ofandroid.notification.title_loc_args
field.titleLocArguments
(List<String> titleLocArguments) Sets theandroid.notification.title_loc_args
field.Gets the value ofandroid.notification.title_loc_key
field.titleLocKey
(String titleLocKey) Sets theandroid.notification.title_loc_key
field.
-
Constructor Details
-
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
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:
IllegalArgumentException
- if the notification is not a valid JSON structure.
-
-
Method Details
-
build
Produces the JSON structure for the push notification format specified by this object.- Returns:
- the JSON structure for the push notification format.
-
collapseKey
Sets theandroid.collapse_key
field.- Parameters:
collapseKey
- A string to be used for theandroid.collapse_key
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
collapseKey
Gets the value ofandroid.collapse_key
field.- Returns:
- the value of
android.collapse_key
field, or null if absent.
-
priority
Sets theandroid.priority
field.- Parameters:
priority
- A string to be used for theandroid.priority
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
priority
Gets the value ofandroid.priority
field.- Returns:
- the value of
android.priority
field, or null if absent.
-
timeToLive
Sets theandroid.ttl
field with a string value.- Parameters:
timeToLive
- A string to be used for theandroid.ttl
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
timeToLiveAsString
Gets the value ofandroid.ttl
field as a string.- Returns:
- a string with the value of
android.ttl
field, or null if absent.
-
timeToLive
Sets theandroid.ttl
field with an integer value.- Parameters:
timeToLive
- An integer to be used for theandroid.ttl
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
timeToLiveAsInteger
Gets the value ofandroid.ttl
field as an integer.- Returns:
- an integer with the value of
android.ttl
field, or null if absent.
-
title
Sets theandroid.notification.title
field.- Parameters:
title
- A string to be used for theandroid.notification.title
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
title
Gets the value ofandroid.notification.title
field.- Returns:
- the value of
android.notification.title
field, or null if absent.
-
titleLocKey
Sets theandroid.notification.title_loc_key
field.- Parameters:
titleLocKey
- A string to be used for theandroid.notification.title_loc_key
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
titleLocKey
Gets the value ofandroid.notification.title_loc_key
field.- Returns:
- the value of
android.notification.title_loc_key
field, or null if absent.
-
titleLocArguments
Sets theandroid.notification.title_loc_args
field.- Parameters:
titleLocArguments
- A list of strings to be used for theandroid.notification.title_loc_args
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
titleLocArguments
Gets the value ofandroid.notification.title_loc_args
field.- Returns:
- a list of strings with the value of
android.notification.title_loc_args
field, or null if absent.
-
body
Sets theandroid.notification.body
field.- Parameters:
body
- A string to be used for theandroid.notification.body
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
body
Gets the value ofandroid.notification.body
field.- Returns:
- the value of
android.notification.body
field, or null if absent.
-
bodyLocKey
Sets theandroid.notification.body_loc_key
field.- Parameters:
bodyLocKey
- A string to be used for theandroid.notification.body_loc_key
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
bodyLocKey
Gets the value ofandroid.notification.body_loc_key
field.- Returns:
- the value of
android.notification.body_loc_key
field, or null if absent.
-
bodyLocArguments
Sets theandroid.notification.body_loc_args
field.- Parameters:
bodyLocArguments
- A list of strings to be used for theandroid.notification.body_loc_args
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
bodyLocArguments
Gets the value ofandroid.notification.body_loc_args
field.- Returns:
- a list of strings with the value of
android.notification.body_loc_args
field, or null if absent.
-
icon
Sets theandroid.notification.icon
field.- Parameters:
icon
- A string to be used for theandroid.notification.icon
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
icon
Gets the value ofandroid.notification.icon
field.- Returns:
- the value of
android.notification.icon
field, or null if absent.
-
sound
Sets theandroid.notification.sound
field.- Parameters:
sound
- A string to be used for theandroid.notification.sound
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
sound
Gets the value ofandroid.notification.sound
field.- Returns:
- the value of
android.notification.sound
field, or null if absent.
-
tag
Sets theandroid.notification.tag
field.- Parameters:
tag
- A string to be used for theandroid.notification.tag
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
tag
Gets the value ofandroid.notification.tag
field.- Returns:
- the value of
android.notification.tag
field, or null if absent.
-
color
Sets theandroid.notification.color
field.- Parameters:
color
- A string to be used for theandroid.notification.color
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
color
Gets the value ofandroid.notification.color
field.- Returns:
- the value of
android.notification.color
field, or null if absent.
-
clickAction
Sets theandroid.notification.click_action
field.- Parameters:
clickAction
- A string to be used for theandroid.notification.click_action
field value, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
clickAction
Gets the value ofandroid.notification.click_action
field.- Returns:
- the value of
android.notification.click_action
field, or null if absent.
-
data
Sets sub-fields of theandroid.data
field.- Parameters:
data
- A map to be used for sub-fields of theandroid.data
field, or null to clear it.- Returns:
- this MpnBuilder object, for fluent use.
-
data
Gets sub-fields of theandroid.data
field.- Returns:
- A map with sub-fields of the
android.data
field, or null if absent.
-