com.urbanairship.api.customevents.parse.CustomEventBodySerializer 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.customevents.parse;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.urbanairship.api.customevents.model.CustomEventBody;
import java.io.IOException;
public class CustomEventBodySerializer extends JsonSerializer {
@Override
public void serialize(CustomEventBody body, JsonGenerator jgen, SerializerProvider provider) throws IOException {
jgen.writeStartObject();
jgen.writeStringField("name", body.getName());
if (body.getSessionId().isPresent()) {
jgen.writeStringField("session_id", body.getSessionId().get());
}
if (body.getInteractionId().isPresent()) {
jgen.writeStringField("interaction_id", body.getInteractionId().get());
}
if (body.getInteractionType().isPresent()) {
jgen.writeStringField("interaction_type", body.getInteractionType().get());
}
if (body.getTransaction().isPresent()) {
jgen.writeStringField("transaction", body.getTransaction().get());
}
if (body.getProperties().isPresent()) {
jgen.writeObjectField("properties", body.getProperties().get());
}
if (body.getValue().isPresent()) {
jgen.writeObjectField("value", body.getValue().get());
}
jgen.writeEndObject();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy