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

io.prestosql.jdbc.$internal.jackson.datatype.jdk8.DoubleStreamSerializer Maven / Gradle / Ivy

There is a newer version: 350
Show newest version
package io.prestosql.jdbc.$internal.jackson.datatype.jdk8;

import io.prestosql.jdbc.$internal.jackson.core.JsonGenerator;
import io.prestosql.jdbc.$internal.jackson.databind.SerializerProvider;
import io.prestosql.jdbc.$internal.jackson.databind.ser.std.StdSerializer;

import java.io.IOException;
import java.util.stream.DoubleStream;

/**
 * {@link DoubleStream} serializer
 * 

* Unfortunately there to common ancestor between number base stream, * so we need to define each in a specific class *

*/ public class DoubleStreamSerializer extends StdSerializer { private static final long serialVersionUID = 1L; /** * Singleton instance */ public static final DoubleStreamSerializer INSTANCE = new DoubleStreamSerializer(); /** * Constructor */ private DoubleStreamSerializer() { super(DoubleStream.class); } @Override public void serialize(DoubleStream stream, JsonGenerator jgen, SerializerProvider provider) throws IOException { try(DoubleStream ds = stream) { jgen.writeStartArray(); ds.forEachOrdered(value -> { try { jgen.writeNumber(value); } catch (IOException e) { throw new WrappedIOException(e); } }); jgen.writeEndArray(); } catch (WrappedIOException e) { throw e.getCause(); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy