Class AsyncUraTripReader

java.lang.Object
de.stklcode.pubtrans.ura.reader.AsyncUraTripReader
All Implemented Interfaces:
AutoCloseable

public class AsyncUraTripReader extends Object implements 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 Details

    • AsyncUraTripReader

      public AsyncUraTripReader(URI uri, Consumer<Trip> consumer)
      Initialize trip reader.
      Parameters:
      uri - URL to read trips from.
      consumer - Initial consumer.
      Since:
      2.0 Parameter of Type URI instead of URL.
    • AsyncUraTripReader

      public AsyncUraTripReader(URI uri, List<Consumer<Trip>> consumers)
      Initialize trip reader.
      Parameters:
      uri - URL to read trips from.
      consumers - Initial list of consumers.
      Since:
      2.0 Parameter of Type URI instead of URL.
    • AsyncUraTripReader

      public AsyncUraTripReader(URI uri, UraClientConfiguration config, List<Consumer<Trip>> consumers)
      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

      public void addConsumer(Consumer<Trip> consumer)
      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:
      close in interface AutoCloseable