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(URL url, Consumer<Trip> consumer) Initialize trip reader.AsyncUraTripReader(URL url, List<Consumer<Trip>> consumers) Initialize trip reader. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConsumer(Consumer<Trip> consumer) Register an additional consumer.voidclose()Close the reader.voidopen()
-
Constructor Details
-
AsyncUraTripReader
Initialize trip reader.- Parameters:
url- URL to read trips from.consumer- Initial consumer.
-
AsyncUraTripReader
Initialize trip reader.- Parameters:
url- URL to read trips from.consumers- Initial list of consumers.
-
-
Method Details
-
open
public void open() -
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
-