Class RangePublisher

  • All Implemented Interfaces:
    Publisher<java.lang.Integer>

    public final class RangePublisher
    extends java.lang.Object
    implements Publisher<java.lang.Integer>
    A synchronous implementation of the Publisher that can be subscribed to multiple times and each individual subscription will receive range of monotonically increasing integer values on demand.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  RangePublisher.RangeSubscription
      A Subscription implementation that holds the current downstream requested amount and responds to the downstream's request() and cancel() calls.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int count
      The number of items to emit.
      (package private) int start
      The starting value of the range.
    • Constructor Summary

      Constructors 
      Constructor Description
      RangePublisher​(int start, int count)
      Constructs a RangePublisher instance with the given start and count values that yields a sequence of [start, start + count).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void subscribe​(Subscriber<? super java.lang.Integer> subscriber)
      Request Publisher to start streaming data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • start

        final int start
        The starting value of the range.
      • count

        final int count
        The number of items to emit.
    • Constructor Detail

      • RangePublisher

        public RangePublisher​(int start,
                              int count)
        Constructs a RangePublisher instance with the given start and count values that yields a sequence of [start, start + count).
        Parameters:
        start - the starting value of the range
        count - the number of items to emit