All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.voucherify.client.json.serializer.AbstractListSerializer Maven / Gradle / Ivy

Go to download

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)

There is a newer version: 16.0.2
Show newest version
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