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

com.codepoetics.octarine.json.serialisation.ListSerialiser Maven / Gradle / Ivy

There is a newer version: 0.18
Show newest version
package com.codepoetics.octarine.json.serialisation;

import com.fasterxml.jackson.core.JsonGenerator;

import java.io.IOException;
import java.util.Collection;

public final class ListSerialiser implements SafeSerialiser> {
    public static  ListSerialiser writingItemsWith(Serialiser itemSerialiser) {
        return new ListSerialiser<>(itemSerialiser);
    }

    private final Serialiser itemSerialiser;

    private ListSerialiser(Serialiser itemSerialiser) {
        this.itemSerialiser = itemSerialiser;
    }

    @Override
    public void unsafeAccept(JsonGenerator j, Collection ts) throws IOException {
        j.writeStartArray();
        ts.forEach(t -> itemSerialiser.accept(j, t));
        j.writeEndArray();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy