com.urbanairship.api.push.model.notification.web.WebDevicePayload Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client Show documentation
Show all versions of java-client Show documentation
The Urban Airship Java client library
package com.urbanairship.api.push.model.notification.web;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.urbanairship.api.push.model.DeviceType;
import com.urbanairship.api.push.model.PushExpiry;
import com.urbanairship.api.push.model.PushModelObject;
import com.urbanairship.api.push.model.notification.DevicePayloadOverride;
import com.urbanairship.api.push.model.notification.actions.Actions;
import java.util.Map;
import java.util.Optional;
/**
* Represents the payload to be used for sending to web devices.
*/
public final class WebDevicePayload extends PushModelObject implements DevicePayloadOverride{
private final Optional alert;
private final Optional title;
private final Optional> extra;
private final Optional webIcon;
private final Optional requireInteraction;
private final Optional actions;
private final Optional webImage;
private final Optional expiry;
private final Optional> buttons;
private final Optional template;
private WebDevicePayload(Builder builder) {
this.alert = Optional.ofNullable(builder.alert);
this.title = Optional.ofNullable(builder.title);
this.webIcon = Optional.ofNullable(builder.webIcon);
this.requireInteraction = Optional.ofNullable(builder.requireInteraction);
this.actions = Optional.ofNullable(builder.actions);
this.webImage = Optional.ofNullable(builder.webImage);
this.expiry = Optional.ofNullable(builder.expiry);
this.template = Optional.ofNullable(builder.webTemplate);
if (builder.buttons.build().isEmpty()) {
this.buttons = Optional.empty();
} else {
this.buttons = Optional.of(builder.buttons.build());
}
if (builder.extra.build().isEmpty()) {
this.extra = Optional.empty();
} else {
this.extra = Optional.of(builder.extra.build());
}
}
/**
* New WebDevicePayload Builder.
*
* @return Builder
*/
public static Builder newBuilder() {
return new Builder();
}
/**
* Get the device type.
*
* @return DeviceType.WEB
*/
@Override
public DeviceType getDeviceType() {
return DeviceType.WEB;
}
/**
* Get the alert.
*
* @return Optional String alert
*/
@Override
public Optional getAlert() {
return alert;
}
/**
* Get the title.
*
* @return Optional String title
*/
public Optional getTitle() {
return title;
}
/**
* Get an extra mapping of key-value pairs.
*
* @return Optional ImmutableMap of Strings
*/
public Optional> getExtra() {
return extra;
}
/**
* Get the web icon that describes an icon to be used with the web alert.
*
* @return Optional WebIcon object
*/
public Optional getWebIcon() {
return webIcon;
}
/**
* Get the Require Interaction flag.
*
* @return Optional Boolean require interaction flag.
*/
public Optional getRequireInteraction() {
return requireInteraction;
}
/**
* Get the Actions.
* Describes Actions to be performed by the SDK when a user interacts with the notification.
*
* @return Optional Actions
*/
public Optional getActions() {
return actions;
}
/**
* Get the WebImage object.
* A object that describes an image to be used with the web alert.
*
* @return Optional WebImage
*/
public Optional getWebImage() {
return webImage;
}
/**
* Get the PushExpiry
* Delivery expiration, as either absolute ISO UTC timestamp, or number of seconds from now.
*
* @return Optional PushExpiry
*/
public Optional getExpiry() {
return expiry;
}
/**
* Get the List of buttons.
* Contains one or two buttons that perform actions for the web notification.
* If you do not specify actions for a button, the button closes the notification without performing an action.
*
* @return Optional ImmutableList of Button objects.
*/
public Optional> getButtons() {
return buttons;
}
/**
* Get the template with web-specific message.
*
* @return Optional WebTemplate
*/
public Optional getTemplate() {
return template;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
WebDevicePayload payload = (WebDevicePayload) o;
return Objects.equal(alert, payload.alert) &&
Objects.equal(title, payload.title) &&
Objects.equal(extra, payload.extra) &&
Objects.equal(webIcon, payload.webIcon)&&
Objects.equal(requireInteraction, payload.requireInteraction) &&
Objects.equal(actions, payload.actions) &&
Objects.equal(webImage, payload.webImage) &&
Objects.equal(expiry, payload.expiry) &&
Objects.equal(buttons, payload.buttons) &&
Objects.equal(template, payload.template);
}
@Override
public int hashCode() {
return Objects.hashCode(alert, title, extra, webIcon,
requireInteraction, actions, webImage, expiry, buttons, template);
}
@Override
public String toString() {
return "WebDevicePayload{" +
"alert=" + alert +
", title=" + title +
", extra=" + extra +
", webIcon=" + webIcon +
", requireInteraction=" + requireInteraction +
", actions=" + actions +
", webImage=" + webImage +
", expiry=" + expiry +
", buttons=" + buttons +
", template=" + template +
'}';
}
/**
* WebDevicePayload Builder.
*/
public static class Builder {
private String alert = null;
private String title = null;
private ImmutableMap.Builder extra = ImmutableMap.builder();
private WebIcon webIcon = null;
private Boolean requireInteraction = null;
private Actions actions = null;
private WebImage webImage = null;
private PushExpiry expiry = null;
private ImmutableList.Builder
© 2015 - 2024 Weber Informatics LLC | Privacy Policy