com.urbanairship.api.push.model.notification.android.AndroidDevicePayload 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
/*
* Copyright (c) 2013-2016. Urban Airship and Contributors
*/
package com.urbanairship.api.push.model.notification.android;
import com.google.common.base.Optional;
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.Interactive;
import java.util.Map;
public final class AndroidDevicePayload extends PushModelObject implements DevicePayloadOverride {
private final Optional alert;
private final Optional collapseKey;
private final Optional timeToLive;
private final Optional delayWhileIdle;
private final Optional> extra;
private final Optional interactive;
private final Optional title;
private AndroidDevicePayload(Optional alert,
Optional collapseKey,
Optional timeToLive,
Optional delayWhileIdle,
Optional> extra,
Optional interactive,
Optional title) {
this.alert = alert;
this.collapseKey = collapseKey;
this.timeToLive = timeToLive;
this.delayWhileIdle = delayWhileIdle;
this.extra = extra;
this.interactive = interactive;
this.title = title;
}
public static Builder newBuilder() {
return new Builder();
}
@Override
public DeviceType getDeviceType() {
return DeviceType.ANDROID;
}
@Override
public Optional getAlert() {
return alert;
}
public Optional getCollapseKey() {
return collapseKey;
}
public Optional getTimeToLive() {
return timeToLive;
}
public Optional getDelayWhileIdle() {
return delayWhileIdle;
}
public Optional> getExtra() {
return extra;
}
public Optional getInteractive() {
return interactive;
}
public Optional getTitle() {
return title;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AndroidDevicePayload that = (AndroidDevicePayload)o;
if (alert != null ? !alert.equals(that.alert) : that.alert != null) {
return false;
}
if (collapseKey != null ? !collapseKey.equals(that.collapseKey) : that.collapseKey != null) {
return false;
}
if (timeToLive != null ? !timeToLive.equals(that.timeToLive) : that.timeToLive != null) {
return false;
}
if (delayWhileIdle != null ? !delayWhileIdle.equals(that.delayWhileIdle) : that.delayWhileIdle != null) {
return false;
}
if (extra != null ? !extra.equals(that.extra) : that.extra != null) {
return false;
}
if (interactive != null ? !interactive.equals(that.interactive) : that.interactive != null) {
return false;
}
if (title != null ? !title.equals(that.title) : that.title != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = (alert != null ? alert.hashCode() : 0);
result = 31 * result + (collapseKey != null ? collapseKey.hashCode() : 0);
result = 31 * result + (timeToLive != null ? timeToLive.hashCode() : 0);
result = 31 * result + (delayWhileIdle != null ? delayWhileIdle.hashCode() : 0);
result = 31 * result + (extra != null ? extra.hashCode() : 0);
result = 31 * result + (interactive != null ? interactive.hashCode() : 0);
result = 31 * result + (title != null ? title.hashCode() : 0);
return result;
}
public static class Builder {
private String alert = null;
private String collapseKey = null;
private PushExpiry timeToLive = null;
private Boolean delayWhileIdle = null;
private ImmutableMap.Builder extra = null;
private Interactive interactive = null;
private String title = null;
private Builder() { }
public Builder setAlert(String alert) {
this.alert = alert;
return this;
}
public Builder setCollapseKey(String collapseKey) {
this.collapseKey = collapseKey;
return this;
}
public Builder setTimeToLive(PushExpiry value) {
this.timeToLive = value;
return this;
}
public Builder setDelayWhileIdle(boolean value) {
this.delayWhileIdle = value;
return this;
}
public Builder addExtraEntry(String key, String value) {
if (extra == null) {
extra = ImmutableMap.builder();
}
this.extra.put(key, value);
return this;
}
public Builder addAllExtraEntries(Map entries) {
if (extra == null) {
extra = ImmutableMap.builder();
}
this.extra.putAll(entries);
return this;
}
public Builder setInteractive(Interactive value) {
this.interactive = value;
return this;
}
public Builder setTitle(String value) {
this.title = value;
return this;
}
public AndroidDevicePayload build() {
return new AndroidDevicePayload(Optional.fromNullable(alert),
Optional.fromNullable(collapseKey),
Optional.fromNullable(timeToLive),
Optional.fromNullable(delayWhileIdle),
extra == null ? Optional.>absent() : Optional.fromNullable(extra.build()),
Optional.fromNullable(interactive),
Optional.fromNullable(title));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy