src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <TOpening, TClosing, U extends Collection<? super T>> Observable<U> buffer(
            ObservableSource<? extends TOpening> openingIndicator,
            Function<? super TOpening, ? extends ObservableSource<? extends TClosing>> closingIndicator,
            Callable<U> bufferSupplier) {
        ObjectHelper.requireNonNull(openingIndicator, "openingIndicator is null");
        ObjectHelper.requireNonNull(closingIndicator, "closingIndicator is null");
        ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
        return RxJavaPlugins.onAssembly(new ObservableBufferBoundary<T, U, TOpening, TClosing>(this, openingIndicator, closingIndicator, bufferSupplier));
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <TOpening, TClosing, U extends Collection<? super T>> Observable<U> buffer(
            ObservableSource<? extends TOpening> openingIndicator,
            Function<? super TOpening, ? extends ObservableSource<? extends TClosing>> closingIndicator,
            Callable<U> bufferSupplier) {
        ObjectHelper.requireNonNull(openingIndicator, "openingIndicator is null");
        ObjectHelper.requireNonNull(closingIndicator, "closingIndicator is null");
        ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null");
        return RxJavaPlugins.onAssembly(new ObservableBufferBoundary<T, U, TOpening, TClosing>(this, openingIndicator, closingIndicator, bufferSupplier));
    }
Returns an Observable that emits buffers of items it collects from the source ObservableSource. The resulting
ObservableSource emits buffers that it creates when the specified {@code openingIndicator} ObservableSource emits an
item, and closes when the ObservableSource returned from {@code closingIndicator} emits an item. If any of the
source ObservableSource, {@code openingIndicator} or {@code closingIndicator} issues an onError notification the
event is passed on immediately without first emitting the buffer it is in the process of assembling.
<p>
<img width="640" height="470" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/buffer2.png" alt="">
<dl>
<dt><b>Scheduler:</b></dt>
<dd>This version of {@code buffer} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>

@param <U> the collection subclass type to buffer into
@param <TOpening> the element type of the buffer-opening ObservableSource
@param <TClosing> the element type of the individual buffer-closing ObservableSources
@param openingIndicator
the ObservableSource that, when it emits an item, causes a new buffer to be created
@param closingIndicator
the {@link Function} that is used to produce an ObservableSource for every buffer created. When this
ObservableSource emits an item, the associated buffer is emitted.
@param bufferSupplier
a factory function that returns an instance of the collection subclass to be used and returned
as the buffer
@return an Observable that emits buffers, containing items from the source ObservableSource, that are created
and closed when the specified ObservableSources emit items
@see <a href="http://reactivex.io/documentation/operators/buffer.html">ReactiveX operators documentation: Buffer</a>