
com.urbanairship.connect.client.model.responses.InAppMessageExpirationEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of connect-client Show documentation
Show all versions of connect-client Show documentation
The UA Connect Java client library
/*
Copyright 2015 Urban Airship and Contributors
*/
package com.urbanairship.connect.client.model.responses;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import com.urbanairship.connect.client.model.EventType;
import com.urbanairship.connect.client.model.GsonUtil;
import org.joda.time.DateTime;
public class InAppMessageExpirationEvent implements EventBody {
public static final String REPLACED = "REPLACED";
public static final String EXPIRED = "EXPIRED";
public static final String ALREADY_DISPLAYED = "ALREADY_DISPLAYED";
public static final ImmutableSet VALID_TYPES = ImmutableSet.of(REPLACED, EXPIRED, ALREADY_DISPLAYED);
@SerializedName("push_id")
private final String pushId;
@SerializedName("group_id")
private final Optional groupId;
@SerializedName("variant_id")
private final Optional variantId;
@SerializedName("time_sent")
private final Optional timeSent;
@SerializedName("triggering_push")
private final Optional triggeringPush;
private final String type;
@SerializedName("time_expired")
private final Optional timeExpired;
@SerializedName("replacing_push")
private final Optional replacingPush;
@SerializedName("session_id")
private final Optional sessionId;
public static InAppMessageExpirationEvent parseJSONfromBytes(byte[] bytes) {
JsonObject jsonObject = GsonUtil.parseJSONfromBytes(bytes);
return parseJSON(jsonObject.toString());
}
public static InAppMessageExpirationEvent parseJSON(String json) {
return GsonUtil.getGson().fromJson(json, InAppMessageExpirationEvent.class);
}
public byte[] serializeToJSONBytes() {
return GsonUtil.serializeToJSONBytes(this, InAppMessageExpirationEvent.class);
}
public static class Builder {
private String pushId;
private Optional groupId = Optional.absent();
private Optional variantId = Optional.absent();
private Optional timeSent = Optional.absent();
private Optional triggeringPush = Optional.absent();
private String type;
private Optional timeExpired = Optional.absent();
private Optional replacingPush = Optional.absent();
private Optional sessionId = Optional.absent();
public Builder setPushId(String pushId) {
this.pushId = pushId;
return this;
}
public Builder setGroupId(String groupId) {
this.groupId = Optional.of(groupId);
return this;
}
public Builder setVariantId(int variantId) {
this.variantId = Optional.of(variantId);
return this;
}
public Builder setTimeSent(DateTime timeSent) {
this.timeSent = Optional.of(timeSent);
return this;
}
public Builder setTriggeringPush(AssociatedPush triggeringPush) {
this.triggeringPush = Optional.of(triggeringPush);
return this;
}
public Builder setType(String type) {
this.type = type;
return this;
}
public Builder setTimeExpired(DateTime timeExpired) {
this.timeExpired = Optional.of(timeExpired);
return this;
}
public Builder setReplacingPush(AssociatedPush replacingPush) {
this.replacingPush = Optional.of(replacingPush);
return this;
}
public Builder setSessionId(String sessionId) {
this.sessionId = Optional.of(sessionId);
return this;
}
public InAppMessageExpirationEvent build() {
Preconditions.checkNotNull(pushId);
Preconditions.checkNotNull(type);
Preconditions.checkState(VALID_TYPES.contains(type));
return new InAppMessageExpirationEvent(pushId, groupId, variantId, timeSent, triggeringPush, type, timeExpired, replacingPush, sessionId);
}
}
public InAppMessageExpirationEvent(String pushId, Optional groupId, Optional variantId, Optional timeSent, Optional triggeringPush, String type, Optional timeExpired, Optional replacingPush, Optional sessionId) {
this.pushId = pushId;
this.groupId = groupId;
this.variantId = variantId;
this.timeSent = timeSent;
this.triggeringPush = triggeringPush;
this.type = type;
this.timeExpired = timeExpired;
this.replacingPush = replacingPush;
this.sessionId = sessionId;
}
private InAppMessageExpirationEvent() {
this(null, Optional.absent(), Optional.absent(), Optional.absent(), Optional.absent(), null, Optional.absent(),
Optional.absent(), Optional.absent());
}
@Override
public EventType getType() {
return EventType.IN_APP_MESSAGE_EXPIRATION;
}
public String getExpirationType() {
return type;
}
public String getPushId() {
return pushId;
}
public Optional getGroupId() {
return groupId;
}
public Optional getVariantId() {
return variantId;
}
public Optional getTimeSent() {
return timeSent;
}
public Optional getTriggeringPush() {
return triggeringPush;
}
public Optional getTimeExpired() {
return timeExpired;
}
public Optional getReplacingPush() {
return replacingPush;
}
public Optional getSessionId() {
return sessionId;
}
@Override
public String toString() {
return "InAppMessageExpirationEvent{" +
"pushId='" + pushId + '\'' +
", groupId=" + groupId +
", variantId=" + variantId +
", timeSent=" + timeSent +
", triggeringPush=" + triggeringPush +
", type='" + type + '\'' +
", timeExpired=" + timeExpired +
", replacingPush=" + replacingPush +
", sessionId=" + sessionId +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final InAppMessageExpirationEvent that = (InAppMessageExpirationEvent) o;
if (getPushId() != null ? !getPushId().equals(that.getPushId()) : that.getPushId() != null) return false;
if (getGroupId() != null ? !getGroupId().equals(that.getGroupId()) : that.getGroupId() != null) return false;
if (getVariantId() != null ? !getVariantId().equals(that.getVariantId()) : that.getVariantId() != null)
return false;
if (getTimeSent() != null ? !getTimeSent().equals(that.getTimeSent()) : that.getTimeSent() != null)
return false;
if (getTriggeringPush() != null ? !getTriggeringPush().equals(that.getTriggeringPush()) : that.getTriggeringPush() != null)
return false;
if (getType() != null ? !getType().equals(that.getType()) : that.getType() != null) return false;
if (getTimeExpired() != null ? !getTimeExpired().equals(that.getTimeExpired()) : that.getTimeExpired() != null)
return false;
if (getReplacingPush() != null ? !getReplacingPush().equals(that.getReplacingPush()) : that.getReplacingPush() != null)
return false;
return getSessionId() != null ? getSessionId().equals(that.getSessionId()) : that.getSessionId() == null;
}
@Override
public int hashCode() {
int result = getPushId() != null ? getPushId().hashCode() : 0;
result = 31 * result + (getGroupId() != null ? getGroupId().hashCode() : 0);
result = 31 * result + (getVariantId() != null ? getVariantId().hashCode() : 0);
result = 31 * result + (getTimeSent() != null ? getTimeSent().hashCode() : 0);
result = 31 * result + (getTriggeringPush() != null ? getTriggeringPush().hashCode() : 0);
result = 31 * result + (getType() != null ? getType().hashCode() : 0);
result = 31 * result + (getTimeExpired() != null ? getTimeExpired().hashCode() : 0);
result = 31 * result + (getReplacingPush() != null ? getReplacingPush().hashCode() : 0);
result = 31 * result + (getSessionId() != null ? getSessionId().hashCode() : 0);
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy