@Test public void testToStream() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int size = list.stream() .collect(MessageCollectors.toStream(baos, new JsonSerializer())); assertThat(baos.size(), is(size)); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); List<CompactFields> out = MessageStreams.stream(bais, new JsonSerializer(), CompactFields.kDescriptor) .collect(Collectors.toList()); assertThat(out, is(equalTo(list))); }
@Nonnull public static <Message extends PMessage<Message, Field>, Field extends PField> Stream<Message> stream(InputStream in, Serializer serializer, PMessageDescriptor<Message, Field> descriptor) { return StreamSupport.stream(new MessageSpliterator<>(in, serializer, descriptor), false); }
MessageStreams { @Nonnull public static <Message extends PMessage<Message, Field>, Field extends PField> Stream<Message> stream(InputStream in, Serializer serializer, PMessageDescriptor<Message, Field> descriptor) { return StreamSupport.stream(new MessageSpliterator<>(in, serializer, descriptor), false); } }
MessageStreams { @Nonnull public static <Message extends PMessage<Message, Field>, Field extends PField> Stream<Message> stream(InputStream in, Serializer serializer, PMessageDescriptor<Message, Field> descriptor) { return StreamSupport.stream(new MessageSpliterator<>(in, serializer, descriptor), false); }  }
MessageStreams { @Nonnull public static <Message extends PMessage<Message, Field>, Field extends PField> Stream<Message> stream(InputStream in, Serializer serializer, PMessageDescriptor<Message, Field> descriptor) { return StreamSupport.stream(new MessageSpliterator<>(in, serializer, descriptor), false); }  @Nonnull static Stream<Message> path(Path file,
                         Serializer serializer,
                         PMessageDescriptor<Message, Field> descriptor); @Nonnull static Stream<Message> file(File file,
                         Serializer serializer,
                         PMessageDescriptor<Message, Field> descriptor); @Nonnull static Stream<Message> resource(@Nonnull String resource,
                             @Nonnull Serializer serializer,
                             @Nonnull PMessageDescriptor<Message, Field> descriptor); @Nonnull static Stream<Message> stream(InputStream in,
                           Serializer serializer,
                           PMessageDescriptor<Message, Field> descriptor); }
MessageStreams { @Nonnull public static <Message extends PMessage<Message, Field>, Field extends PField> Stream<Message> stream(InputStream in, Serializer serializer, PMessageDescriptor<Message, Field> descriptor) { return StreamSupport.stream(new MessageSpliterator<>(in, serializer, descriptor), false); }  @Nonnull static Stream<Message> path(Path file,
                         Serializer serializer,
                         PMessageDescriptor<Message, Field> descriptor); @Nonnull static Stream<Message> file(File file,
                         Serializer serializer,
                         PMessageDescriptor<Message, Field> descriptor); @Nonnull static Stream<Message> resource(@Nonnull String resource,
                             @Nonnull Serializer serializer,
                             @Nonnull PMessageDescriptor<Message, Field> descriptor); @Nonnull static Stream<Message> stream(InputStream in,
                           Serializer serializer,
                           PMessageDescriptor<Message, Field> descriptor);  }