com.urbanairship.api.experiments.parse.VariantSerializer 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-2017. Urban Airship and Contributors
*/
package com.urbanairship.api.experiments.parse;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.urbanairship.api.experiments.model.Variant;
import java.io.IOException;
public class VariantSerializer extends JsonSerializer {
@Override
public void serialize(Variant variant, JsonGenerator jgen, SerializerProvider provider) throws IOException {
jgen.writeStartObject();
if (variant.getName().isPresent()) {
jgen.writeObjectField("name", variant.getName().get());
}
if (variant.getDescription().isPresent()) {
jgen.writeObjectField("description", variant.getDescription().get());
}
if (variant.getSchedule().isPresent()) {
jgen.writeObjectField("schedule", variant.getSchedule().get());
}
if (variant.getWeight().isPresent()) {
jgen.writeObjectField("weight", variant.getWeight().get());
}
jgen.writeObjectField("push", variant.getVariantPushPayload());
jgen.writeEndObject();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy