com.urbanairship.connect.client.model.responses.SendEvent 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.gson.JsonObject;
import com.google.gson.annotations.SerializedName;
import com.urbanairship.connect.client.model.EventType;
import com.urbanairship.connect.client.model.GsonUtil;
public class SendEvent implements EventBody {
@SerializedName("push_id")
private final String pushId;
@SerializedName("group_id")
private final Optional groupId;
@SerializedName("variant_id")
private final Optional variantId;
private SendEvent() {
this(null, Optional.absent(), Optional.absent());
}
public SendEvent(String pushId, Optional groupId, Optional variantId) {
this.pushId = pushId;
this.groupId = groupId;
this.variantId = variantId;
}
public Optional getVariantId() {
return variantId;
}
public Optional getGroupId() {
return groupId;
}
public String getPushId() {
return pushId;
}
public static SendEvent parseJSONfromBytes(byte[] bytes) {
JsonObject jsonObject = GsonUtil.parseJSONfromBytes(bytes);
return parseJSON(jsonObject.toString());
}
public static SendEvent parseJSON(String json) {
return GsonUtil.getGson().fromJson(json, SendEvent.class);
}
public byte[] serializeToJSONBytes() {
return GsonUtil.serializeToJSONBytes(this, SendEvent.class);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SendEvent)) return false;
SendEvent sendEvent = (SendEvent) o;
if (!groupId.equals(sendEvent.groupId)) return false;
if (!pushId.equals(sendEvent.pushId)) return false;
if (!variantId.equals(sendEvent.variantId)) return false;
return true;
}
@Override
public int hashCode() {
int result = pushId.hashCode();
result = 31 * result + groupId.hashCode();
result = 31 * result + variantId.hashCode();
return result;
}
@Override
public String toString() {
return "SendEvent{" +
"pushId='" + pushId + '\'' +
", groupId=" + groupId +
", variantId=" + variantId +
'}';
}
@Override
public EventType getType() {
return EventType.SEND;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy