Class 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 Detail

      • AsyncUraTripReader

        public AsyncUraTripReader​(URL url,
                                  Consumer<Trip> consumer)
        Initialize trip reader.
        Parameters:
        url - URL to read trips from.
        consumer - Initial consumer.
      • AsyncUraTripReader

        public AsyncUraTripReader​(URL url,
                                  List<Consumer<Trip>> consumers)
        Initialize trip reader.
        Parameters:
        url - URL to read trips from.
        consumers - Initial list of consumers.
    • Method Detail

      • open

        public void open()
      • 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