com.lightstreamer.client.mpn.MpnBuilder Maven / Gradle / Ivy
package com.lightstreamer.client.mpn;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import com.lightstreamer.client.mpn.LSMpnBuilder;
/**
* 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 {@link MpnSubscription#setNotificationFormat(String)}.
*
* @see MpnSubscription#setNotificationFormat(String)
*/
public class MpnBuilder {
final LSMpnBuilder delegate;
/**
* 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.
*/
public MpnBuilder() {
this.delegate = new LSMpnBuilder();
}
/**
* Creates an object based on the specified push notification format.
* Use getter methods to obtain the value of push notification fields.
*
* @param notificationFormat A JSON structure representing a push notification format.
*
* @throws IllegalArgumentException if the notification is not a valid JSON structure.
*/
@SuppressWarnings("unchecked")
public MpnBuilder(@Nonnull String notificationFormat) {
this.delegate = new LSMpnBuilder(notificationFormat);
}
/**
* Produces the JSON structure for the push notification format specified by this object.
* @return the JSON structure for the push notification format.
*/
public @Nonnull String build() {
return delegate.build();
}
/**
* Sets the android.collapse_key
field.
*
* @param collapseKey A string to be used for the android.collapse_key
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder collapseKey(String collapseKey) {
delegate.collapseKey(collapseKey);
return this;
}
/**
* Gets the value of android.collapse_key
field.
* @return the value of android.collapse_key
field, or null if absent.
*/
public String collapseKey() {
return delegate.collapseKey();
}
/**
* Sets the android.priority
field.
*
* @param priority A string to be used for the android.priority
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder priority(String priority) {
delegate.priority(priority);
return this;
}
/**
* Gets the value of android.priority
field.
* @return the value of android.priority
field, or null if absent.
*/
public String priority() {
return delegate.priority();
}
/**
* Sets the android.ttl
field with a string value.
*
* @param timeToLive A string to be used for the android.ttl
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder timeToLive(String timeToLive) {
delegate.timeToLive(timeToLive);
return this;
}
/**
* Gets the value of android.ttl
field as a string.
* @return a string with the value of android.ttl
field, or null if absent.
*/
public String timeToLiveAsString() {
return delegate.timeToLiveAsString();
}
/**
* Sets the android.ttl
field with an integer value.
*
* @param timeToLive An integer to be used for the android.ttl
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder timeToLive(Integer timeToLive) {
delegate.timeToLive(timeToLive);
return this;
}
/**
* Gets the value of android.ttl
field as an integer.
* @return an integer with the value of android.ttl
field, or null if absent.
*/
public Integer timeToLiveAsInteger() {
return delegate.timeToLiveAsInteger();
}
/**
* Sets the android.notification.title
field.
*
* @param title A string to be used for the android.notification.title
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder title(String title) {
delegate.title(title);
return this;
}
/**
* Gets the value of android.notification.title
field.
* @return the value of android.notification.title
field, or null if absent.
*/
public String title() {
return delegate.title();
}
/**
* Sets the android.notification.title_loc_key
field.
*
* @param titleLocKey A string to be used for the android.notification.title_loc_key
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder titleLocKey(String titleLocKey) {
delegate.titleLocKey(titleLocKey);
return this;
}
/**
* Gets the value of android.notification.title_loc_key
field.
* @return the value of android.notification.title_loc_key
field, or null if absent.
*/
public String titleLocKey() {
return delegate.titleLocKey();
}
/**
* Sets the android.notification.title_loc_args
field.
*
* @param titleLocArguments A list of strings to be used for the android.notification.title_loc_args
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder titleLocArguments(List titleLocArguments) {
delegate.titleLocArguments(titleLocArguments);
return this;
}
/**
* Gets the value of android.notification.title_loc_args
field.
* @return a list of strings with the value of android.notification.title_loc_args
field, or null if absent.
*/
public List titleLocArguments() {
return delegate.titleLocArguments();
}
/**
* Sets the android.notification.body
field.
*
* @param body A string to be used for the android.notification.body
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder body(String body) {
delegate.body(body);
return this;
}
/**
* Gets the value of android.notification.body
field.
* @return the value of android.notification.body
field, or null if absent.
*/
public String body() {
return delegate.body();
}
/**
* Sets the android.notification.body_loc_key
field.
*
* @param bodyLocKey A string to be used for the android.notification.body_loc_key
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder bodyLocKey(String bodyLocKey) {
delegate.bodyLocKey(bodyLocKey);
return this;
}
/**
* Gets the value of android.notification.body_loc_key
field.
* @return the value of android.notification.body_loc_key
field, or null if absent.
*/
public String bodyLocKey() {
return delegate.bodyLocKey();
}
/**
* Sets the android.notification.body_loc_args
field.
*
* @param bodyLocArguments A list of strings to be used for the android.notification.body_loc_args
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder bodyLocArguments(List bodyLocArguments) {
delegate.bodyLocArguments(bodyLocArguments);
return this;
}
/**
* Gets the value of android.notification.body_loc_args
field.
* @return a list of strings with the value of android.notification.body_loc_args
field, or null if absent.
*/
public List bodyLocArguments() {
return delegate.bodyLocArguments();
}
/**
* Sets the android.notification.icon
field.
*
* @param icon A string to be used for the android.notification.icon
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder icon(String icon) {
delegate.icon(icon);
return this;
}
/**
* Gets the value of android.notification.icon
field.
* @return the value of android.notification.icon
field, or null if absent.
*/
public String icon() {
return delegate.icon();
}
/**
* Sets the android.notification.sound
field.
*
* @param sound A string to be used for the android.notification.sound
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder sound(String sound) {
delegate.sound(sound);
return this;
}
/**
* Gets the value of android.notification.sound
field.
* @return the value of android.notification.sound
field, or null if absent.
*/
public String sound() {
return delegate.sound();
}
/**
* Sets the android.notification.tag
field.
*
* @param tag A string to be used for the android.notification.tag
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder tag(String tag) {
delegate.tag(tag);
return this;
}
/**
* Gets the value of android.notification.tag
field.
* @return the value of android.notification.tag
field, or null if absent.
*/
public String tag() {
return delegate.tag();
}
/**
* Sets the android.notification.color
field.
*
* @param color A string to be used for the android.notification.color
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder color(String color) {
delegate.color(color);
return this;
}
/**
* Gets the value of android.notification.color
field.
* @return the value of android.notification.color
field, or null if absent.
*/
public String color() {
return delegate.color();
}
/**
* Sets the android.notification.click_action
field.
*
* @param clickAction A string to be used for the android.notification.click_action
field value, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder clickAction(String clickAction) {
delegate.clickAction(clickAction);
return this;
}
/**
* Gets the value of android.notification.click_action
field.
* @return the value of android.notification.click_action
field, or null if absent.
*/
public String clickAction() {
return delegate.clickAction();
}
/**
* Sets sub-fields of the android.data
field.
*
* @param data A map to be used for sub-fields of the android.data
field, or null to clear it.
* @return this MpnBuilder object, for fluent use.
*/
public MpnBuilder data(Map data) {
delegate.data(data);
return this;
}
/**
* Gets sub-fields of the android.data
field.
* @return A map with sub-fields of the android.data
field, or null if absent.
*/
public Map data() {
return delegate.data();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy