Class EventStream<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    java.lang.AutoCloseable

    public final class EventStream<T>
    extends java.lang.Object
    implements java.lang.AutoCloseable
    • Constructor Summary

      Constructors 
      Constructor Description
      EventStream​(java.io.InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      java.util.Optional<T> next()
      Returns the next message.
      java.util.stream.Stream<T> stream()
      Returns a Stream of events.
      java.util.List<T> toList()
      Reads all events and returns them as a List.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EventStream

        public EventStream​(java.io.InputStream in,
                           com.fasterxml.jackson.core.type.TypeReference<T> typeReference,
                           com.fasterxml.jackson.databind.ObjectMapper mapper)
    • Method Detail

      • next

        public java.util.Optional<T> next()
                                   throws java.io.IOException
        Returns the next message. If another message does not exist returns Optional.empty().
        Returns:
        the next message or Optional.empty() if no more messages
        Throws:
        java.io.IOException
      • toList

        public java.util.List<T> toList()
        Reads all events and returns them as a List. This method calls close().
        Returns:
        list of events
      • stream

        public java.util.stream.Stream<T> stream()
        Returns a Stream of events. Must be closed after use!
        Returns:
        streamed events
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception