All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rx.observables.JoinObservable Maven / Gradle / Ivy

The newest version!
package rx.observables;

import rx.Observable;
import rx.functions.Func1;
import rx.joins.Pattern2;
import rx.joins.Plan0;
import rx.joins.operators.OperatorJoinPatterns;

/**
 * Represents an observable that supports join operations.
 *
 * @param  the value type joined
 */
public final class JoinObservable {

    private final Observable o;

    private JoinObservable(Observable o) {
        this.o = o;
    }

    /**
     * Creates a JoinObservable from a regular Observable.
     * @param o the observable to wrap
     * @return the created JoinObservable instance
     */
    public static  JoinObservable from(Observable o) {
        return new JoinObservable(o);
    }

    /**
     * Returns a Pattern that matches when both Observables emit an item.
     * 

* * * @param right * an Observable to match with the source Observable * @return a Pattern object that matches when both Observables emit an item * @throws NullPointerException * if {@code right} is null * @see RxJava Wiki: and() * @see MSDN: Observable.And */ public final Pattern2 and(Observable right) { return OperatorJoinPatterns.and(o, right); } /** * Joins together the results from several patterns via their plans. *

* * * @param plans * a series of plans created by use of the {@link #then} Observer on patterns * @return an Observable that emits the results from matching several patterns * @throws NullPointerException * if {@code plans} is null * @see RxJava Wiki: when() * @see MSDN: Observable.When */ public final static JoinObservable when(Iterable> plans) { if (plans == null) { throw new NullPointerException("plans"); } return from(Observable.create(OperatorJoinPatterns.when(plans))); } /** * Joins together the results from several patterns via their plans. *

* * * @param plans * a series of plans created by use of the {@link #then} Observer on patterns * @return an Observable that emits the results from matching several patterns * @throws NullPointerException * if {@code plans} is null * @see RxJava Wiki: when() * @see MSDN: Observable.When */ public final static JoinObservable when(Plan0... plans) { return from(Observable.create(OperatorJoinPatterns.when(plans))); } /** * Joins the results from a pattern via its plan. *

* * * @param p1 * the plan to join, created by use of the {@link #then} Observer on a pattern * @return an Observable that emits the results from matching a pattern * @see RxJava Wiki: when() * @see MSDN: Observable.When */ @SuppressWarnings("unchecked") public final static JoinObservable when(Plan0 p1) { return from(Observable.create(OperatorJoinPatterns.when(p1))); } /** * Joins together the results from two patterns via their plans. *

* * * @param p1 * a plan, created by use of the {@link #then} Observer on a pattern * @param p2 * a plan, created by use of the {@link #then} Observer on a pattern * @return an Observable that emits the results from matching two patterns * @see RxJava Wiki: when() * @see MSDN: Observable.When */ @SuppressWarnings("unchecked") public final static JoinObservable when(Plan0 p1, Plan0 p2) { return from(Observable.create(OperatorJoinPatterns.when(p1, p2))); } /** * Joins together the results from three patterns via their plans. *

* * * @param p1 * a plan, created by use of the {@link #then} Observer on a pattern * @param p2 * a plan, created by use of the {@link #then} Observer on a pattern * @param p3 * a plan, created by use of the {@link #then} Observer on a pattern * @return an Observable that emits the results from matching three patterns * @see RxJava Wiki: when() * @see MSDN: Observable.When */ @SuppressWarnings("unchecked") public final static JoinObservable when(Plan0 p1, Plan0 p2, Plan0 p3) { return from(Observable.create(OperatorJoinPatterns.when(p1, p2, p3))); } /** * Joins together the results from four patterns via their plans. *

* * * @param p1 * a plan, created by use of the {@link #then} Observer on a pattern * @param p2 * a plan, created by use of the {@link #then} Observer on a pattern * @param p3 * a plan, created by use of the {@link #then} Observer on a pattern * @param p4 * a plan, created by use of the {@link #then} Observer on a pattern * @return an Observable that emits the results from matching four patterns * @see RxJava Wiki: when() * @see MSDN: Observable.When */ @SuppressWarnings("unchecked") public final static JoinObservable when(Plan0 p1, Plan0 p2, Plan0 p3, Plan0 p4) { return from(Observable.create(OperatorJoinPatterns.when(p1, p2, p3, p4))); } /** * Joins together the results from five patterns via their plans. *

* * * @param p1 * a plan, created by use of the {@link #then} Observer on a pattern * @param p2 * a plan, created by use of the {@link #then} Observer on a pattern * @param p3 * a plan, created by use of the {@link #then} Observer on a pattern * @param p4 * a plan, created by use of the {@link #then} Observer on a pattern * @param p5 * a plan, created by use of the {@link #then} Observer on a pattern * @return an Observable that emits the results from matching five patterns * @see RxJava Wiki: when() * @see MSDN: Observable.When */ @SuppressWarnings("unchecked") public final static JoinObservable when(Plan0 p1, Plan0 p2, Plan0 p3, Plan0 p4, Plan0 p5) { return from(Observable.create(OperatorJoinPatterns.when(p1, p2, p3, p4, p5))); } /** * Joins together the results from six patterns via their plans. *

* * * @param p1 * a plan, created by use of the {@link #then} Observer on a pattern * @param p2 * a plan, created by use of the {@link #then} Observer on a pattern * @param p3 * a plan, created by use of the {@link #then} Observer on a pattern * @param p4 * a plan, created by use of the {@link #then} Observer on a pattern * @param p5 * a plan, created by use of the {@link #then} Observer on a pattern * @param p6 * a plan, created by use of the {@link #then} Observer on a pattern * @return an Observable that emits the results from matching six patterns * @see RxJava Wiki: when() * @see MSDN: Observable.When */ @SuppressWarnings("unchecked") public final static JoinObservable when(Plan0 p1, Plan0 p2, Plan0 p3, Plan0 p4, Plan0 p5, Plan0 p6) { return from(Observable.create(OperatorJoinPatterns.when(p1, p2, p3, p4, p5, p6))); } /** * Joins together the results from seven patterns via their plans. *

* * * @param p1 * a plan, created by use of the {@link #then} Observer on a pattern * @param p2 * a plan, created by use of the {@link #then} Observer on a pattern * @param p3 * a plan, created by use of the {@link #then} Observer on a pattern * @param p4 * a plan, created by use of the {@link #then} Observer on a pattern * @param p5 * a plan, created by use of the {@link #then} Observer on a pattern * @param p6 * a plan, created by use of the {@link #then} Observer on a pattern * @param p7 * a plan, created by use of the {@link #then} Observer on a pattern * @return an Observable that emits the results from matching seven patterns * @see RxJava Wiki: when() * @see MSDN: Observable.When */ @SuppressWarnings("unchecked") public final static JoinObservable when(Plan0 p1, Plan0 p2, Plan0 p3, Plan0 p4, Plan0 p5, Plan0 p6, Plan0 p7) { return from(Observable.create(OperatorJoinPatterns.when(p1, p2, p3, p4, p5, p6, p7))); } /** * Joins together the results from eight patterns via their plans. *

* * * @param p1 * a plan, created by use of the {@link #then} Observer on a pattern * @param p2 * a plan, created by use of the {@link #then} Observer on a pattern * @param p3 * a plan, created by use of the {@link #then} Observer on a pattern * @param p4 * a plan, created by use of the {@link #then} Observer on a pattern * @param p5 * a plan, created by use of the {@link #then} Observer on a pattern * @param p6 * a plan, created by use of the {@link #then} Observer on a pattern * @param p7 * a plan, created by use of the {@link #then} Observer on a pattern * @param p8 * a plan, created by use of the {@link #then} Observer on a pattern * @return an Observable that emits the results from matching eight patterns * @see RxJava Wiki: when() * @see MSDN: Observable.When */ @SuppressWarnings("unchecked") public final static JoinObservable when(Plan0 p1, Plan0 p2, Plan0 p3, Plan0 p4, Plan0 p5, Plan0 p6, Plan0 p7, Plan0 p8) { return from(Observable.create(OperatorJoinPatterns.when(p1, p2, p3, p4, p5, p6, p7, p8))); } /** * Joins together the results from nine patterns via their plans. *

* * * @param p1 * a plan, created by use of the {@link #then} Observer on a pattern * @param p2 * a plan, created by use of the {@link #then} Observer on a pattern * @param p3 * a plan, created by use of the {@link #then} Observer on a pattern * @param p4 * a plan, created by use of the {@link #then} Observer on a pattern * @param p5 * a plan, created by use of the {@link #then} Observer on a pattern * @param p6 * a plan, created by use of the {@link #then} Observer on a pattern * @param p7 * a plan, created by use of the {@link #then} Observer on a pattern * @param p8 * a plan, created by use of the {@link #then} Observer on a pattern * @param p9 * a plan, created by use of the {@link #then} Observer on a pattern * @return an Observable that emits the results from matching nine patterns * @see RxJava Wiki: when() * @see MSDN: Observable.When */ @SuppressWarnings("unchecked") public final static JoinObservable when(Plan0 p1, Plan0 p2, Plan0 p3, Plan0 p4, Plan0 p5, Plan0 p6, Plan0 p7, Plan0 p8, Plan0 p9) { return from(Observable.create(OperatorJoinPatterns.when(p1, p2, p3, p4, p5, p6, p7, p8, p9))); } /** * Matches when the Observable has an available item and projects the item by invoking the selector * function. *

* * * @param selector * selector that will be invoked for items emitted by the source Observable * @return a {@link Plan0} that produces the projected results, to be fed (with other Plans) to the {@link #when} Observer * @throws NullPointerException * if {@code selector} is null * @see RxJava Wiki: then() * @see MSDN: Observable.Then */ public final Plan0 then(Func1 selector) { return OperatorJoinPatterns.then(o, selector); } public Observable toObservable() { return o; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy