Package com.styra.opa.openapi.utils
Class EventStream<T>
java.lang.Object
com.styra.opa.openapi.utils.EventStream<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionEventStream
(InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper, Optional<String> terminalMessage) -
Method Summary
-
Constructor Details
-
EventStream
public EventStream(InputStream in, com.fasterxml.jackson.core.type.TypeReference<T> typeReference, com.fasterxml.jackson.databind.ObjectMapper mapper, Optional<String> terminalMessage)
-
-
Method Details
-
next
Returns the next message. If another message does not exist returnsOptional.empty()
.- Returns:
- the next message or
Optional.empty()
if no more messages - Throws:
IOException
-
toList
Reads all events and returns them as aList
. This method callsclose()
.- Returns:
- list of events
-
stream
Returns aStream
of events. Must be closed after use!- Returns:
- streamed events
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-