com.unblu.webapi.model.v3.ExpandableFieldSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of models-v3 Show documentation
Show all versions of models-v3 Show documentation
Java classes corresponding to the JSON bodies
package com.unblu.webapi.model.v3;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
public class ExpandableFieldSerializer extends JsonSerializer> {
@Override
public void serialize(final ExpandableField> value, final JsonGenerator gen, final SerializerProvider serializers) throws IOException {
if (value == null) {
gen.writeNull();
} else if (value.isExpanded()) {
gen.writeObject(value.getExpanded());
} else {
gen.writeString(value.getId());
}
}
}