io.voucherify.client.json.serializer.AbstractListSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of voucherify-java-sdk Show documentation
Show all versions of voucherify-java-sdk Show documentation
Voucherify-java-sdk is a Java client (can be used in Android application as well) which was created to simplify integration with Voucherify backend (http://www.voucherify.io)
package io.voucherify.client.json.serializer;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
import java.util.List;
public abstract class AbstractListSerializer extends JsonSerializer {
@Override
public void serialize(T value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
if (value == null) {
return;
}
List items = getList(value);
if (items == null) {
return;
}
jgen.writeStartArray();
for (R item : items) {
if (item != null) {
jgen.writeObject(item);
}
}
jgen.writeEndArray();
}
protected abstract List getList(T value);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy