Package de.stklcode.pubtrans.ura.reader
Class AsyncUraTripReader
java.lang.Object
de.stklcode.pubtrans.ura.reader.AsyncUraTripReader
- All Implemented Interfaces:
AutoCloseable
Asynchronous stream reader for URA stream API.
This reader provides a handler for asynchronous stream events.
- Since:
- 1.2.0
- Author:
- Stefan Kalscheuer
-
Constructor Summary
ConstructorsConstructorDescriptionAsyncUraTripReader(URI uri, UraClientConfiguration config, List<Consumer<Trip>> consumers) Initialize trip reader.AsyncUraTripReader(URI uri, Consumer<Trip> consumer) Initialize trip reader.AsyncUraTripReader(URI uri, List<Consumer<Trip>> consumers) Initialize trip reader. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConsumer(Consumer<Trip> consumer) Register an additional consumer.voidclose()Close the reader.voidopen()Open the reader, i.e. initiate connection to the API and start reading the response stream.
-
Constructor Details
-
AsyncUraTripReader
Initialize trip reader. -
AsyncUraTripReader
Initialize trip reader. -
AsyncUraTripReader
Initialize trip reader.- Parameters:
uri- URL to read trips from.config- Client configuration for additional parameters.consumers- Initial list of consumers.- Since:
- 2.0 Configuration added.
-
-
Method Details
-
open
public void open()Open the reader, i.e. initiate connection to the API and start reading the response stream. -
addConsumer
Register an additional consumer.- Parameters:
consumer- New consumer.
-
close
public void close()Close the reader. This is done by signaling cancel to the asynchronous task. If the task is not completed within 1 second however it is canceled hard.- Specified by:
closein interfaceAutoCloseable
-