diff --git a/rxjava-contrib/rxjava-async-util/build.gradle b/rxjava-contrib/rxjava-async-util/build.gradle deleted file mode 100644 index e7d19ce23f..0000000000 --- a/rxjava-contrib/rxjava-async-util/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -apply plugin: 'osgi' - -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - -dependencies { - compile project(':rxjava') - testCompile project(":rxjava").sourceSets.test.output - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' -} - -jar { - manifest { - name = 'rxjava-async-util' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/ReactiveX/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/Async.java b/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/Async.java deleted file mode 100644 index 8aa13f6119..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/Async.java +++ /dev/null @@ -1,1619 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.util.async; - -import rx.*; -import rx.Scheduler.Worker; -import rx.functions.*; -import rx.schedulers.Schedulers; -import rx.subjects.AsyncSubject; -import rx.subjects.PublishSubject; -import rx.subjects.Subject; -import rx.subscriptions.SerialSubscription; -import rx.util.async.operators.*; - -import java.util.concurrent.Callable; -import java.util.concurrent.Future; -import java.util.concurrent.FutureTask; - -/** - * Utility methods to convert functions and actions into asynchronous operations through the Observable/Observer - * pattern. - */ -public final class Async { - - private Async() { - throw new IllegalStateException("No instances!"); - } - - /** - * Invokes the specified function asynchronously and returns an Observable that emits the result. - *

- * Note: The function is called immediately and once, not whenever an observer subscribes to the resulting - * Observable. Multiple subscriptions to this Observable observe the same return value. - *

- * - * - * @param the result value type - * @param func function to run asynchronously - * @return an Observable that emits the function's result value, or notifies observers of an exception - * @see RxJava Wiki: start() - * @see MSDN: Observable.Start - */ - public static Observable start(Func0 func) { - return Async.toAsync(func).call(); - } - - /** - * Invokes the specified function asynchronously on the specified Scheduler and returns an Observable that - * emits the result. - *

- * Note: The function is called immediately and once, not whenever an observer subscribes to the resulting - * Observable. Multiple subscriptions to this Observable observe the same return value. - *

- * - *

- * @param the result value type - * @param func function to run asynchronously - * @param scheduler Scheduler to run the function on - * @return an Observable that emits the function's result value, or notifies observers of an exception - * @see RxJava Wiki: start() - * @see MSDN: Observable.Start - */ - public static Observable start(Func0 func, Scheduler scheduler) { - return Async.toAsync(func, scheduler).call(); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - *

- * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func0> toAsync(Action0 action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the result value type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func0> toAsync(Func0 func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param first parameter type of the action - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func1> toAsync(Action1 action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param first parameter type of the action - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func1> toAsync(Func1 func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func2> toAsync(Action2 action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func2> toAsync(Func2 func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func3> toAsync(Action3 action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func3> toAsync(Func3 func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func4> toAsync(Action4 action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func4> toAsync(Func4 func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func5> toAsync(Action5 action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func5> toAsync(Func5 func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func6> toAsync(Action6 action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func6> toAsync(Func6 func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func7> toAsync(Action7 action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func7> toAsync(Func7 func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param the eighth parameter type - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func8> toAsync(Action8 action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param the eighth parameter type - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func8> toAsync(Func8 func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param the eighth parameter type - * @param the ninth parameter type - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func9> toAsync(Action9 action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param the eighth parameter type - * @param the ninth parameter type - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func9> toAsync(Func9 func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - */ - public static FuncN> toAsync(ActionN action) { - return toAsync(action, Schedulers.computation()); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - */ - public static FuncN> toAsync(FuncN func) { - return toAsync(func, Schedulers.computation()); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func0> toAsync(final Action0 action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func0> toAsync(final Func0 func, final Scheduler scheduler) { - return new Func0>() { - @Override - public Observable call() { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param action the Action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func1> toAsync(final Action1 action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func1> toAsync(final Func1 func, final Scheduler scheduler) { - return new Func1>() { - @Override - public Observable call(final T1 t1) { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(t1); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func2> toAsync(final Action2 action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func2> toAsync(final Func2 func, final Scheduler scheduler) { - return new Func2>() { - @Override - public Observable call(final T1 t1, final T2 t2) { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(t1, t2); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func3> toAsync(final Action3 action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func3> toAsync(final Func3 func, final Scheduler scheduler) { - return new Func3>() { - @Override - public Observable call(final T1 t1, final T2 t2, final T3 t3) { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(t1, t2, t3); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func4> toAsync(final Action4 action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func4> toAsync(final Func4 func, final Scheduler scheduler) { - return new Func4>() { - @Override - public Observable call(final T1 t1, final T2 t2, final T3 t3, final T4 t4) { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(t1, t2, t3, t4); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func5> toAsync(final Action5 action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func5> toAsync(final Func5 func, final Scheduler scheduler) { - return new Func5>() { - @Override - public Observable call(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5) { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(t1, t2, t3, t4, t5); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func6> toAsync(final Action6 action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func6> toAsync(final Func6 func, final Scheduler scheduler) { - return new Func6>() { - @Override - public Observable call(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final T6 t6) { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(t1, t2, t3, t4, t5, t6); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func7> toAsync(final Action7 action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func7> toAsync(final Func7 func, final Scheduler scheduler) { - return new Func7>() { - @Override - public Observable call(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final T6 t6, final T7 t7) { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(t1, t2, t3, t4, t5, t6, t7); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param the eighth parameter type - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func8> toAsync(final Action8 action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param the eighth parameter type - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func8> toAsync(final Func8 func, final Scheduler scheduler) { - return new Func8>() { - @Override - public Observable call(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final T6 t6, final T7 t7, final T8 t8) { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(t1, t2, t3, t4, t5, t6, t7, t8); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param the eighth parameter type - * @param the ninth parameter type - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func9> toAsync(final Action9 action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the first parameter type - * @param the second parameter type - * @param the third parameter type - * @param the fourth parameter type - * @param the fifth parameter type - * @param the sixth parameter type - * @param the seventh parameter type - * @param the eighth parameter type - * @param the ninth parameter type - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - * @see MSDN: Observable.ToAsync - */ - public static Func9> toAsync(final Func9 func, final Scheduler scheduler) { - return new Func9>() { - @Override - public Observable call(final T1 t1, final T2 t2, final T3 t3, final T4 t4, final T5 t5, final T6 t6, final T7 t7, final T8 t8, final T9 t9) { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(t1, t2, t3, t4, t5, t6, t7, t8, t9); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - * - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: toAsync() - */ - public static FuncN> toAsync(final ActionN action, final Scheduler scheduler) { - return toAsync(Actions.toFunc(action), scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - * - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: toAsync() - */ - public static FuncN> toAsync(final FuncN func, final Scheduler scheduler) { - return new FuncN>() { - @Override - public Observable call(final Object... args) { - final AsyncSubject subject = AsyncSubject.create(); - final Worker inner = scheduler.createWorker(); - inner.schedule(new Action0() { - @Override - public void call() { - R result; - try { - result = func.call(args); - } catch (Throwable t) { - subject.onError(t); - return; - } finally { - inner.unsubscribe(); - } - subject.onNext(result); - subject.onCompleted(); - } - }); - return subject; - } - }; - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - *

- * Alias for toAsync(ActionN) intended for dynamic languages. - * - * @param action the action to convert - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: asyncAction() - */ - public static FuncN> asyncAction(final ActionN action) { - return toAsync(action); - } - - /** - * Convert a synchronous action call into an asynchronous function call through an Observable. - *

- * - *

- * Alias for toAsync(ActionN, Scheduler) intended for dynamic languages. - * - * @param action the action to convert - * @param scheduler the Scheduler used to execute the {@code action} - * @return a function that returns an Observable that executes the {@code action} and emits {@code null} - * @see RxJava Wiki: asyncAction() - */ - public static FuncN> asyncAction(final ActionN action, final Scheduler scheduler) { - return toAsync(action, scheduler); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - *

- * Alias for toAsync(FuncN) intended for dynamic languages. - * - * @param the result type - * @param func the function to convert - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: asyncFunc() - */ - public static FuncN> asyncFunc(final FuncN func) { - return toAsync(func); - } - - /** - * Convert a synchronous function call into an asynchronous function call through an Observable. - *

- * - *

- * Alias for {@code toAsync(FuncN, Scheduler)} intended for dynamic languages. - * - * @param the result type - * @param func the function to convert - * @param scheduler the Scheduler used to call the {@code func} - * @return a function that returns an Observable that executes the {@code func} and emits its returned value - * @see RxJava Wiki: asyncFunc() - */ - public static FuncN> asyncFunc(final FuncN func, final Scheduler scheduler) { - return toAsync(func, scheduler); - } - - /** - * Invokes the asynchronous function immediately, surfacing the result through an Observable. - *

- * Important note subscribing to the resulting Observable blocks until the future completes. - *

- * - * - * @param the result type - * @param functionAsync the asynchronous function to run - * @return an Observable that surfaces the result of the future - * @see #startFuture(rx.functions.Func0, rx.Scheduler) - * @see RxJava Wiki: startFuture() - */ - public static Observable startFuture(Func0> functionAsync) { - return OperatorStartFuture.startFuture(functionAsync); - } - - /** - * Invokes the asynchronous function immediately, surfacing the result through an Observable and waits on - * the specified Scheduler. - *

- * - * - * @param the result type - * @param functionAsync the asynchronous function to run - * @param scheduler the Scheduler where the completion of the Future is awaited - * @return an Observable that surfaces the result of the future - * @see RxJava Wiki: startFuture() - */ - public static Observable startFuture(Func0> functionAsync, - Scheduler scheduler) { - return OperatorStartFuture.startFuture(functionAsync, scheduler); - } - - /** - * Returns an Observable that starts the specified asynchronous factory function whenever a new observer - * subscribes. - *

- * Important note subscribing to the resulting Observable blocks until the future completes. - *

- * - * - * @param the result type - * @param observableFactoryAsync the asynchronous function to start for each observer - * @return the Observable emitting items produced by the asynchronous observer produced by the factory - * @see #deferFuture(rx.functions.Func0, rx.Scheduler) - * @see RxJava Wiki: deferFuture() - */ - public static Observable deferFuture(Func0>> observableFactoryAsync) { - return OperatorDeferFuture.deferFuture(observableFactoryAsync); - } - - /** - * Returns an Observable that starts the specified asynchronous factory function whenever a new observer - * subscribes. - *

- * - * - * @param the result type - * @param observableFactoryAsync the asynchronous function to start for each observer - * @param scheduler the Scheduler where the completion of the Future is awaited - * @return the Observable emitting items produced by the asynchronous observer produced by the factory - * @see RxJava Wiki: deferFuture() - */ - public static Observable deferFuture( - Func0>> observableFactoryAsync, - Scheduler scheduler) { - return OperatorDeferFuture.deferFuture(observableFactoryAsync, scheduler); - } - - /** - * Subscribes to the given source and calls the callback for each emitted item, and surfaces the completion - * or error through a Future. - *

- * Important note: The returned task blocks indefinitely unless the {@code run()} method is called - * or the task is scheduled on an Executor. - *

- * - * - * @param the source value type - * @param source the source Observable - * @param onNext the action to call with each emitted element - * @return the Future representing the entire for-each operation - * @see #forEachFuture(rx.Observable, rx.functions.Action1, rx.Scheduler) - * @see RxJava Wiki: forEachFuture() - */ - public static FutureTask forEachFuture( - Observable source, - Action1 onNext) { - return OperatorForEachFuture.forEachFuture(source, onNext); - } - - - /** - * Subscribes to the given source and calls the callback for each emitted item, and surfaces the completion - * or error through a Future. - *

- * Important note: The returned task blocks indefinitely unless the {@code run()} method is called - * or the task is scheduled on an Executor. - *

- * - * - * @param the source value type - * @param source the source Observable - * @param onNext the action to call with each emitted element - * @param onError the action to call when an exception is emitted - * @return the Future representing the entire for-each operation - * @see #forEachFuture(rx.Observable, rx.functions.Action1, rx.functions.Action1, rx.Scheduler) - * @see RxJava Wiki: forEachFuture() - */ - public static FutureTask forEachFuture( - Observable source, - Action1 onNext, - Action1 onError) { - return OperatorForEachFuture.forEachFuture(source, onNext, onError); - } - - - /** - * Subscribes to the given source and calls the callback for each emitted item, and surfaces the completion - * or error through a Future. - *

- * Important note: The returned task blocks indefinitely unless the {@code run()} method is called - * or the task is scheduled on an Executor. - *

- * - * - * @param the source value type - * @param source the source Observable - * @param onNext the action to call with each emitted element - * @param onError the action to call when an exception is emitted - * @param onCompleted the action to call when the source completes - * @return the Future representing the entire for-each operation - * @see #forEachFuture(rx.Observable, rx.functions.Action1, rx.functions.Action1, rx.functions.Action0, rx.Scheduler) - * @see RxJava Wiki: forEachFuture() - */ - public static FutureTask forEachFuture( - Observable source, - Action1 onNext, - Action1 onError, - Action0 onCompleted) { - return OperatorForEachFuture.forEachFuture(source, onNext, onError, onCompleted); - } - - - /** - * Subscribes to the given source and calls the callback for each emitted item, and surfaces the completion - * or error through a Future, scheduled on the given scheduler. - *

- * - * - * @param the source value type - * @param source the source Observable - * @param onNext the action to call with each emitted element - * @param scheduler the Scheduler where the task will await the termination of the for-each - * @return the Future representing the entire for-each operation - * @see RxJava Wiki: forEachFuture() - */ - public static FutureTask forEachFuture( - Observable source, - Action1 onNext, - Scheduler scheduler) { - FutureTask task = OperatorForEachFuture.forEachFuture(source, onNext); - final Worker inner = scheduler.createWorker(); - inner.schedule(Functionals.fromRunnable(task, inner)); - return task; - } - - - /** - * Subscribes to the given source and calls the callback for each emitted item, and surfaces the completion - * or error through a Future, scheduled on the given Scheduler. - *

- * - * - * @param the source value type - * @param source the source Observable - * @param onNext the action to call with each emitted element - * @param onError the action to call when an exception is emitted - * @param scheduler the Scheduler where the task will await the termination of the for-each - * @return the Future representing the entire for-each operation - * @see RxJava Wiki: forEachFuture() - */ - public static FutureTask forEachFuture( - Observable source, - Action1 onNext, - Action1 onError, - Scheduler scheduler) { - FutureTask task = OperatorForEachFuture.forEachFuture(source, onNext, onError); - final Worker inner = scheduler.createWorker(); - inner.schedule(Functionals.fromRunnable(task, inner)); - return task; - } - - - /** - * Subscribes to the given source and calls the callback for each emitted item, and surfaces the completion - * or error through a Future, scheduled on the given Scheduler. - *

- * - * - * @param the source value type - * @param source the source Observable - * @param onNext the action to call with each emitted element - * @param onError the action to call when an exception is emitted - * @param onCompleted the action to call when the source completes - * @param scheduler the Scheduler where the task will await the termination of the for-each - * @return the Future representing the entire for-each operation - * @see RxJava Wiki: forEachFuture() - */ - public static FutureTask forEachFuture( - Observable source, - Action1 onNext, - Action1 onError, - Action0 onCompleted, - Scheduler scheduler) { - FutureTask task = OperatorForEachFuture.forEachFuture(source, onNext, onError, onCompleted); - final Worker inner = scheduler.createWorker(); - inner.schedule(Functionals.fromRunnable(task, inner)); - return task; - } - - /** - * Return an Observable that calls the given action and emits the given result when an Observer subscribes. - *

- * - *

- * The action is run on the default thread pool for computation. - * - * @param the return type - * @param action the action to invoke on each subscription - * @param result the result to emit to observers - * @return an Observable that calls the given action and emits the given result when an Observer subscribes - * @see RxJava Wiki: fromAction() - */ - public static Observable fromAction(Action0 action, R result) { - return fromAction(action, result, Schedulers.computation()); - } - - /** - * Return an Observable that calls the given Callable and emits its result or Exception when an Observer - * subscribes. - *

- * - *

- * The Callable is called on the default thread pool for computation. - * - * @param the return type - * @param callable the callable to call on each subscription - * @return an Observable that calls the given Callable and emits its result or Exception when an Observer - * subscribes - * @see #start(rx.functions.Func0) - * @see RxJava Wiki: fromCallable() - */ - public static Observable fromCallable(Callable callable) { - return fromCallable(callable, Schedulers.computation()); - } - - /** - * Return an Observable that calls the given Runnable and emits the given result when an Observer - * subscribes. - *

- * - *

- * The Runnable is called on the default thread pool for computation. - * - * @param the return type - * @param run the runnable to invoke on each subscription - * @param result the result to emit to observers - * @return an Observable that calls the given Runnable and emits the given result when an Observer - * subscribes - * @see RxJava Wiki: fromRunnable() - */ - public static Observable fromRunnable(final Runnable run, final R result) { - return fromRunnable(run, result, Schedulers.computation()); - } - - /** - * Return an Observable that calls the given action and emits the given result when an Observer subscribes. - *

- * - * - * @param the return type - * @param action the action to invoke on each subscription - * @param scheduler the Scheduler where the function is called and the result is emitted - * @param result the result to emit to observers - * @return an Observable that calls the given action and emits the given result when an Observer subscribes - * @see RxJava Wiki: fromAction() - */ - public static Observable fromAction(Action0 action, R result, Scheduler scheduler) { - return Observable.create(OperatorFromFunctionals.fromAction(action, result)).subscribeOn(scheduler); - } - - /** - * Return an Observable that calls the given Callable and emits its result or Exception when an Observer - * subscribes. - *

- * - * - * @param the return type - * @param callable the callable to call on each subscription - * @param scheduler the Scheduler where the function is called and the result is emitted - * @return an Observable that calls the given Callable and emits its result or Exception when an Observer - * subscribes - * @see #start(rx.functions.Func0) - * @see RxJava Wiki: fromCallable() - */ - public static Observable fromCallable(Callable callable, Scheduler scheduler) { - return Observable.create(OperatorFromFunctionals.fromCallable(callable)).subscribeOn(scheduler); - } - - /** - * Return an Observable that calls the given Runnable and emits the given result when an Observer - * subscribes. - *

- * - * - * @param the return type - * @param run the runnable to invoke on each subscription - * @param scheduler the Scheduler where the function is called and the result is emitted - * @param result the result to emit to observers - * @return an Observable that calls the given Runnable and emits the given result when an Observer - * subscribes - * @see RxJava Wiki: fromRunnable() - */ - public static Observable fromRunnable(final Runnable run, final R result, Scheduler scheduler) { - return Observable.create(OperatorFromFunctionals.fromRunnable(run, result)).subscribeOn(scheduler); - } - - /** - * Runs the provided action on the given scheduler and allows propagation of multiple events to the - * observers of the returned StoppableObservable. The action is immediately executed and unobserved values - * will be lost. - * - * @param the output value type - * @param scheduler the Scheduler where the action is executed - * @param action the action to execute, receives an Observer where the events can be pumped and a - * Subscription which lets it check for cancellation condition - * @return an Observable that provides a Subscription interface to cancel the action - * @see RxJava Wiki: runAsync() - */ - public static StoppableObservable runAsync(Scheduler scheduler, - final Action2, ? super Subscription> action) { - return runAsync(scheduler, PublishSubject.create(), action); - } - - /** - * Runs the provided action on the given scheduler and allows propagation of multiple events to the - * observers of the returned StoppableObservable. The action is immediately executed and unobserved values - * might be lost, depending on the Subject type used. - * - * @param the output value of the action - * @param the output type of the observable sequence - * @param scheduler the Scheduler where the action is executed - * @param subject the subject to use to distribute values emitted by the action - * @param action the action to execute, receives an Observer where the events can be pumped and a - * Subscription which lets it check for cancellation condition - * @return an Observable that provides a Subscription interface to cancel the action - * @see RxJava Wiki: runAsync() - */ - public static StoppableObservable runAsync(Scheduler scheduler, - final Subject subject, - final Action2, ? super Subscription> action) { - final SerialSubscription csub = new SerialSubscription(); - - StoppableObservable co = new StoppableObservable(new Observable.OnSubscribe() { - @Override - public void call(Subscriber t1) { - subject.subscribe(t1); - } - }, csub); - - final Worker inner = scheduler.createWorker(); - csub.set(inner); - - inner.schedule(new Action0() { - @Override - public void call() { - if (!csub.isUnsubscribed()) { - action.call(subject, csub); - } - } - }); - - return co; - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/StoppableObservable.java b/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/StoppableObservable.java deleted file mode 100644 index 092b56b337..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/StoppableObservable.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.util.async; - -import rx.Observable; -import rx.Subscription; - -/** - * An Observable that provides a Subscription interface to signal a stop condition to an asynchronous task. - * - * @see RxJava Wiki: runAsync() - */ -public class StoppableObservable extends Observable implements Subscription { - private final Subscription token; - public StoppableObservable(Observable.OnSubscribe onSubscribe, Subscription token) { - super(onSubscribe); - this.token = token; - } - - @Override - public boolean isUnsubscribed() { - return token.isUnsubscribed(); - } - - @Override - public void unsubscribe() { - token.unsubscribe(); - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/Functionals.java b/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/Functionals.java deleted file mode 100644 index a197e183c7..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/Functionals.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rx.util.async.operators; - -import rx.Scheduler.Worker; -import rx.functions.Action0; -import rx.functions.Action1; - -/** - * Utility methods convert between functional interfaces of actions and functions. - */ -public final class Functionals { - private Functionals() { - throw new IllegalStateException("No instances!"); - } - /** - * Return an action which takes a Throwable and does nothing. - *

(To avoid casting from the generic empty1().) - * @return the action - */ - public static Action1 emptyThrowable() { - return EMPTY_THROWABLE; - } - /** - * An action that takes a Throwable and does nothing. - */ - private static final Action1 EMPTY_THROWABLE = new EmptyThrowable(); - /** An empty throwable class. */ - private static final class EmptyThrowable implements Action1 { - @Override - public void call(Throwable t1) { - } - } - /** - * Return an Action0 instance which does nothing. - * @return an Action0 instance which does nothing - */ - public static Action0 empty() { - return EMPTY; - } - /** A single empty instance. */ - private static final Action0 EMPTY = new EmptyAction(); - /** An empty action class. */ - private static final class EmptyAction implements Action0 { - @Override - public void call() { - } - } - - /** - * Converts a runnable instance into an Action0 instance. - * @param run the Runnable to run when the Action0 is called - * @return the Action0 wrapping the Runnable - */ - public static Action0 fromRunnable(Runnable run, Worker inner) { - if (run == null) { - throw new NullPointerException("run"); - } - return new ActionWrappingRunnable(run, inner); - } - /** An Action1 which wraps and calls a Runnable. */ - private static final class ActionWrappingRunnable implements Action0 { - final Runnable run; - final Worker inner; - - public ActionWrappingRunnable(Runnable run, Worker inner) { - this.run = run; - this.inner = inner; - } - - @Override - public void call() { - try { - run.run(); - } finally { - inner.unsubscribe(); - } - } - - } - /** - * Converts an Action0 instance into a Runnable instance. - * @param action the Action0 to call when the Runnable is run - * @return the Runnable wrapping the Action0 - */ - public static Runnable toRunnable(Action0 action) { - if (action == null) { - throw new NullPointerException("action"); - } - return new RunnableAction(action); - } - /** An Action0 which wraps and calls a Runnable. */ - private static final class RunnableAction implements Runnable { - final Action0 action; - - public RunnableAction(Action0 action) { - this.action = action; - } - - @Override - public void run() { - action.call(); - } - - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/LatchedObserver.java b/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/LatchedObserver.java deleted file mode 100644 index e8e062bb43..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/LatchedObserver.java +++ /dev/null @@ -1,305 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.util.async.operators; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action2; - -/** - * An observer implementation that calls a CountDownLatch in case - * a terminal state has been reached. - * @param the observed value type - */ -abstract class LatchedObserver implements Observer { - /** The CountDownLatch to count-down on a terminal state. */ - protected final CountDownLatch latch; - /** Contains the error. */ - protected volatile Throwable error; - /** - * Indicates the completion status. - */ - protected final AtomicBoolean done; - /** - * Consturcts a LatchedObserver instance. - * @param latch the CountDownLatch to use - */ - public LatchedObserver(CountDownLatch latch) { - this.latch = latch; - this.done = new AtomicBoolean(); - } - - /** - * Override this method to handle an onNext event. - * @param value - */ - protected abstract void onNextCore(T value); - /** - * Override this method to handle an onError event. - * @param e - */ - protected abstract void onErrorCore(Throwable e); - /** - * Override this to handle th onCompleted event. - */ - protected abstract void onCompletedCore(); - /** - * Try to move into an error state. - * @param e - * @return true if succeded, false if this observable has already terminated - */ - protected boolean fail(Throwable e) { - if (done.compareAndSet(false, true)) { - onErrorCore(e); - return true; - } - return false; - } - - @Override - public final void onNext(T args) { - if (!done.get()) { - onNextCore(args); - } - } - - @Override - public final void onError(Throwable e) { - fail(e); - } - - @Override - public final void onCompleted() { - if (done.compareAndSet(false, true)) { - onCompletedCore(); - } - } - - /** - * Block and await the latch. - * @throws InterruptedException if the wait is interrupted - */ - public void await() throws InterruptedException { - latch.await(); - } - /** - * Block and await the latch for a given amount of time. - * @see CountDownLatch#await(long, java.util.concurrent.TimeUnit) - */ - public boolean await(long time, TimeUnit unit) throws InterruptedException { - return latch.await(time, unit); - } - /** - * Returns the observed error or null if there was none. - *

- * Should be generally called after the await() returns. - * @return the observed error - */ - public Throwable getThrowable() { - return error; - } - - /** - * Create a LatchedObserver with the given callback function(s). - */ - public static LatchedObserver create(Action1 onNext) { - return create(onNext, new CountDownLatch(1)); - } - - /** - * Create a LatchedObserver with the given callback function(s). - */ - public static LatchedObserver create(Action1 onNext, Action1 onError) { - return create(onNext, onError, new CountDownLatch(1)); - } - - /** - * Create a LatchedObserver with the given callback function(s). - */ - public static LatchedObserver create(Action1 onNext, Action1 onError, Action0 onCompleted) { - return create(onNext, onError, onCompleted, new CountDownLatch(1)); - } - - /** - * Create a LatchedObserver with the given callback function(s) and a shared latch. - */ - public static LatchedObserver create(Action1 onNext, CountDownLatch latch) { - return new LatchedObserverImpl(onNext, Functionals.emptyThrowable(), Functionals.empty(), latch); - } - - /** - * Create a LatchedObserver with the given callback function(s) and a shared latch. - */ - public static LatchedObserver create(Action1 onNext, Action1 onError, CountDownLatch latch) { - return new LatchedObserverImpl(onNext, onError, Functionals.empty(), latch); - } - - /** - * Create a LatchedObserver with the given callback function(s) and a shared latch. - */ - public static LatchedObserver create(Action1 onNext, Action1 onError, Action0 onCompleted, CountDownLatch latch) { - return new LatchedObserverImpl(onNext, onError, onCompleted, latch); - } - - /** - * Create a LatchedObserver with the given indexed callback function(s). - */ - public static LatchedObserver createIndexed(Action2 onNext) { - return createIndexed(onNext, new CountDownLatch(1)); - } - - /** - * Create a LatchedObserver with the given indexed callback function(s). - */ - public static LatchedObserver createIndexed(Action2 onNext, Action1 onError) { - return createIndexed(onNext, onError, new CountDownLatch(1)); - } - - /** - * Create a LatchedObserver with the given indexed callback function(s). - */ - public static LatchedObserver createIndexed(Action2 onNext, Action1 onError, Action0 onCompleted) { - return createIndexed(onNext, onError, onCompleted, new CountDownLatch(1)); - } - - /** - * Create a LatchedObserver with the given indexed callback function(s) and a shared latch. - */ - public static LatchedObserver createIndexed(Action2 onNext, CountDownLatch latch) { - return new LatchedObserverIndexedImpl(onNext, Functionals.emptyThrowable(), Functionals.empty(), latch); - } - - /** - * Create a LatchedObserver with the given indexed callback function(s) and a shared latch. - */ - public static LatchedObserver createIndexed(Action2 onNext, Action1 onError, CountDownLatch latch) { - return new LatchedObserverIndexedImpl(onNext, onError, Functionals.empty(), latch); - } - - /** - * Create a LatchedObserver with the given indexed callback function(s) and a shared latch. - */ - public static LatchedObserver createIndexed(Action2 onNext, Action1 onError, Action0 onCompleted, CountDownLatch latch) { - return new LatchedObserverIndexedImpl(onNext, onError, onCompleted, latch); - } - - /** - * A latched observer which calls an action for each observed value - * and checks if a cancellation token is not unsubscribed. - * @param the observed value type - */ - private static final class LatchedObserverImpl extends LatchedObserver { - final Action1 onNext; - final Action1 onError; - final Action0 onCompleted; - - public LatchedObserverImpl(Action1 onNext, - Action1 onError, - Action0 onCompleted, - CountDownLatch latch) { - super(latch); - this.onNext = onNext; - this.onError = onError; - this.onCompleted = onCompleted; - } - - @Override - protected void onNextCore(T args) { - try { - onNext.call(args); - } catch (Throwable t) { - fail(t); - } - } - - @Override - protected void onErrorCore(Throwable e) { - try { - error = e; - onError.call(e); - } finally { - latch.countDown(); - } - } - - @Override - protected void onCompletedCore() { - try { - onCompleted.call(); - } finally { - latch.countDown(); - } - } - } - /** - * A latched observer which calls an action for each observed value - * and checks if a cancellation token is not unsubscribed. - * @param the observed value type - */ - private static final class LatchedObserverIndexedImpl extends LatchedObserver { - final Action2 onNext; - final Action1 onError; - final Action0 onCompleted; - int index; - - public LatchedObserverIndexedImpl(Action2 onNext, - Action1 onError, - Action0 onCompleted, - CountDownLatch latch) { - super(latch); - this.onNext = onNext; - this.onError = onError; - this.onCompleted = onCompleted; - } - - @Override - protected void onNextCore(T args) { - if (index == Integer.MAX_VALUE) { - fail(new ArithmeticException("index overflow")); - return; - } - try { - onNext.call(args, index++); - } catch (Throwable t) { - fail(t); - } - } - - @Override - protected void onErrorCore(Throwable e) { - try { - error = e; - onError.call(e); - } finally { - latch.countDown(); - } - } - - @Override - protected void onCompletedCore() { - try { - onCompleted.call(); - } finally { - latch.countDown(); - } - } - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorDeferFuture.java b/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorDeferFuture.java deleted file mode 100644 index 4e8c524243..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorDeferFuture.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.util.async.operators; - -import java.util.concurrent.Future; - -import rx.Observable; -import rx.Scheduler; -import rx.functions.Func0; - -/** - * Defer the execution of a factory method which produces an observable sequence. - */ -public final class OperatorDeferFuture { - /** Utility class. */ - private OperatorDeferFuture() { throw new IllegalStateException("No instances!"); } - - /** - * Returns an observable sequence that starts the specified asynchronous - * factory function whenever a new observer subscribes. - * @param the result type - * @param observableFactoryAsync the asynchronous function to start for each observer - * @return the observable sequence containing values produced by the asynchronous observer - * produced by the factory - */ - public static Observable deferFuture(Func0>> observableFactoryAsync) { - return Observable.defer(new DeferFutureFunc0(observableFactoryAsync)); - } - /** The function called by the defer operator. */ - private static final class DeferFutureFunc0 implements Func0> { - final Func0>> observableFactoryAsync; - - public DeferFutureFunc0(Func0>> observableFactoryAsync) { - this.observableFactoryAsync = observableFactoryAsync; - } - - @Override - public Observable call() { - return Observable.merge(OperatorStartFuture.startFuture(observableFactoryAsync)); - } - - } - - /** - * Returns an observable sequence that starts the specified asynchronous - * factory function whenever a new observer subscribes. - * @param the result type - * @param observableFactoryAsync the asynchronous function to start for each observer - * @param scheduler the scheduler where the completion of the Future is awaited - * @return the observable sequence containing values produced by the asynchronous observer - * produced by the factory - */ - public static Observable deferFuture( - Func0>> observableFactoryAsync, - Scheduler scheduler) { - return Observable.defer(new DeferFutureFunc0Scheduled(observableFactoryAsync, scheduler)); - } - /** The function called by the defer operator. */ - private static final class DeferFutureFunc0Scheduled implements Func0> { - final Func0>> observableFactoryAsync; - final Scheduler scheduler; - - public DeferFutureFunc0Scheduled(Func0>> observableFactoryAsync, - Scheduler scheduler) { - this.observableFactoryAsync = observableFactoryAsync; - this.scheduler = scheduler; - } - - @Override - public Observable call() { - return Observable.merge(OperatorStartFuture.startFuture(observableFactoryAsync, scheduler)); - } - - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorForEachFuture.java b/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorForEachFuture.java deleted file mode 100644 index 098aa41aaf..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorForEachFuture.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.util.async.operators; - -import java.util.concurrent.Callable; -import java.util.concurrent.FutureTask; - -import rx.Observable; -import rx.Subscription; -import rx.exceptions.Exceptions; -import rx.functions.Action0; -import rx.functions.Action1; - -/** - * Convert the observation of a source observable to a big Future call. - *

- * Remark: the cancellation token version's behavior is in doubt, so left out. - */ -public final class OperatorForEachFuture { - /** Utility class. */ - private OperatorForEachFuture() { throw new IllegalStateException("No instances!"); } - - /** - * Subscribes to the given source and calls the callback for each emitted item, - * and surfaces the completion or error through a Future. - * @param the element type of the Observable - * @param source the source Observable - * @param onNext the action to call with each emitted element - * @return the Future representing the entire for-each operation - */ - public static FutureTask forEachFuture( - Observable source, - Action1 onNext) { - return forEachFuture(source, onNext, Functionals.emptyThrowable(), Functionals.empty()); - } - - /** - * Subscribes to the given source and calls the callback for each emitted item, - * and surfaces the completion or error through a Future. - * @param the element type of the Observable - * @param source the source Observable - * @param onNext the action to call with each emitted element - * @param onError the action to call when an exception is emitted - * @return the Future representing the entire for-each operation - */ - public static FutureTask forEachFuture( - Observable source, - Action1 onNext, - Action1 onError) { - return forEachFuture(source, onNext, onError, Functionals.empty()); - } - - /** - * Subscribes to the given source and calls the callback for each emitted item, - * and surfaces the completion or error through a Future. - * @param the element type of the Observable - * @param source the source Observable - * @param onNext the action to call with each emitted element - * @param onError the action to call when an exception is emitted - * @param onCompleted the action to call when the source completes - * @return the Future representing the entire for-each operation - */ - public static FutureTask forEachFuture( - Observable source, - Action1 onNext, - Action1 onError, - Action0 onCompleted) { - - LatchedObserver lo = LatchedObserver.create(onNext, onError, onCompleted); - - Subscription s = source.subscribe(lo); - - FutureTaskCancel task = new FutureTaskCancel(s, new RunAwait(lo)); - - return task; - } - /** - * A future task that unsubscribes the given subscription when cancelled. - * @param the return value type - */ - private static final class FutureTaskCancel extends FutureTask { - final Subscription cancel; - - public FutureTaskCancel(Subscription cancel, Callable callable) { - super(callable); - this.cancel = cancel; - } - - public FutureTaskCancel(Subscription cancel, Runnable runnable, T result) { - super(runnable, result); - this.cancel = cancel; - } - - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - cancel.unsubscribe(); - return super.cancel(mayInterruptIfRunning); - } - - } - - /** Await the completion of a latched observer and throw its exception if any. */ - private static final class RunAwait implements Callable { - final LatchedObserver observer; - - public RunAwait(LatchedObserver observer) { - this.observer = observer; - } - - @Override - public Void call() throws Exception { - observer.await(); - Throwable t = observer.getThrowable(); - if (t != null) { - throw Exceptions.propagate(t); - } - return null; - } - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorFromFunctionals.java b/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorFromFunctionals.java deleted file mode 100644 index e1e337ae5a..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorFromFunctionals.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.util.async.operators; - -import java.util.concurrent.Callable; - -import rx.Observable.OnSubscribe; -import rx.Subscriber; -import rx.functions.Action0; -import rx.functions.Actions; -import rx.functions.Func0; - -/** - * Operators that invoke a function or action if - * an observer subscribes. - * Asynchrony can be achieved by using subscribeOn or observeOn. - */ -public final class OperatorFromFunctionals { - /** Utility class. */ - private OperatorFromFunctionals() { throw new IllegalStateException("No instances!"); } - - /** Subscriber function that invokes an action and returns the given result. */ - public static OnSubscribe fromAction(Action0 action, R result) { - return new InvokeAsync(Actions.toFunc(action, result)); - } - - /** - * Subscriber function that invokes the callable and returns its value or - * propagates its checked exception. - */ - public static OnSubscribe fromCallable(Callable callable) { - return new InvokeAsync(callable); - } - /** Subscriber function that invokes a runnable and returns the given result. */ - public static OnSubscribe fromRunnable(final Runnable run, final R result) { - return new InvokeAsync(new Func0() { - @Override - public R call() { - run.run(); - return result; - } - }); - } - - /** - * Invokes a java.util.concurrent.Callable when an observer subscribes. - * @param the return type - */ - static final class InvokeAsync implements OnSubscribe { - final Callable callable; - public InvokeAsync(Callable callable) { - if (callable == null) { - throw new NullPointerException("function"); - } - this.callable = callable; - } - @Override - public void call(Subscriber t1) { - try { - t1.onNext(callable.call()); - } catch (Throwable t) { - t1.onError(t); - return; - } - t1.onCompleted(); - } - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorStartFuture.java b/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorStartFuture.java deleted file mode 100644 index 25ce2c62f4..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/main/java/rx/util/async/operators/OperatorStartFuture.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.util.async.operators; - -import java.util.concurrent.Future; - -import rx.Observable; -import rx.Scheduler; -import rx.functions.Func0; - -/** - * Start an asynchronous Future immediately and observe its result through - * an observable. - */ -public final class OperatorStartFuture { - /** Utility class. */ - private OperatorStartFuture() { throw new IllegalStateException("No instances!"); } - /** - * Invokes the asynchronous function, surfacing the result through an observable sequence. - *

- * Important note subscribing to the resulting observable blocks until - * the future completes. - * @param the result type - * @param functionAsync the asynchronous function to run - * @return the observable - */ - public static Observable startFuture(Func0> functionAsync) { - Future task; - try { - task = functionAsync.call(); - } catch (Throwable t) { - return Observable.error(t); - } - return Observable.from(task); - } - /** - * Invokes the asynchronous function, surfacing the result through an observable sequence - * running on the given scheduler. - * @param the result type - * @param functionAsync the asynchronous function to run - * @param scheduler the scheduler where the completion of the Future is awaited - * @return the observable - */ - public static Observable startFuture(Func0> functionAsync, - Scheduler scheduler) { - Future task; - try { - task = functionAsync.call(); - } catch (Throwable t) { - return Observable.error(t); - } - return Observable.from(task, scheduler); - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/AsyncTest.java b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/AsyncTest.java deleted file mode 100644 index 7427e3c2fe..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/AsyncTest.java +++ /dev/null @@ -1,866 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rx.util.async; - -import java.util.concurrent.CountDownLatch; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import junit.framework.Assert; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -import rx.Observable; -import rx.Observer; -import rx.Subscription; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action2; -import rx.functions.Action3; -import rx.functions.Action4; -import rx.functions.Action5; -import rx.functions.Action6; -import rx.functions.Action7; -import rx.functions.Action8; -import rx.functions.Action9; -import rx.functions.ActionN; -import rx.functions.Func0; -import rx.functions.Func1; -import rx.functions.Func2; -import rx.functions.Func3; -import rx.functions.Func4; -import rx.functions.Func5; -import rx.functions.Func6; -import rx.functions.Func7; -import rx.functions.Func8; -import rx.functions.Func9; -import rx.functions.FuncN; -import rx.observers.TestObserver; -import rx.schedulers.Schedulers; -import rx.schedulers.TestScheduler; - -public class AsyncTest { - @Mock - Observer observer; - - @Before - public void before() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testAction0() { - final AtomicInteger value = new AtomicInteger(); - Action0 action = new Action0() { - @Override - public void call() { - value.incrementAndGet(); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call() - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(1, value.get()); - } - - @Test - public void testAction0Error() { - Action0 action = new Action0() { - @Override - public void call() { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call() - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testAction1() { - final AtomicInteger value = new AtomicInteger(); - Action1 action = new Action1() { - @Override - public void call(Integer t1) { - value.set(t1); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(1, value.get()); - } - - @Test - public void testAction1Error() { - Action1 action = new Action1() { - @Override - public void call(Integer t1) { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1) - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testAction2() { - final AtomicInteger value = new AtomicInteger(); - Action2 action = new Action2() { - @Override - public void call(Integer t1, Integer t2) { - value.set(t1 | t2); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(3, value.get()); - } - - @Test - public void testAction2Error() { - Action2 action = new Action2() { - @Override - public void call(Integer t1, Integer t2) { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2) - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testAction3() { - final AtomicInteger value = new AtomicInteger(); - Action3 action = new Action3() { - @Override - public void call(Integer t1, Integer t2, Integer t3) { - value.set(t1 | t2 | t3); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(7, value.get()); - } - - @Test - public void testAction3Error() { - Action3 action = new Action3() { - @Override - public void call(Integer t1, Integer t2, Integer t3) { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4) - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testAction4() { - final AtomicInteger value = new AtomicInteger(); - Action4 action = new Action4() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4) { - value.set(t1 | t2 | t3 | t4); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(15, value.get()); - } - - @Test - public void testAction4Error() { - Action4 action = new Action4() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4) { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8) - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testAction5() { - final AtomicInteger value = new AtomicInteger(); - Action5 action = new Action5() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5) { - value.set(t1 | t2 | t3 | t4 | t5); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(31, value.get()); - } - - @Test - public void testAction5Error() { - Action5 action = new Action5() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5) { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16) - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testAction6() { - final AtomicInteger value = new AtomicInteger(); - Action6 action = new Action6() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6) { - value.set(t1 | t2 | t3 | t4 | t5 | t6); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(63, value.get()); - } - - @Test - public void testAction6Error() { - Action6 action = new Action6() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6) { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32) - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testAction7() { - final AtomicInteger value = new AtomicInteger(); - Action7 action = new Action7() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7) { - value.set(t1 | t2 | t3 | t4 | t5 | t6 | t7); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(127, value.get()); - } - - @Test - public void testAction7Error() { - Action7 action = new Action7() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7) { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64) - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testAction8() { - final AtomicInteger value = new AtomicInteger(); - Action8 action = new Action8() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8) { - value.set(t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64, 128) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(255, value.get()); - } - - @Test - public void testAction8Error() { - Action8 action = new Action8() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8) { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64, 128) - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testAction9() { - final AtomicInteger value = new AtomicInteger(); - Action9 action = new Action9() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8, Integer t9) { - value.set(t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64, 128, 256) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(511, value.get()); - } - - @Test - public void testAction9Error() { - Action9 action = new Action9() { - @Override - public void call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8, Integer t9) { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64, 128, 256) - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testActionN() { - final AtomicInteger value = new AtomicInteger(); - ActionN action = new ActionN() { - @Override - public void call(Object... args) { - int i = 0; - for (Object o : args) { - i = i | (Integer) o; - } - value.set(i); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64, 128, 256, 512) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(null); - verify(observer, times(1)).onCompleted(); - - Assert.assertEquals(1023, value.get()); - } - - @Test - public void testActionNError() { - ActionN action = new ActionN() { - @Override - public void call(Object... args) { - throw new RuntimeException("Forced failure"); - } - }; - - Async.toAsync(action, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64, 128, 256, 512) - .subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(null); - verify(observer, never()).onCompleted(); - } - - @Test - public void testFunc0() { - Func0 func = new Func0() { - @Override - public Integer call() { - return 0; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call() - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(0); - verify(observer, times(1)).onCompleted(); - - } - - @Test - public void testFunc1() { - Func1 func = new Func1() { - @Override - public Integer call(Integer t1) { - return t1; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call(1) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(1); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void testFunc2() { - Func2 func = new Func2() { - @Override - public Integer call(Integer t1, Integer t2) { - return t1 | t2; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call(1, 2) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(3); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void testFunc3() { - Func3 func = new Func3() { - @Override - public Integer call(Integer t1, Integer t2, Integer t3) { - return t1 | t2 | t3; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call(1, 2, 4) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(7); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void testFunc4() { - Func4 func = new Func4() { - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4) { - return t1 | t2 | t3 | t4; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call(1, 2, 4, 8) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(15); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void testFunc5() { - Func5 func = new Func5() { - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5) { - return t1 | t2 | t3 | t4 | t5; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call(1, 2, 4, 8, 16) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(31); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void testFunc6() { - Func6 func = new Func6() { - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6) { - return t1 | t2 | t3 | t4 | t5 | t6; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(63); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void testFunc7() { - Func7 func = new Func7() { - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7) { - return t1 | t2 | t3 | t4 | t5 | t6 | t7; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(127); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void testFunc8() { - Func8 func = new Func8() { - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8) { - return t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64, 128) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(255); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void testFunc9() { - Func9 func = new Func9() { - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8, Integer t9) { - return t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64, 128, 256) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(511); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void testFuncN() { - FuncN func = new FuncN() { - @Override - public Integer call(Object... args) { - int i = 0; - for (Object o : args) { - i = i | (Integer) o; - } - return i; - } - }; - Async.toAsync(func, Schedulers.immediate()) - .call(1, 2, 4, 8, 16, 32, 64, 128, 256, 512) - .subscribe(new TestObserver(observer)); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(1023); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void testStartWithFunc() { - Func0 func = new Func0() { - @Override - public String call() { - return "one"; - } - }; - assertEquals("one", Async.start(func).toBlocking().single()); - } - - @Test(expected = RuntimeException.class) - public void testStartWithFuncError() { - Func0 func = new Func0() { - @Override - public String call() { - throw new RuntimeException("Some error"); - } - }; - Async.start(func).toBlocking().single(); - } - - @Test - public void testStartWhenSubscribeRunBeforeFunc() { - TestScheduler scheduler = new TestScheduler(); - - Func0 func = new Func0() { - @Override - public String call() { - return "one"; - } - }; - - Observable observable = Async.start(func, scheduler); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - observable.subscribe(new TestObserver(observer)); - - InOrder inOrder = inOrder(observer); - inOrder.verifyNoMoreInteractions(); - - // Run func - scheduler.advanceTimeBy(100, TimeUnit.MILLISECONDS); - - inOrder.verify(observer, times(1)).onNext("one"); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testStartWhenSubscribeRunAfterFunc() { - TestScheduler scheduler = new TestScheduler(); - - Func0 func = new Func0() { - @Override - public String call() { - return "one"; - } - }; - - Observable observable = Async.start(func, scheduler); - - // Run func - scheduler.advanceTimeBy(100, TimeUnit.MILLISECONDS); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - observable.subscribe(new TestObserver(observer)); - - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext("one"); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testStartWithFuncAndMultipleObservers() { - TestScheduler scheduler = new TestScheduler(); - - @SuppressWarnings("unchecked") - Func0 func = (Func0) mock(Func0.class); - doAnswer(new Answer() { - @Override - public String answer(InvocationOnMock invocation) throws Throwable { - return "one"; - } - }).when(func).call(); - - Observable observable = Async.start(func, scheduler); - - scheduler.advanceTimeBy(100, TimeUnit.MILLISECONDS); - - @SuppressWarnings("unchecked") - Observer observer1 = mock(Observer.class); - @SuppressWarnings("unchecked") - Observer observer2 = mock(Observer.class); - @SuppressWarnings("unchecked") - Observer observer3 = mock(Observer.class); - - observable.subscribe(new TestObserver(observer1)); - observable.subscribe(new TestObserver(observer2)); - observable.subscribe(new TestObserver(observer3)); - - InOrder inOrder; - inOrder = inOrder(observer1); - inOrder.verify(observer1, times(1)).onNext("one"); - inOrder.verify(observer1, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - - inOrder = inOrder(observer2); - inOrder.verify(observer2, times(1)).onNext("one"); - inOrder.verify(observer2, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - - inOrder = inOrder(observer3); - inOrder.verify(observer3, times(1)).onNext("one"); - inOrder.verify(observer3, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - - verify(func, times(1)).call(); - } - - @Test - public void testRunAsync() throws InterruptedException { - final CountDownLatch cdl = new CountDownLatch(1); - final CountDownLatch cdl2 = new CountDownLatch(1); - Action2, Subscription> action = new Action2, Subscription>() { - @Override - public void call(Observer t1, Subscription t2) { - try { - cdl.await(); - } catch (InterruptedException ex) { - Thread.currentThread().interrupt(); - return; - } - for (int i = 0; i < 10 && !t2.isUnsubscribed(); i++) { - t1.onNext(i); - } - t1.onCompleted(); - cdl2.countDown(); - } - }; - - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - InOrder inOrder = inOrder(o); - - StoppableObservable so = Async.runAsync(Schedulers.io(), action); - - so.subscribe(o); - - cdl.countDown(); - - if (!cdl2.await(2, TimeUnit.SECONDS)) { - fail("Didn't complete"); - } - - for (int i = 0; i < 10; i++) { - inOrder.verify(o).onNext(i); - } - inOrder.verify(o).onCompleted(); - inOrder.verifyNoMoreInteractions(); - verify(o, never()).onError(any(Throwable.class)); - - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorDeferFutureTest.java b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorDeferFutureTest.java deleted file mode 100644 index 5d79797a3b..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorDeferFutureTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.util.async.operators; - -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; -import org.mockito.InOrder; - -import rx.Observable; -import rx.Observer; -import rx.exceptions.TestException; -import rx.functions.Func0; -import rx.schedulers.Schedulers; -import rx.util.async.Async; - -public class OperatorDeferFutureTest { - @Test - @SuppressWarnings("unchecked") - public void testSimple() throws InterruptedException { - final ExecutorService exec = Executors.newCachedThreadPool(); - try { - final CountDownLatch ready = new CountDownLatch(1); - - Func0>> func = new Func0>>() { - @Override - public Future> call() { - return exec.submit(new Callable>() { - @Override - public Observable call() throws Exception { - if (!ready.await(1000, TimeUnit.MILLISECONDS)) { - throw new IllegalStateException("Not started in time"); - } - return Observable.just(1); - } - }); - } - }; - - Observable result = Async.deferFuture(func, Schedulers.computation()); - - final Observer observer = mock(Observer.class); - - final CountDownLatch done = new CountDownLatch(1); - - result.subscribe(new OperatorStartFutureTest.MockHelper(observer, done)); - - ready.countDown(); - - if (!done.await(1000, TimeUnit.MILLISECONDS)) { - fail("Not completed in time!"); - } - - InOrder inOrder = inOrder(observer); - - inOrder.verify(observer).onNext(1); - inOrder.verify(observer).onCompleted(); - verify(observer, never()).onError(any(Throwable.class)); - } finally { - exec.shutdown(); - } - } - - @Test - @SuppressWarnings("unchecked") - public void testSimpleFactoryThrows() { - Func0>> func = new Func0>>() { - - @Override - public Future> call() { - throw new TestException(); - } - }; - - Observable result = Async.deferFuture(func); - - final Observer observer = mock(Observer.class); - result.subscribe(observer); - - verify(observer, never()).onNext(any()); - verify(observer, never()).onCompleted(); - verify(observer).onError(any(TestException.class)); - } -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorForEachFutureTest.java b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorForEachFutureTest.java deleted file mode 100644 index 96a55f4529..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorForEachFutureTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - /** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.util.async.operators; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicInteger; - -import org.junit.Test; - -import rx.Observable; -import rx.exceptions.TestException; -import rx.functions.Action1; -import rx.schedulers.Schedulers; -import rx.util.async.Async; - -public class OperatorForEachFutureTest { - @Test - public void testSimple() { - final ExecutorService exec = Executors.newCachedThreadPool(); - - try { - Observable source = Observable.just(1, 2, 3) - .subscribeOn(Schedulers.computation()); - - final AtomicInteger sum = new AtomicInteger(); - Action1 add = new Action1() { - @Override - public void call(Integer t1) { - sum.addAndGet(t1); - } - }; - - FutureTask task = Async.forEachFuture(source, add); - - exec.execute(task); - - try { - Void value = task.get(1000, TimeUnit.MILLISECONDS); - - assertEquals(null, value); - - assertEquals(6, sum.get()); - } catch (TimeoutException ex) { - fail("Timed out: " + ex); - } catch (ExecutionException ex) { - fail("Exception: " + ex); - } catch (InterruptedException ex) { - fail("Exception: " + ex); - } - } finally { - exec.shutdown(); - } - } - @Test - public void testSimpleThrowing() { - - final ExecutorService exec = Executors.newCachedThreadPool(); - - try { - Observable source = Observable.error(new TestException()) - .subscribeOn(Schedulers.computation()); - - final AtomicInteger sum = new AtomicInteger(); - Action1 add = new Action1() { - @Override - public void call(Integer t1) { - sum.addAndGet(t1); - } - }; - - FutureTask task = Async.forEachFuture(source, add); - - exec.execute(task); - - try { - task.get(1000, TimeUnit.MILLISECONDS); - } catch (TimeoutException ex) { - fail("Timed out: " + ex); - } catch (ExecutionException ex) { - if (!(ex.getCause() instanceof TestException)) { - fail("Got different exception: " + ex.getCause()); - } - } catch (InterruptedException ex) { - fail("Exception: " + ex); - } - - assertEquals(0, sum.get()); - } finally { - exec.shutdown(); - } - } - - @Test - public void testSimpleScheduled() { - Observable source = Observable.just(1, 2, 3) - .subscribeOn(Schedulers.computation()); - - final AtomicInteger sum = new AtomicInteger(); - Action1 add = new Action1() { - @Override - public void call(Integer t1) { - sum.addAndGet(t1); - } - }; - - FutureTask task = Async.forEachFuture(source, add, Schedulers.newThread()); - - try { - Void value = task.get(1000, TimeUnit.MILLISECONDS); - - assertEquals(null, value); - - assertEquals(6, sum.get()); - } catch (TimeoutException ex) { - fail("Timed out: " + ex); - } catch (ExecutionException ex) { - fail("Exception: " + ex); - } catch (InterruptedException ex) { - fail("Exception: " + ex); - } - } - @Test - public void testSimpleScheduledThrowing() { - - Observable source = Observable.error(new TestException()) - .subscribeOn(Schedulers.computation()); - - final AtomicInteger sum = new AtomicInteger(); - Action1 add = new Action1() { - @Override - public void call(Integer t1) { - sum.addAndGet(t1); - } - }; - - FutureTask task = Async.forEachFuture(source, add, Schedulers.newThread()); - - try { - task.get(1000, TimeUnit.MILLISECONDS); - } catch (TimeoutException ex) { - fail("Timed out: " + ex); - } catch (ExecutionException ex) { - if (!(ex.getCause() instanceof TestException)) { - fail("Got different exception: " + ex.getCause()); - } - } catch (InterruptedException ex) { - fail("Exception: " + ex); - } - - assertEquals(0, sum.get()); - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorFromFunctionalsTest.java b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorFromFunctionalsTest.java deleted file mode 100644 index aed539f67b..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorFromFunctionalsTest.java +++ /dev/null @@ -1,212 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rx.util.async.operators; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.io.IOException; -import java.util.concurrent.Callable; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import junit.framework.Assert; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; - -import rx.Observable; -import rx.Observer; -import rx.functions.Action0; -import rx.observers.TestObserver; -import rx.schedulers.TestScheduler; -import rx.util.async.Async; - -public class OperatorFromFunctionalsTest { - TestScheduler scheduler; - @Before - public void before() { - scheduler = new TestScheduler(); - } - private void testRunShouldThrow(Observable source, Class exception) { - for (int i = 0; i < 3; i++) { - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - source.subscribe(new TestObserver(observer)); - - InOrder inOrder = inOrder(observer); - - inOrder.verify(observer, never()).onError(any(Throwable.class)); - - scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); - - inOrder.verify(observer, times(1)).onError(any(exception)); - verify(observer, never()).onNext(any()); - verify(observer, never()).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - } - @Test - public void testFromAction() { - final AtomicInteger value = new AtomicInteger(); - - Action0 action = new Action0() { - @Override - public void call() { - value.set(2); - } - }; - - Observable source = Async.fromAction(action, 1, scheduler); - - for (int i = 0; i < 3; i++) { - - value.set(0); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - source.subscribe(new TestObserver(observer)); - - InOrder inOrder = inOrder(observer); - - inOrder.verify(observer, never()).onNext(any()); - inOrder.verify(observer, never()).onCompleted(); - - scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); - - inOrder.verify(observer, times(1)).onNext(1); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - verify(observer, never()).onError(any(Throwable.class)); - - Assert.assertEquals(2, value.get()); - } - } - @Test - public void testFromActionThrows() { - Action0 action = new Action0() { - @Override - public void call() { - throw new RuntimeException("Forced failure!"); - } - }; - - Observable source = Async.fromAction(action, 1, scheduler); - - testRunShouldThrow(source, RuntimeException.class); - } - - @Test - public void testFromRunnable() { - final AtomicInteger value = new AtomicInteger(); - - Runnable action = new Runnable() { - @Override - public void run() { - value.set(2); - } - }; - - Observable source = Async.fromRunnable(action, 1, scheduler); - - for (int i = 0; i < 3; i++) { - - value.set(0); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - source.subscribe(new TestObserver(observer)); - - InOrder inOrder = inOrder(observer); - - inOrder.verify(observer, never()).onNext(any()); - inOrder.verify(observer, never()).onCompleted(); - - scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); - - inOrder.verify(observer, times(1)).onNext(1); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - verify(observer, never()).onError(any(Throwable.class)); - - Assert.assertEquals(2, value.get()); - } - } - @Test - public void testFromRunnableThrows() { - Runnable action = new Runnable() { - @Override - public void run() { - throw new RuntimeException("Forced failure!"); - } - }; - - Observable source = Async.fromRunnable(action, 1, scheduler); - - testRunShouldThrow(source, RuntimeException.class); - } - @Test - public void testFromCallable() { - Callable callable = new Callable() { - @Override - public Integer call() throws Exception { - return 1; - } - }; - - Observable source = Async.fromCallable(callable, scheduler); - - for (int i = 0; i < 3; i++) { - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - source.subscribe(new TestObserver(observer)); - - InOrder inOrder = inOrder(observer); - - inOrder.verify(observer, never()).onNext(any()); - inOrder.verify(observer, never()).onCompleted(); - - scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS); - - inOrder.verify(observer, times(1)).onNext(1); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - verify(observer, never()).onError(any(Throwable.class)); - } - } - - @Test - public void testFromCallableThrows() { - Callable callable = new Callable() { - @Override - public Integer call() throws Exception { - throw new IOException("Forced failure!"); - } - }; - - Observable source = Async.fromCallable(callable, scheduler); - - testRunShouldThrow(source, IOException.class); - } -} diff --git a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorStartFutureTest.java b/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorStartFutureTest.java deleted file mode 100644 index 0c6f800926..0000000000 --- a/rxjava-contrib/rxjava-async-util/src/test/java/rx/util/async/operators/OperatorStartFutureTest.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.util.async.operators; - -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; -import org.mockito.InOrder; - -import rx.Observable; -import rx.Observer; -import rx.exceptions.TestException; -import rx.functions.Func0; -import rx.schedulers.Schedulers; -import rx.util.async.Async; - -public class OperatorStartFutureTest { - /** - * Forwards the events to the underlying observer and counts down the latch - * on terminal conditions. - * @param - */ - static class MockHelper implements Observer { - final Observer observer; - final CountDownLatch latch; - - public MockHelper(Observer observer, CountDownLatch latch) { - this.observer = observer; - this.latch = latch; - } - - @Override - public void onNext(T args) { - try { - observer.onNext(args); - } catch (Throwable t) { - onError(t); - } - } - - @Override - public void onError(Throwable e) { - try { - observer.onError(e); - } finally { - latch.countDown(); - } - } - - - @Override - public void onCompleted() { - try { - observer.onCompleted(); - } finally { - latch.countDown(); - } - } - - } - @Test - @SuppressWarnings("unchecked") - public void testSimple() throws InterruptedException { - final ExecutorService exec = Executors.newCachedThreadPool(); - try { - final CountDownLatch ready = new CountDownLatch(1); - - Func0> func = new Func0>() { - - @Override - public Future call() { - return exec.submit(new Callable() { - @Override - public Integer call() throws Exception { - if (!ready.await(1000, TimeUnit.MILLISECONDS)) { - throw new IllegalStateException("Not started in time"); - } - return 1; - } - }); - } - }; - - Observable result = Async.startFuture(func, Schedulers.computation()); - - final Observer observer = mock(Observer.class); - - final CountDownLatch done = new CountDownLatch(1); - - result.subscribe(new MockHelper(observer, done)); - - ready.countDown(); - - if (!done.await(1000, TimeUnit.MILLISECONDS)) { - fail("Not completed in time!"); - } - - InOrder inOrder = inOrder(observer); - - inOrder.verify(observer).onNext(1); - inOrder.verify(observer).onCompleted(); - verify(observer, never()).onError(any(Throwable.class)); - } finally { - exec.shutdown(); - } - } - - @Test - @SuppressWarnings("unchecked") - public void testSimpleFactoryThrows() { - Func0> func = new Func0>() { - - @Override - public Future call() { - throw new TestException(); - } - }; - - Observable result = Async.startFuture(func); - - final Observer observer = mock(Observer.class); - result.subscribe(observer); - - verify(observer, never()).onNext(any()); - verify(observer, never()).onCompleted(); - verify(observer).onError(any(TestException.class)); - } -} diff --git a/rxjava-contrib/rxjava-computation-expressions/build.gradle b/rxjava-contrib/rxjava-computation-expressions/build.gradle deleted file mode 100644 index c602140881..0000000000 --- a/rxjava-contrib/rxjava-computation-expressions/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -apply plugin: 'osgi' - -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - -dependencies { - compile project(':rxjava') - testCompile project(":rxjava").sourceSets.test.output - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' -} - -jar { - manifest { - name = 'rxjava-computation-expressions' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/ReactiveX/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } -} diff --git a/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/Statement.java b/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/Statement.java deleted file mode 100644 index 5948212264..0000000000 --- a/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/Statement.java +++ /dev/null @@ -1,217 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx; - -import java.util.Map; - -import rx.functions.Func0; -import rx.operators.OperatorIfThen; -import rx.operators.OperatorSwitchCase; -import rx.operators.OperatorWhileDoWhile; - -/** - * Imperative statements expressed as Observable operators. - */ -public final class Statement { - private Statement() { throw new IllegalStateException("No instances!"); } - /** - * Return a particular one of several possible Observables based on a case - * selector. - *

- * - * - * @param - * the case key type - * @param - * the result value type - * @param caseSelector - * the function that produces a case key when an - * Observer subscribes - * @param mapOfCases - * a map that maps a case key to an Observable - * @return a particular Observable chosen by key from the map of - * Observables, or an empty Observable if no Observable matches the - * key - */ - public static Observable switchCase(Func0 caseSelector, - Map> mapOfCases) { - return switchCase(caseSelector, mapOfCases, Observable. empty()); - } - - /** - * Return a particular one of several possible Observables based on a case - * selector and run it on the designated scheduler. - *

- * - * - * @param - * the case key type - * @param - * the result value type - * @param caseSelector - * the function that produces a case key when an - * Observer subscribes - * @param mapOfCases - * a map that maps a case key to an Observable - * @param scheduler - * the scheduler where the empty observable is observed - * @return a particular Observable chosen by key from the map of - * Observables, or an empty Observable if no Observable matches the - * key, but one that runs on the designated scheduler in either case - */ - public static Observable switchCase(Func0 caseSelector, - Map> mapOfCases, Scheduler scheduler) { - return switchCase(caseSelector, mapOfCases, Observable. empty().subscribeOn(scheduler)); - } - - /** - * Return a particular one of several possible Observables based on a case - * selector, or a default Observable if the case selector does not map to - * a particular one. - *

- * - * - * @param - * the case key type - * @param - * the result value type - * @param caseSelector - * the function that produces a case key when an - * Observer subscribes - * @param mapOfCases - * a map that maps a case key to an Observable - * @param defaultCase - * the default Observable if the {@code mapOfCases} doesn't contain a value for the key returned by the {@code caseSelector} - * @return a particular Observable chosen by key from the map of - * Observables, or the default case if no Observable matches the key - */ - public static Observable switchCase(Func0 caseSelector, - Map> mapOfCases, - Observable defaultCase) { - return Observable.create(new OperatorSwitchCase(caseSelector, mapOfCases, defaultCase)); - } - - /** - * Return an Observable that replays the emissions from the source - * Observable, and then continues to replay them so long as a condtion is - * true. - *

- * - * - * @param postCondition - * the post condition to test after the source - * Observable completes - * @return an Observable that replays the emissions from the source - * Observable, and then continues to replay them so long as the post - * condition is true - */ - public static Observable doWhile(Observable source, Func0 postCondition) { - return Observable.create(new OperatorWhileDoWhile(source, TRUE, postCondition)); - } - - /** - * Return an Observable that replays the emissions from the source - * Observable so long as a condtion is true. - *

- * - * - * @param preCondition - * the condition to evaluate before subscribing to or - * replaying the source Observable - * @return an Observable that replays the emissions from the source - * Observable so long as preCondition is true - */ - public static Observable whileDo(Observable source, Func0 preCondition) { - return Observable.create(new OperatorWhileDoWhile(source, preCondition, preCondition)); - } - - /** - * Return an Observable that emits the emissions from a specified Observable - * if a condition evaluates to true, otherwise return an empty Observable. - *

- * - * - * @param - * the result value type - * @param condition - * the condition that decides whether to emit the emissions - * from the then Observable - * @param then - * the Observable sequence to emit to if {@code condition} is {@code true} - * @return an Observable that mimics the {@code then} Observable if the {@code condition} function evaluates to true, or an empty - * Observable otherwise - */ - public static Observable ifThen(Func0 condition, Observable then) { - return ifThen(condition, then, Observable. empty()); - } - - /** - * Return an Observable that emits the emissions from a specified Observable - * if a condition evaluates to true, otherwise return an empty Observable - * that runs on a specified Scheduler. - *

- * - * - * @param - * the result value type - * @param condition - * the condition that decides whether to emit the emissions - * from the then Observable - * @param then - * the Observable sequence to emit to if {@code condition} is {@code true} - * @param scheduler - * the Scheduler on which the empty Observable runs if the - * in case the condition returns false - * @return an Observable that mimics the {@code then} Observable if the {@code condition} function evaluates to true, or an empty - * Observable running on the specified Scheduler otherwise - */ - public static Observable ifThen(Func0 condition, Observable then, Scheduler scheduler) { - return ifThen(condition, then, Observable. empty().subscribeOn(scheduler)); - } - - /** - * Return an Observable that emits the emissions from one specified - * Observable if a condition evaluates to true, or from another specified - * Observable otherwise. - *

- * - * - * @param - * the result value type - * @param condition - * the condition that decides which Observable to emit the - * emissions from - * @param then - * the Observable sequence to emit to if {@code condition} is {@code true} - * @param orElse - * the Observable sequence to emit to if {@code condition} is {@code false} - * @return an Observable that mimics either the {@code then} or {@code orElse} Observables depending on a condition function - */ - public static Observable ifThen(Func0 condition, Observable then, - Observable orElse) { - return Observable.create(new OperatorIfThen(condition, then, orElse)); - } - /** Returns always true. */ - private static final class Func0True implements Func0 { - @Override - public Boolean call() { - return true; - } - } - - /** Returns always true function. */ - private static final Func0True TRUE = new Func0True(); -} diff --git a/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/operators/OperatorIfThen.java b/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/operators/OperatorIfThen.java deleted file mode 100644 index 68a60bcb51..0000000000 --- a/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/operators/OperatorIfThen.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.operators; - -import rx.Observable; -import rx.Observable.OnSubscribe; -import rx.Subscriber; -import rx.functions.Func0; - -/** - * Given a condition, subscribe to one of the observables when an Observer - * subscribes. - * - * @param - * the result value type - */ -public final class OperatorIfThen implements OnSubscribe { - final Func0 condition; - final Observable then; - final Observable orElse; - - public OperatorIfThen(Func0 condition, Observable then, Observable orElse) { - this.condition = condition; - this.then = then; - this.orElse = orElse; - } - - @Override - public void call(Subscriber t1) { - Observable target; - try { - if (condition.call()) { - target = then; - } else { - target = orElse; - } - } catch (Throwable t) { - t1.onError(t); - return; - } - target.subscribe(t1); - } -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/operators/OperatorSwitchCase.java b/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/operators/OperatorSwitchCase.java deleted file mode 100644 index ab5fbcf9f0..0000000000 --- a/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/operators/OperatorSwitchCase.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.operators; - -import java.util.Map; - -import rx.Observable; -import rx.Observable.OnSubscribe; -import rx.Subscriber; -import rx.functions.Func0; - -/** - * Select an observable from a map based on a case key returned by a selector - * function when an observer subscribes. - * - * @param - * the case key type - * @param - * the result value type - */ -public final class OperatorSwitchCase implements OnSubscribe { - final Func0 caseSelector; - final Map> mapOfCases; - final Observable defaultCase; - - public OperatorSwitchCase(Func0 caseSelector, - Map> mapOfCases, - Observable defaultCase) { - this.caseSelector = caseSelector; - this.mapOfCases = mapOfCases; - this.defaultCase = defaultCase; - } - - @Override - public void call(Subscriber t1) { - Observable target; - try { - K caseKey = caseSelector.call(); - if (mapOfCases.containsKey(caseKey)) { - target = mapOfCases.get(caseKey); - } else { - target = defaultCase; - } - } catch (Throwable t) { - t1.onError(t); - return; - } - target.subscribe(t1); - } -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/operators/OperatorWhileDoWhile.java b/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/operators/OperatorWhileDoWhile.java deleted file mode 100644 index 2cecb64132..0000000000 --- a/rxjava-contrib/rxjava-computation-expressions/src/main/java/rx/operators/OperatorWhileDoWhile.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.operators; - -import rx.Observable; -import rx.Observer; -import rx.Subscriber; -import rx.Observable.OnSubscribe; -import rx.functions.Func0; -import rx.subscriptions.SerialSubscription; - -/** - * Repeatedly subscribes to the source observable if the pre- or - * postcondition is true. - *

- * This combines the While and DoWhile into a single operation through - * the conditions. - * - * @param - * the result value type - */ -public final class OperatorWhileDoWhile implements OnSubscribe { - final Func0 preCondition; - final Func0 postCondition; - final Observable source; - - public OperatorWhileDoWhile(Observable source, - Func0 preCondition, Func0 postCondition) { - this.source = source; - this.preCondition = preCondition; - this.postCondition = postCondition; - } - - @Override - public void call(Subscriber child) { - boolean first; - try { - first = preCondition.call(); - } catch (Throwable t) { - child.onError(t); - return; - } - - if (first) { - SerialSubscription cancel = new SerialSubscription(); - child.add(cancel); - final SourceObserver sourceObserver = new SourceObserver(child, cancel); - - Subscriber firstSubscription = new Subscriber() { - - @Override - public void onCompleted() { - sourceObserver.onCompleted(); - } - - @Override - public void onError(Throwable e) { - sourceObserver.onError(e); - } - - @Override - public void onNext(T t) { - sourceObserver.onNext(t); - } - - }; - cancel.set(firstSubscription); - source.unsafeSubscribe(firstSubscription); - } else { - child.onCompleted(); - } - } - - /** Observe the source. */ - final class SourceObserver implements Observer { - final Subscriber actual; - final SerialSubscription cancel; - - public SourceObserver(Subscriber actual, SerialSubscription cancel) { - this.actual = actual; - this.cancel = cancel; - } - - @Override - public void onNext(T args) { - actual.onNext(args); - } - - @Override - public void onError(Throwable e) { - actual.onError(e); - } - - @Override - public void onCompleted() { - boolean next; - try { - next = postCondition.call(); - } catch (Throwable t) { - actual.onError(t); - return; - } - if (next) { - Subscriber newSubscription = new Subscriber() { - - @Override - public void onCompleted() { - SourceObserver.this.onCompleted(); - } - - @Override - public void onError(Throwable e) { - SourceObserver.this.onError(e); - } - - @Override - public void onNext(T t) { - SourceObserver.this.onNext(t); - } - - }; - cancel.set(newSubscription); - source.unsafeSubscribe(newSubscription); - - } else { - actual.onCompleted(); - } - } - - } -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-computation-expressions/src/test/java/rx/operators/OperatorConditionalsTest.java b/rxjava-contrib/rxjava-computation-expressions/src/test/java/rx/operators/OperatorConditionalsTest.java deleted file mode 100644 index 5319881ab9..0000000000 --- a/rxjava-contrib/rxjava-computation-expressions/src/test/java/rx/operators/OperatorConditionalsTest.java +++ /dev/null @@ -1,487 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.operators; - -import static org.mockito.Matchers.*; -import static org.mockito.Mockito.*; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import rx.Observable; -import rx.Observer; -import rx.Statement; -import rx.Subscription; -import rx.functions.Func0; -import rx.observers.TestObserver; -import rx.schedulers.Schedulers; -import rx.schedulers.TestScheduler; - -public class OperatorConditionalsTest { - @Mock - Observer observer; - TestScheduler scheduler; - Func0 func; - Func0 funcError; - Func0 condition; - Func0 conditionError; - int numRecursion = 250; - - @Before - public void before() { - MockitoAnnotations.initMocks(this); - scheduler = new TestScheduler(); - func = new Func0() { - int count = 1; - - @Override - public Integer call() { - return count++; - } - }; - funcError = new Func0() { - int count = 1; - - @Override - public Integer call() { - if (count == 2) { - throw new RuntimeException("Forced failure!"); - } - return count++; - } - }; - condition = new Func0() { - boolean r; - - @Override - public Boolean call() { - r = !r; - return r; - } - - }; - conditionError = new Func0() { - boolean r; - - @Override - public Boolean call() { - r = !r; - if (!r) { - throw new RuntimeException("Forced failure!"); - } - return r; - } - - }; - } - - Func0 just(final T value) { - return new Func0() { - @Override - public T call() { - return value; - } - }; - } - - @SuppressWarnings("unchecked") - void observe(Observable source, T... values) { - Observer o = mock(Observer.class); - - Subscription s = source.subscribe(new TestObserver(o)); - - InOrder inOrder = inOrder(o); - - for (T v : values) { - inOrder.verify(o, times(1)).onNext(v); - } - inOrder.verify(o, times(1)).onCompleted(); - verify(o, never()).onError(any(Throwable.class)); - - s.unsubscribe(); - - inOrder.verifyNoMoreInteractions(); - } - - @SuppressWarnings("unchecked") - void observeSequence(Observable source, Iterable values) { - Observer o = mock(Observer.class); - - TestObserver testObserver = new TestObserver(o); - Subscription s = source.subscribe(testObserver); - - InOrder inOrder = inOrder(o); - - for (T v : values) { - inOrder.verify(o, times(1)).onNext(v); - } - inOrder.verify(o, times(1)).onCompleted(); - verify(o, never()).onError(any(Throwable.class)); - - s.unsubscribe(); - - inOrder.verifyNoMoreInteractions(); - } - - @SuppressWarnings("unchecked") - void observeError(Observable source, Class error, T... valuesBeforeError) { - Observer o = mock(Observer.class); - - Subscription s = source.subscribe(new TestObserver(o)); - - InOrder inOrder = inOrder(o); - - for (T v : valuesBeforeError) { - inOrder.verify(o, times(1)).onNext(v); - } - inOrder.verify(o, times(1)).onError(any(error)); - verify(o, never()).onCompleted(); - - s.unsubscribe(); - - inOrder.verifyNoMoreInteractions(); - } - - @SuppressWarnings("unchecked") - void observeSequenceError(Observable source, Class error, Iterable valuesBeforeError) { - Observer o = mock(Observer.class); - - Subscription s = source.subscribe(new TestObserver(o)); - - InOrder inOrder = inOrder(o); - - for (T v : valuesBeforeError) { - inOrder.verify(o, times(1)).onNext(v); - } - inOrder.verify(o, times(1)).onError(any(error)); - verify(o, never()).onCompleted(); - - s.unsubscribe(); - - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testSimple() { - Observable source1 = Observable.just(1, 2, 3); - Observable source2 = Observable.just(4, 5, 6); - - Map> map = new HashMap>(); - map.put(1, source1); - map.put(2, source2); - - Observable result = Statement.switchCase(func, map); - - observe(result, 1, 2, 3); - observe(result, 4, 5, 6); - observe(result); - } - - @Test - public void testDefaultCase() { - Observable source1 = Observable.just(1, 2, 3); - Observable source2 = Observable.just(4, 5, 6); - - Map> map = new HashMap>(); - map.put(1, source1); - - Observable result = Statement.switchCase(func, map, source2); - - observe(result, 1, 2, 3); - observe(result, 4, 5, 6); - observe(result, 4, 5, 6); - } - - @Test - public void testCaseSelectorThrows() { - Observable source1 = Observable.just(1, 2, 3); - - Map> map = new HashMap>(); - map.put(1, source1); - - Observable result = Statement.switchCase(funcError, map); - - observe(result, 1, 2, 3); - observeError(result, RuntimeException.class); - } - - @Test - public void testMapGetThrows() { - Observable source1 = Observable.just(1, 2, 3); - Observable source2 = Observable.just(4, 5, 6); - - Map> map = new HashMap>() { - private static final long serialVersionUID = -4342868139960216388L; - - @Override - public Observable get(Object key) { - if (key.equals(2)) { - throw new RuntimeException("Forced failure!"); - } - return super.get(key); - } - - }; - map.put(1, source1); - map.put(2, source2); - - Observable result = Statement.switchCase(func, map); - - observe(result, 1, 2, 3); - observeError(result, RuntimeException.class); - } - - @Test - public void testMapContainsKeyThrows() { - Observable source1 = Observable.just(1, 2, 3); - - Map> map = new HashMap>() { - private static final long serialVersionUID = 1975411728567003983L; - - @Override - public boolean containsKey(Object key) { - if (key.equals(2)) { - throw new RuntimeException("Forced failure!"); - } - return super.containsKey(key); - } - - }; - map.put(1, source1); - - Observable result = Statement.switchCase(func, map); - - observe(result, 1, 2, 3); - observeError(result, RuntimeException.class); - } - - @Test - public void testChosenObservableThrows() { - Observable source1 = Observable.just(1, 2, 3); - Observable source2 = Observable.error(new RuntimeException("Forced failure")); - - Map> map = new HashMap>(); - map.put(1, source1); - map.put(2, source2); - - Observable result = Statement.switchCase(func, map); - - observe(result, 1, 2, 3); - observeError(result, RuntimeException.class); - } - - @Test - public void testIfThen() { - Observable source1 = Observable.just(1, 2, 3); - - Observable result = Statement.ifThen(condition, source1); - - observe(result, 1, 2, 3); - observe(result); - observe(result, 1, 2, 3); - observe(result); - } - - @Test - public void testIfThenElse() { - Observable source1 = Observable.just(1, 2, 3); - Observable source2 = Observable.just(4, 5, 6); - - Observable result = Statement.ifThen(condition, source1, source2); - - observe(result, 1, 2, 3); - observe(result, 4, 5, 6); - observe(result, 1, 2, 3); - observe(result, 4, 5, 6); - } - - @Test - public void testIfThenConditonThrows() { - Observable source1 = Observable.just(1, 2, 3); - - Observable result = Statement.ifThen(conditionError, source1); - - observe(result, 1, 2, 3); - observeError(result, RuntimeException.class); - observe(result, 1, 2, 3); - observeError(result, RuntimeException.class); - } - - @Test - public void testIfThenObservableThrows() { - Observable source1 = Observable.error(new RuntimeException("Forced failure!")); - - Observable result = Statement.ifThen(condition, source1); - - observeError(result, RuntimeException.class); - observe(result); - - observeError(result, RuntimeException.class); - observe(result); - } - - @Test - public void testIfThenElseObservableThrows() { - Observable source1 = Observable.just(1, 2, 3); - Observable source2 = Observable.error(new RuntimeException("Forced failure!")); - - Observable result = Statement.ifThen(condition, source1, source2); - - observe(result, 1, 2, 3); - observeError(result, RuntimeException.class); - observe(result, 1, 2, 3); - observeError(result, RuntimeException.class); - } - - @Test - public void testDoWhile() { - Observable source1 = Observable.just(1, 2, 3); - - Observable result = Statement.doWhile(source1, condition); - - observe(result, 1, 2, 3, 1, 2, 3); - } - - @Test - public void testDoWhileOnce() { - Observable source1 = Observable.just(1, 2, 3); - - condition.call(); // toggle to false - Observable result = Statement.doWhile(source1, condition); - - observe(result, 1, 2, 3); - } - - @Test - public void testDoWhileConditionThrows() { - Observable source1 = Observable.just(1, 2, 3); - Observable result = Statement.doWhile(source1, conditionError); - - observeError(result, RuntimeException.class, 1, 2, 3); - } - - @Test - public void testDoWhileSourceThrows() { - Observable source1 = Observable.concat(Observable.just(1, 2, 3), - Observable. error(new RuntimeException("Forced failure!"))); - - Observable result = Statement.doWhile(source1, condition); - - observeError(result, RuntimeException.class, 1, 2, 3); - } - - Func0 countdown(final int n) { - return new Func0() { - int count = n; - - @Override - public Boolean call() { - return count-- > 0; - } - }; - } - - @Test - public void testDoWhileManyTimes() { - Observable source1 = Observable.just(1, 2, 3).subscribeOn(Schedulers.trampoline()); - - List expected = new ArrayList(numRecursion * 3); - for (int i = 0; i < numRecursion; i++) { - expected.add(1); - expected.add(2); - expected.add(3); - } - - Observable result = Statement.doWhile(source1, countdown(numRecursion)); - - observeSequence(result, expected); - } - - @Test - public void testWhileDo() { - Observable source1 = Observable.just(1, 2, 3); - Observable result = Statement.whileDo(source1, countdown(2)); - - observe(result, 1, 2, 3, 1, 2, 3); - } - - @Test - public void testWhileDoOnce() { - Observable source1 = Observable.just(1, 2, 3); - Observable result = Statement.whileDo(source1, countdown(1)); - - observe(result, 1, 2, 3); - } - - @Test - public void testWhileDoZeroTimes() { - Observable source1 = Observable.just(1, 2, 3); - Observable result = Statement.whileDo(source1, countdown(0)); - - observe(result); - } - - @Test - public void testWhileDoManyTimes() { - Observable source1 = Observable.just(1, 2, 3).subscribeOn(Schedulers.trampoline()); - - List expected = new ArrayList(numRecursion * 3); - for (int i = 0; i < numRecursion; i++) { - expected.add(1); - expected.add(2); - expected.add(3); - } - - Observable result = Statement.whileDo(source1, countdown(numRecursion)); - - observeSequence(result, expected); - } - - @Test - public void testWhileDoConditionThrows() { - Observable source1 = Observable.just(1, 2, 3); - Observable result = Statement.whileDo(source1, conditionError); - - observeError(result, RuntimeException.class, 1, 2, 3); - } - - @Test - public void testWhileDoConditionThrowsImmediately() { - Observable source1 = Observable.just(1, 2, 3); - conditionError.call(); - Observable result = Statement.whileDo(source1, conditionError); - - observeError(result, RuntimeException.class); - } - - @Test - public void testWhileDoSourceThrows() { - Observable source1 = Observable.concat(Observable.just(1, 2, 3), - Observable. error(new RuntimeException("Forced failure!"))); - - Observable result = Statement.whileDo(source1, condition); - - observeError(result, RuntimeException.class, 1, 2, 3); - } -} diff --git a/rxjava-contrib/rxjava-debug/build.gradle b/rxjava-contrib/rxjava-debug/build.gradle deleted file mode 100644 index cfec15f6f7..0000000000 --- a/rxjava-contrib/rxjava-debug/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -apply plugin: 'osgi' - -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - -dependencies { - compile project(':rxjava') - testCompile project(":rxjava").sourceSets.test.output - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' -} - -javadoc { - options { - doclet = "org.benjchristensen.doclet.DocletExclude" - docletpath = [rootProject.file('./gradle/doclet-exclude.jar')] - stylesheetFile = rootProject.file('./gradle/javadocStyleSheet.css') - windowTitle = "RxJava Javadoc ${project.version}" - } - options.addStringOption('top').value = '

RxJava

' -} - -jar { - manifest { - name = 'rxjava-debug' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/ReactiveX/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } -} diff --git a/rxjava-contrib/rxjava-debug/src/main/java/rx/operators/DebugSubscriber.java b/rxjava-contrib/rxjava-debug/src/main/java/rx/operators/DebugSubscriber.java deleted file mode 100644 index f8ef22e9a5..0000000000 --- a/rxjava-contrib/rxjava-debug/src/main/java/rx/operators/DebugSubscriber.java +++ /dev/null @@ -1,85 +0,0 @@ -package rx.operators; - -import rx.Observable.Operator; -import rx.Observer; -import rx.Subscriber; -import rx.plugins.DebugNotification; -import rx.plugins.DebugNotificationListener; - -public final class DebugSubscriber extends Subscriber { - private DebugNotificationListener listener; - private final Observer o; - private Operator from = null; - private Operator to = null; - - public DebugSubscriber( - DebugNotificationListener listener, - Subscriber _o, - Operator _out, - Operator _in) { - super(_o); - this.listener = listener; - this.o = _o; - this.from = _out; - this.to = _in; - this.add(new DebugSubscription(this, listener)); - } - - @Override - public void onCompleted() { - final DebugNotification n = DebugNotification.createOnCompleted(o, from, to); - C context = listener.start(n); - try { - o.onCompleted(); - listener.complete(context); - } catch (Throwable e) { - listener.error(context, e); - } - } - - @Override - public void onError(Throwable e) { - final DebugNotification n = DebugNotification.createOnError(o, from, e, to); - C context = listener.start(n); - try { - o.onError(e); - listener.complete(context); - } catch (Throwable e2) { - listener.error(context, e2); - } - } - - @Override - public void onNext(T t) { - final DebugNotification n = DebugNotification.createOnNext(o, from, t, to); - t = (T) listener.onNext(n); - - C context = listener.start(n); - try { - o.onNext(t); - listener.complete(context); - } catch (Throwable e) { - listener.error(context, e); - } - } - - public Operator getFrom() { - return from; - } - - public void setFrom(Operator bind) { - this.from = bind; - } - - public Operator getTo() { - return to; - } - - public void setTo(Operator op) { - this.to = op; - } - - public Observer getActual() { - return o; - } -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-debug/src/main/java/rx/operators/DebugSubscription.java b/rxjava-contrib/rxjava-debug/src/main/java/rx/operators/DebugSubscription.java deleted file mode 100644 index 0a3ce9d5ef..0000000000 --- a/rxjava-contrib/rxjava-debug/src/main/java/rx/operators/DebugSubscription.java +++ /dev/null @@ -1,32 +0,0 @@ -package rx.operators; - -import rx.Subscription; -import rx.plugins.DebugNotification; -import rx.plugins.DebugNotificationListener; - -final class DebugSubscription implements Subscription { - private final DebugSubscriber debugObserver; - private DebugNotificationListener listener; - - DebugSubscription(DebugSubscriber debugObserver, DebugNotificationListener listener) { - this.debugObserver = debugObserver; - this.listener = listener; - } - - @Override - public void unsubscribe() { - final DebugNotification n = DebugNotification. createUnsubscribe(debugObserver.getActual(), debugObserver.getFrom(), debugObserver.getTo()); - C context = listener.start(n); - try { - debugObserver.unsubscribe(); - listener.complete(context); - } catch (Throwable e) { - listener.error(context, e); - } - } - - @Override - public boolean isUnsubscribed() { - return debugObserver.isUnsubscribed(); - } -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-debug/src/main/java/rx/plugins/DebugHook.java b/rxjava-contrib/rxjava-debug/src/main/java/rx/plugins/DebugHook.java deleted file mode 100644 index 22d61a16d6..0000000000 --- a/rxjava-contrib/rxjava-debug/src/main/java/rx/plugins/DebugHook.java +++ /dev/null @@ -1,110 +0,0 @@ -package rx.plugins; - -import rx.Observable; -import rx.Observable.OnSubscribe; -import rx.Observable.Operator; -import rx.Subscriber; -import rx.Subscription; -import rx.operators.DebugSubscriber; - -/** - * Implements hooks into the {@link Observable} chain to emit a detailed account of all the events - * that happened. - * - * @author gscampbell - */ -public class DebugHook extends RxJavaObservableExecutionHook { - private DebugNotificationListener listener; - - /** - * Creates a new instance of the DebugHook RxJava plug-in that can be passed into - * {@link RxJavaPlugins} registerObservableExecutionHook(hook) method. - * - * @param listener - * all of the onNext values are passed through this function to allow for - * manipulation of the values - */ - public DebugHook(DebugNotificationListener listener) { - if (listener == null) - throw new IllegalArgumentException("The debug listener must not be null"); - this.listener = listener; - } - - @Override - public OnSubscribe onSubscribeStart(final Observable observableInstance, final OnSubscribe f) { - return new OnSubscribe() { - @Override - public void call(Subscriber o) { - final DebugNotification n = DebugNotification.createSubscribe(o, observableInstance, f); - o = wrapOutbound(null, o); - - C context = listener.start(n); - try { - f.call(o); - listener.complete(context); - } - catch(Throwable e) { - listener.error(context, e); - } - } - }; - } - - @Override - public Subscription onSubscribeReturn(Subscription subscription) { - return subscription; - } - - @Override - public OnSubscribe onCreate(final OnSubscribe f) { - return new DebugOnSubscribe(f); - } - - public final class DebugOnSubscribe implements OnSubscribe { - private final OnSubscribe f; - - private DebugOnSubscribe(OnSubscribe f) { - this.f = f; - } - - @Override - public void call(Subscriber o) { - f.call(wrapInbound(null, o)); - } - - public OnSubscribe getActual() { - return f; - } - } - - - @Override - public Operator onLift(final Operator bind) { - return new Operator() { - @Override - public Subscriber call(final Subscriber o) { - return wrapInbound(bind, bind.call(wrapOutbound(bind, o))); - } - }; - } - - @SuppressWarnings("unchecked") - private Subscriber wrapOutbound(Operator bind, Subscriber o) { - if (o instanceof DebugSubscriber) { - if (bind != null) - ((DebugSubscriber) o).setFrom(bind); - return o; - } - return new DebugSubscriber(listener, o, bind, null); - } - - @SuppressWarnings("unchecked") - private Subscriber wrapInbound(Operator bind, Subscriber o) { - if (o instanceof DebugSubscriber) { - if (bind != null) - ((DebugSubscriber) o).setTo(bind); - return o; - } - return new DebugSubscriber(listener, o, null, bind); - } -} diff --git a/rxjava-contrib/rxjava-debug/src/main/java/rx/plugins/DebugNotification.java b/rxjava-contrib/rxjava-debug/src/main/java/rx/plugins/DebugNotification.java deleted file mode 100644 index ba195aa384..0000000000 --- a/rxjava-contrib/rxjava-debug/src/main/java/rx/plugins/DebugNotification.java +++ /dev/null @@ -1,195 +0,0 @@ -package rx.plugins; - -import rx.Observable; -import rx.Observable.OnSubscribe; -import rx.Observable.Operator; -import rx.Observer; -import rx.observers.SafeSubscriber; -import rx.operators.DebugSubscriber; - -public class DebugNotification { - public static enum Kind { - OnNext, OnError, OnCompleted, Subscribe, Unsubscribe - } - - private final Observable source; - private final OnSubscribe sourceFunc; - private final Operator from; - private final Kind kind; - private final Operator to; - private final Throwable throwable; - private final T value; - @SuppressWarnings("rawtypes") - private final Observer observer; - - @SuppressWarnings("unchecked") - public static DebugNotification createSubscribe(Observer o, Observable source, OnSubscribe sourceFunc) { - Operator to = null; - Operator from = null; - if (o instanceof SafeSubscriber) { - o = ((SafeSubscriber) o).getActual(); - } - if (o instanceof DebugSubscriber) { - @SuppressWarnings("rawtypes") - final DebugSubscriber ds = (DebugSubscriber) o; - to = ds.getTo(); - from = ds.getFrom(); - o = ds.getActual(); - } - if (sourceFunc instanceof DebugHook.DebugOnSubscribe) { - sourceFunc = ((DebugHook.DebugOnSubscribe) sourceFunc).getActual(); - } - return new DebugNotification(o, from, Kind.Subscribe, null, null, to, source, sourceFunc); - } - - public static DebugNotification createOnNext(Observer o, Operator from, T t, Operator to) { - return new DebugNotification(o, from, Kind.OnNext, t, null, to, null, null); - } - - public static DebugNotification createOnError(Observer o, Operator from, Throwable e, Operator to) { - return new DebugNotification(o, from, Kind.OnError, null, e, to, null, null); - } - - public static DebugNotification createOnCompleted(Observer o, Operator from, Operator to) { - return new DebugNotification(o, from, Kind.OnCompleted, null, null, to, null, null); - } - - public static DebugNotification createUnsubscribe(Observer o, Operator from, Operator to) { - return new DebugNotification(o, from, Kind.Unsubscribe, null, null, to, null, null); - } - - @SuppressWarnings("rawtypes") - private DebugNotification(Observer o, Operator from, Kind kind, T value, Throwable throwable, Operator to, Observable source, OnSubscribe sourceFunc) { - this.observer = (o instanceof SafeSubscriber) ? ((SafeSubscriber) o).getActual() : o; - this.from = from; - this.kind = kind; - this.value = value; - this.throwable = throwable; - this.to = to; - this.source = source; - this.sourceFunc = sourceFunc; - } - - @SuppressWarnings("rawtypes") - public Observer getObserver() { - return observer; - } - - public Operator getFrom() { - return from; - } - - public T getValue() { - return value; - } - - public Throwable getThrowable() { - return throwable; - } - - public Operator getTo() { - return to; - } - - public Kind getKind() { - return kind; - } - - public Observable getSource() { - return source; - } - - public OnSubscribe getSourceFunc() { - return sourceFunc; - } - - @Override - /** - * Does a very bad job of making JSON like string. - */ - public String toString() { - final StringBuilder s = new StringBuilder("{"); - s.append("\"observer\": "); - if (observer != null) - s.append("\"").append(observer.getClass().getName()).append("@").append(Integer.toHexString(observer.hashCode())).append("\""); - else - s.append("null"); - s.append(", \"type\": \"").append(kind).append("\""); - if (kind == Kind.OnNext) - s.append(", \"value\": ").append(quote(value)).append(""); - if (kind == Kind.OnError) - s.append(", \"exception\": \"").append(throwable.getMessage().replace("\\", "\\\\").replace("\"", "\\\"")).append("\""); - if (source != null) - s.append(", \"source\": \"").append(source.getClass().getName()).append("@").append(Integer.toHexString(source.hashCode())).append("\""); - if (sourceFunc != null) - s.append(", \"sourceFunc\": \"").append(sourceFunc.getClass().getName()).append("@").append(Integer.toHexString(sourceFunc.hashCode())).append("\""); - if (from != null) - s.append(", \"from\": \"").append(from.getClass().getName()).append("@").append(Integer.toHexString(from.hashCode())).append("\""); - if (to != null) - s.append(", \"to\": \"").append(to.getClass().getName()).append("@").append(Integer.toHexString(to.hashCode())).append("\""); - s.append("}"); - return s.toString(); - } - - public static String quote(Object obj) { - if (obj == null) { - return "null"; - } - - String string; - try { - string = obj.toString(); - } catch (Throwable e) { - return "\"\""; - } - if (string == null || string.length() == 0) { - return "\"\""; - } - - char c = 0; - int i; - int len = string.length(); - StringBuilder sb = new StringBuilder(len + 4); - String t; - - sb.append('"'); - for (i = 0; i < len; i += 1) { - c = string.charAt(i); - switch (c) { - case '\\': - case '"': - sb.append('\\'); - sb.append(c); - break; - case '/': - sb.append('\\'); - sb.append(c); - break; - case '\b': - sb.append("\\b"); - break; - case '\t': - sb.append("\\t"); - break; - case '\n': - sb.append("\\n"); - break; - case '\f': - sb.append("\\f"); - break; - case '\r': - sb.append("\\r"); - break; - default: - if (c < ' ') { - t = "000" + Integer.toHexString(c); - sb.append("\\u" + t.substring(t.length() - 4)); - } else { - sb.append(c); - } - } - } - sb.append('"'); - return sb.toString(); - } -} diff --git a/rxjava-contrib/rxjava-debug/src/main/java/rx/plugins/DebugNotificationListener.java b/rxjava-contrib/rxjava-debug/src/main/java/rx/plugins/DebugNotificationListener.java deleted file mode 100644 index 7c306a01ac..0000000000 --- a/rxjava-contrib/rxjava-debug/src/main/java/rx/plugins/DebugNotificationListener.java +++ /dev/null @@ -1,70 +0,0 @@ -package rx.plugins; - -import rx.Observable; -import rx.Observable.Operator; -import rx.Observer; - -/** - * Subclasses of this are passed into the constructor of {@link DebugHook} to receive notification - * about all activity in Rx. - * - * @author gscampbell - * - * @param - * Context type that is returned from start and passed to either complete or error. - * @see DebugHook - */ -public abstract class DebugNotificationListener { - /** - * Override this to change the default behavior of returning the encapsulated value. This will - * only be invoked when the {@link DebugNotification#getKind()} is - * {@link DebugNotification.Kind#OnNext} and the value (null or not) is just about to be sent to - * next {@link Observer}. This can end up being called multiple times for - * the same value as it passes from {@link Operator} to {@link Operator} in the - * {@link Observable} chain. - *

- * This can be used to decorate or replace the values passed into any onNext function or just - * perform extra logging, metrics and other such things and pass-thru the function. - * - * @param n - * {@link DebugNotification} containing the data and context about what is happening. - * @return the notification's value - */ - public T onNext(DebugNotification n) { - return n.getValue(); - } - - /** - * For each {@link DebugNotification.Kind} start is invoked before the actual method is invoked. - *

- * This can be used to perform extra logging, metrics and other such things. - * - * @param n - * {@link DebugNotification} containing the data and context about what is happening. - * @return - * A contextual object that the listener can use in the {@link #complete(Object) } or - * {@link #error(Object, Throwable)} after the actual operation has ended. - */ - public C start(DebugNotification n) { - return null; - } - - /** - * After the actual operations has completed from {@link #start(DebugNotification)} this is - * invoked - * - * @param context - */ - public void complete(C context) { - } - - /** - * After the actual operations has thrown an exception from {@link #start(DebugNotification)} - * this is invoked - * - * @param context - * @param e - */ - public void error(C context, Throwable e) { - } -} diff --git a/rxjava-contrib/rxjava-debug/src/test/java/rx/debug/DebugHookTest.java b/rxjava-contrib/rxjava-debug/src/test/java/rx/debug/DebugHookTest.java deleted file mode 100644 index 2e4d901c71..0000000000 --- a/rxjava-contrib/rxjava-debug/src/test/java/rx/debug/DebugHookTest.java +++ /dev/null @@ -1,270 +0,0 @@ -package rx.debug; - -import static org.junit.Assert.*; -import static org.mockito.Matchers.*; -import static org.mockito.Mockito.*; - -import java.util.Arrays; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; - -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.InOrder; - -import rx.Observable; -import rx.functions.Func1; -import rx.observers.Subscribers; -import rx.plugins.DebugHook; -import rx.plugins.DebugNotification; -import rx.plugins.DebugNotification.Kind; -import rx.plugins.DebugNotificationListener; -import rx.plugins.PlugReset; -import rx.plugins.RxJavaPlugins; - -public class DebugHookTest { - @Before - @After - public void reset() { - PlugReset.reset(); - } - - private static class TestDebugNotificationListener extends DebugNotificationListener { - ConcurrentHashMap allThreadDepths = new ConcurrentHashMap(1); - ThreadLocal currentThreadDepth = new ThreadLocal() { - protected AtomicInteger initialValue() { - AtomicInteger depth = new AtomicInteger(); - allThreadDepths.put(Thread.currentThread(), depth); - return depth; - }; - }; - - @Override - public T onNext(DebugNotification n) { - if (n == null) - return null; // because we are verifying on a spied object. - System.err.println("next: " + n.getValue()); - return super.onNext(n); - } - - @Override - public Object start(DebugNotification n) { - if (n == null) - return null; // because we are verifying on a spied object. - currentThreadDepth.get().incrementAndGet(); - Object context = new Object(); - System.err.println("start: " + Integer.toHexString(context.hashCode()) + " " + n); - return context; - } - - @Override - public void complete(Object context) { - if (context == null) - return; // because we are verifying on a spied object. - currentThreadDepth.get().decrementAndGet(); - System.err.println("complete: " + Integer.toHexString(context.hashCode())); - } - - @Override - public void error(Object context, Throwable e) { - if (context == null) - return; // because we are verifying on a spied object. - currentThreadDepth.get().decrementAndGet(); - System.err.println("error: " + Integer.toHexString(context.hashCode())); - } - - public void assertValidState() { - for (Entry threadDepth : allThreadDepths.entrySet()) { - assertEquals(0, threadDepth.getValue().get()); - } - } - } - - @SuppressWarnings("unchecked") - @Ignore - @Test - public void testSimple() { - TestDebugNotificationListener listener = new TestDebugNotificationListener(); - listener = spy(listener); - @SuppressWarnings("rawtypes") - final DebugHook hook = new DebugHook(listener); - RxJavaPlugins.getInstance().registerObservableExecutionHook(hook); - - Observable.just(1).subscribe(Subscribers.empty()); - - final InOrder inOrder = inOrder(listener); - inOrder.verify(listener).start(subscribe()); - inOrder.verify(listener).onNext(onNext(1)); - inOrder.verify(listener).start(onNext(1)); - inOrder.verify(listener).complete(any()); - inOrder.verify(listener).start(onCompleted()); - inOrder.verify(listener, times(2)).complete(any()); - inOrder.verifyNoMoreInteractions(); - - listener.assertValidState(); - } - - @SuppressWarnings("unchecked") - @Ignore - @Test - public void testOneOp() { - TestDebugNotificationListener listener = new TestDebugNotificationListener(); - listener = spy(listener); - - // create and register the hooks. - final DebugHook hook = new DebugHook(listener); - RxJavaPlugins.getInstance().registerObservableExecutionHook(hook); - - // do the operation - Observable - .from(Arrays.asList(1, 3)) - .flatMap(new Func1>() { - @Override - public Observable call(Integer it) { - return Observable.from(Arrays.asList(it * 10, (it + 1) * 10)); - } - }) - .take(3) - .subscribe(Subscribers. empty()); - - InOrder calls = inOrder(listener); - - calls.verify(listener).start(subscribe()); - calls.verify(listener).start(onNext(1)); // from to map - calls.verify(listener).start(onNext(Observable.class)); // map to merge - calls.verify(listener).start(subscribe()); // merge inner - calls.verify(listener).start(onNext(10)); // from to merge inner - calls.verify(listener).start(onNext(10)); // merge inner to take - calls.verify(listener).start(onNext(10)); // take to empty subscriber - calls.verify(listener, times(3)).complete(any()); - calls.verify(listener).start(onNext(20)); // next from to merge inner - calls.verify(listener).start(onNext(20)); // merge inner to take - calls.verify(listener).start(onNext(20)); // take to output - calls.verify(listener, times(3)).complete(any()); - calls.verify(listener).start(onCompleted()); // sub from completes - // calls.verify(listener).start(unsubscribe()); // merge's composite subscription - // unnecessarily calls unsubscribe during the removing the subscription from the array. - // - // i didn't include it because it could cause a test failure if the internals change. - calls.verify(listener, times(5)).complete(any()); // pop the call stack up to onNext(1) - calls.verify(listener).start(onNext(3)); // from to map - calls.verify(listener).start(onNext(Observable.class)); // map to merge - calls.verify(listener).start(subscribe()); - calls.verify(listener).start(onNext(30)); // next from to merge inner - calls.verify(listener).start(onNext(30)); // merge inner to take - calls.verify(listener).start(onNext(30)); // take to output - calls.verify(listener).complete(any()); - calls.verify(listener).start(onCompleted()); // take to output - calls.verify(listener).start(unsubscribe()); // take unsubscribes - calls.verify(listener).complete(any()); - calls.verify(listener).start(unsubscribe()); // merge inner unsubscribes - calls.verify(listener).complete(any()); - calls.verify(listener).start(unsubscribe()); // merge outer unsubscribes - calls.verify(listener).complete(any()); - calls.verify(listener).start(unsubscribe()); // map unsubscribe - calls.verify(listener, times(7)).complete(any()); - calls.verifyNoMoreInteractions(); - - listener.assertValidState(); - } - - private static DebugNotification onNext(final T value) { - return argThat(new BaseMatcher>() { - @Override - public boolean matches(Object item) { - if (item instanceof DebugNotification) { - @SuppressWarnings("unchecked") - DebugNotification dn = (DebugNotification) item; - return dn.getKind() == Kind.OnNext && dn.getValue().equals(value); - } - return false; - } - - @Override - public void describeTo(Description description) { - description.appendText("OnNext " + value); - } - }); - } - - private static DebugNotification onNext(final Class type) { - return argThat(new BaseMatcher>() { - @Override - public boolean matches(Object item) { - if (item instanceof DebugNotification) { - @SuppressWarnings("unchecked") - DebugNotification dn = (DebugNotification) item; - return dn.getKind() == Kind.OnNext && type.isAssignableFrom(dn.getValue().getClass()); - } - return false; - } - - @Override - public void describeTo(Description description) { - description.appendText("OnNext " + type); - } - }); - } - - @SuppressWarnings("rawtypes") - private static DebugNotification subscribe() { - return argThat(new BaseMatcher>() { - @Override - public boolean matches(Object item) { - if (item instanceof DebugNotification) { - DebugNotification dn = (DebugNotification) item; - return dn.getKind() == DebugNotification.Kind.Subscribe; - } - return false; - } - - @Override - public void describeTo(Description description) { - description.appendText("Subscribe"); - } - }); - } - - @SuppressWarnings("rawtypes") - private static DebugNotification unsubscribe() { - return argThat(new BaseMatcher>() { - @Override - public boolean matches(Object item) { - if (item instanceof DebugNotification) { - DebugNotification dn = (DebugNotification) item; - return dn.getKind() == DebugNotification.Kind.Unsubscribe; - } - return false; - } - - @Override - public void describeTo(Description description) { - description.appendText("Unsubscribe"); - } - }); - } - - @SuppressWarnings("rawtypes") - private static DebugNotification onCompleted() { - return argThat(new BaseMatcher() { - @Override - public boolean matches(Object item) { - if (item instanceof DebugNotification) { - DebugNotification dn = (DebugNotification) item; - return dn.getKind() == Kind.OnCompleted; - } - return false; - } - - @Override - public void describeTo(Description description) { - description.appendText("onCompleted"); - } - }); - } -} diff --git a/rxjava-contrib/rxjava-debug/src/test/java/rx/plugins/PlugReset.java b/rxjava-contrib/rxjava-debug/src/test/java/rx/plugins/PlugReset.java deleted file mode 100644 index 0292d1b5e3..0000000000 --- a/rxjava-contrib/rxjava-debug/src/test/java/rx/plugins/PlugReset.java +++ /dev/null @@ -1,7 +0,0 @@ -package rx.plugins; - -public class PlugReset { - public static void reset() { - RxJavaPlugins.getInstance().reset(); - } -} diff --git a/rxjava-contrib/rxjava-joins/build.gradle b/rxjava-contrib/rxjava-joins/build.gradle deleted file mode 100644 index d888843187..0000000000 --- a/rxjava-contrib/rxjava-joins/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -apply plugin: 'osgi' - -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - -dependencies { - compile project(':rxjava') - testCompile project(":rxjava").sourceSets.test.output - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' -} - -jar { - manifest { - name = 'rxjava-joins' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/ReactiveX/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan0.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan0.java deleted file mode 100644 index 94382b4c67..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan0.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.joins; - -import java.util.HashMap; -import java.util.Map; - -/** - * Represents an activated plan. - */ -public abstract class ActivePlan0 { - protected final Map joinObservers = new HashMap(); - - protected abstract void match(); - - protected void addJoinObserver(JoinObserver joinObserver) { - joinObservers.put(joinObserver, joinObserver); - } - - protected void dequeue() { - for (JoinObserver jo : joinObservers.values()) { - jo.dequeue(); - } - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan1.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan1.java deleted file mode 100644 index ea45aa5c27..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan1.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Notification; -import rx.functions.Action0; -import rx.functions.Action1; - -/** - * Represents an active plan. - */ -public final class ActivePlan1 extends ActivePlan0 { - private final Action1 onNext; - private final Action0 onCompleted; - private final JoinObserver1 jo1; - - ActivePlan1(JoinObserver1 jo1, Action1 onNext, Action0 onCompleted) { - this.onNext = onNext; - this.onCompleted = onCompleted; - this.jo1 = jo1; - addJoinObserver(jo1); - } - - @Override - protected void match() { - if (!jo1.queue().isEmpty()) { - Notification n1 = jo1.queue().peek(); - if (n1.isOnCompleted()) { - onCompleted.call(); - } else { - dequeue(); - onNext.call(n1.getValue()); - } - } - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan2.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan2.java deleted file mode 100644 index 66b8bc39c6..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan2.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Notification; -import rx.functions.Action0; -import rx.functions.Action2; - -/** - * Represents an active plan. - */ -public final class ActivePlan2 extends ActivePlan0 { - private final Action2 onNext; - private final Action0 onCompleted; - private final JoinObserver1 jo1; - private final JoinObserver1 jo2; - - ActivePlan2(JoinObserver1 jo1, JoinObserver1 jo2, Action2 onNext, Action0 onCompleted) { - this.onNext = onNext; - this.onCompleted = onCompleted; - this.jo1 = jo1; - this.jo2 = jo2; - addJoinObserver(jo1); - addJoinObserver(jo2); - } - - @Override - protected void match() { - if (!jo1.queue().isEmpty() && !jo2.queue().isEmpty()) { - Notification n1 = jo1.queue().peek(); - Notification n2 = jo2.queue().peek(); - - if (n1.isOnCompleted() || n2.isOnCompleted()) { - onCompleted.call(); - } else { - dequeue(); - onNext.call(n1.getValue(), n2.getValue()); - } - } - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan3.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan3.java deleted file mode 100644 index ddc9bc633e..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan3.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Notification; -import rx.functions.Action0; -import rx.functions.Action3; - -/** - * Represents an active plan. - */ -public final class ActivePlan3 extends ActivePlan0 { - private final Action3 onNext; - private final Action0 onCompleted; - private final JoinObserver1 first; - private final JoinObserver1 second; - private final JoinObserver1 third; - - ActivePlan3(JoinObserver1 first, - JoinObserver1 second, - JoinObserver1 third, - Action3 onNext, - Action0 onCompleted) { - this.onNext = onNext; - this.onCompleted = onCompleted; - this.first = first; - this.second = second; - this.third = third; - addJoinObserver(first); - addJoinObserver(second); - addJoinObserver(third); - } - - @Override - protected void match() { - if (!first.queue().isEmpty() - && !second.queue().isEmpty() - && !third.queue().isEmpty()) { - Notification n1 = first.queue().peek(); - Notification n2 = second.queue().peek(); - Notification n3 = third.queue().peek(); - - if (n1.isOnCompleted() || n2.isOnCompleted() || n3.isOnCompleted()) { - onCompleted.call(); - } else { - dequeue(); - onNext.call(n1.getValue(), n2.getValue(), n3.getValue()); - } - } - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan4.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan4.java deleted file mode 100644 index e3032dca4b..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan4.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Notification; -import rx.functions.Action0; -import rx.functions.Action4; - -/** - * Represents an active plan. - */ -public final class ActivePlan4 extends ActivePlan0 { - private final Action4 onNext; - private final Action0 onCompleted; - private final JoinObserver1 jo1; - private final JoinObserver1 jo2; - private final JoinObserver1 jo3; - private final JoinObserver1 jo4; - - ActivePlan4( - JoinObserver1 jo1, - JoinObserver1 jo2, - JoinObserver1 jo3, - JoinObserver1 jo4, - Action4 onNext, - Action0 onCompleted) { - this.onNext = onNext; - this.onCompleted = onCompleted; - this.jo1 = jo1; - this.jo2 = jo2; - this.jo3 = jo3; - this.jo4 = jo4; - addJoinObserver(jo1); - addJoinObserver(jo2); - addJoinObserver(jo3); - addJoinObserver(jo4); - } - - @Override - protected void match() { - if (!jo1.queue().isEmpty() - && !jo2.queue().isEmpty() - && !jo3.queue().isEmpty() - && !jo4.queue().isEmpty()) { - Notification n1 = jo1.queue().peek(); - Notification n2 = jo2.queue().peek(); - Notification n3 = jo3.queue().peek(); - Notification n4 = jo4.queue().peek(); - - if (n1.isOnCompleted() - || n2.isOnCompleted() - || n3.isOnCompleted() - || n4.isOnCompleted()) { - onCompleted.call(); - } else { - dequeue(); - onNext.call(n1.getValue(), n2.getValue(), n3.getValue(), n4.getValue()); - } - } - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan5.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan5.java deleted file mode 100644 index 4fff0da151..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan5.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Notification; -import rx.functions.Action0; -import rx.functions.Action5; - -/** - * Represents an active plan. - */ -public final class ActivePlan5 extends ActivePlan0 { - private final Action5 onNext; - private final Action0 onCompleted; - private final JoinObserver1 jo1; - private final JoinObserver1 jo2; - private final JoinObserver1 jo3; - private final JoinObserver1 jo4; - private final JoinObserver1 jo5; - - ActivePlan5( - JoinObserver1 jo1, - JoinObserver1 jo2, - JoinObserver1 jo3, - JoinObserver1 jo4, - JoinObserver1 jo5, - Action5 onNext, - Action0 onCompleted) { - this.onNext = onNext; - this.onCompleted = onCompleted; - this.jo1 = jo1; - this.jo2 = jo2; - this.jo3 = jo3; - this.jo4 = jo4; - this.jo5 = jo5; - addJoinObserver(jo1); - addJoinObserver(jo2); - addJoinObserver(jo3); - addJoinObserver(jo4); - addJoinObserver(jo5); - } - - @Override - protected void match() { - if (!jo1.queue().isEmpty() - && !jo2.queue().isEmpty() - && !jo3.queue().isEmpty() - && !jo4.queue().isEmpty() - && !jo5.queue().isEmpty() - ) { - Notification n1 = jo1.queue().peek(); - Notification n2 = jo2.queue().peek(); - Notification n3 = jo3.queue().peek(); - Notification n4 = jo4.queue().peek(); - Notification n5 = jo5.queue().peek(); - - if (n1.isOnCompleted() - || n2.isOnCompleted() - || n3.isOnCompleted() - || n4.isOnCompleted() - || n5.isOnCompleted() - ) { - onCompleted.call(); - } else { - dequeue(); - onNext.call( - n1.getValue(), - n2.getValue(), - n3.getValue(), - n4.getValue(), - n5.getValue() - ); - } - } - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan6.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan6.java deleted file mode 100644 index 36076aa9b4..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan6.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Notification; -import rx.functions.Action0; -import rx.functions.Action6; - -/** - * Represents an active plan. - */ -public final class ActivePlan6 extends ActivePlan0 { - private final Action6 onNext; - private final Action0 onCompleted; - private final JoinObserver1 jo1; - private final JoinObserver1 jo2; - private final JoinObserver1 jo3; - private final JoinObserver1 jo4; - private final JoinObserver1 jo5; - private final JoinObserver1 jo6; - - ActivePlan6( - JoinObserver1 jo1, - JoinObserver1 jo2, - JoinObserver1 jo3, - JoinObserver1 jo4, - JoinObserver1 jo5, - JoinObserver1 jo6, - Action6 onNext, - Action0 onCompleted) { - this.onNext = onNext; - this.onCompleted = onCompleted; - this.jo1 = jo1; - this.jo2 = jo2; - this.jo3 = jo3; - this.jo4 = jo4; - this.jo5 = jo5; - this.jo6 = jo6; - addJoinObserver(jo1); - addJoinObserver(jo2); - addJoinObserver(jo3); - addJoinObserver(jo4); - addJoinObserver(jo5); - addJoinObserver(jo6); - } - - @Override - protected void match() { - if (!jo1.queue().isEmpty() - && !jo2.queue().isEmpty() - && !jo3.queue().isEmpty() - && !jo4.queue().isEmpty() - && !jo5.queue().isEmpty() - && !jo6.queue().isEmpty() - ) { - Notification n1 = jo1.queue().peek(); - Notification n2 = jo2.queue().peek(); - Notification n3 = jo3.queue().peek(); - Notification n4 = jo4.queue().peek(); - Notification n5 = jo5.queue().peek(); - Notification n6 = jo6.queue().peek(); - - if (n1.isOnCompleted() - || n2.isOnCompleted() - || n3.isOnCompleted() - || n4.isOnCompleted() - || n5.isOnCompleted() - || n6.isOnCompleted() - ) { - onCompleted.call(); - } else { - dequeue(); - onNext.call( - n1.getValue(), - n2.getValue(), - n3.getValue(), - n4.getValue(), - n5.getValue(), - n6.getValue() - ); - } - } - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan7.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan7.java deleted file mode 100644 index cac20bdbcd..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan7.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Notification; -import rx.functions.Action0; -import rx.functions.Action7; - -/** - * Represents an active plan. - */ -public final class ActivePlan7 extends ActivePlan0 { - private final Action7 onNext; - private final Action0 onCompleted; - private final JoinObserver1 jo1; - private final JoinObserver1 jo2; - private final JoinObserver1 jo3; - private final JoinObserver1 jo4; - private final JoinObserver1 jo5; - private final JoinObserver1 jo6; - private final JoinObserver1 jo7; - - ActivePlan7( - JoinObserver1 jo1, - JoinObserver1 jo2, - JoinObserver1 jo3, - JoinObserver1 jo4, - JoinObserver1 jo5, - JoinObserver1 jo6, - JoinObserver1 jo7, - Action7 onNext, - Action0 onCompleted) { - this.onNext = onNext; - this.onCompleted = onCompleted; - this.jo1 = jo1; - this.jo2 = jo2; - this.jo3 = jo3; - this.jo4 = jo4; - this.jo5 = jo5; - this.jo6 = jo6; - this.jo7 = jo7; - addJoinObserver(jo1); - addJoinObserver(jo2); - addJoinObserver(jo3); - addJoinObserver(jo4); - addJoinObserver(jo5); - addJoinObserver(jo6); - addJoinObserver(jo7); - } - - @Override - protected void match() { - if (!jo1.queue().isEmpty() - && !jo2.queue().isEmpty() - && !jo3.queue().isEmpty() - && !jo4.queue().isEmpty() - && !jo5.queue().isEmpty() - && !jo6.queue().isEmpty() - && !jo7.queue().isEmpty() - ) { - Notification n1 = jo1.queue().peek(); - Notification n2 = jo2.queue().peek(); - Notification n3 = jo3.queue().peek(); - Notification n4 = jo4.queue().peek(); - Notification n5 = jo5.queue().peek(); - Notification n6 = jo6.queue().peek(); - Notification n7 = jo7.queue().peek(); - - if (n1.isOnCompleted() - || n2.isOnCompleted() - || n3.isOnCompleted() - || n4.isOnCompleted() - || n5.isOnCompleted() - || n6.isOnCompleted() - || n7.isOnCompleted() - ) { - onCompleted.call(); - } else { - dequeue(); - onNext.call( - n1.getValue(), - n2.getValue(), - n3.getValue(), - n4.getValue(), - n5.getValue(), - n6.getValue(), - n7.getValue() - ); - } - } - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan8.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan8.java deleted file mode 100644 index 20d054abf7..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan8.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Notification; -import rx.functions.Action0; -import rx.functions.Action8; - -/** - * Represents an active plan. - */ -public final class ActivePlan8 extends ActivePlan0 { - private final Action8 onNext; - private final Action0 onCompleted; - private final JoinObserver1 jo1; - private final JoinObserver1 jo2; - private final JoinObserver1 jo3; - private final JoinObserver1 jo4; - private final JoinObserver1 jo5; - private final JoinObserver1 jo6; - private final JoinObserver1 jo7; - private final JoinObserver1 jo8; - - ActivePlan8( - JoinObserver1 jo1, - JoinObserver1 jo2, - JoinObserver1 jo3, - JoinObserver1 jo4, - JoinObserver1 jo5, - JoinObserver1 jo6, - JoinObserver1 jo7, - JoinObserver1 jo8, - Action8 onNext, - Action0 onCompleted) { - this.onNext = onNext; - this.onCompleted = onCompleted; - this.jo1 = jo1; - this.jo2 = jo2; - this.jo3 = jo3; - this.jo4 = jo4; - this.jo5 = jo5; - this.jo6 = jo6; - this.jo7 = jo7; - this.jo8 = jo8; - addJoinObserver(jo1); - addJoinObserver(jo2); - addJoinObserver(jo3); - addJoinObserver(jo4); - addJoinObserver(jo5); - addJoinObserver(jo6); - addJoinObserver(jo7); - addJoinObserver(jo8); - } - - @Override - protected void match() { - if (!jo1.queue().isEmpty() - && !jo2.queue().isEmpty() - && !jo3.queue().isEmpty() - && !jo4.queue().isEmpty() - && !jo5.queue().isEmpty() - && !jo6.queue().isEmpty() - && !jo7.queue().isEmpty() - && !jo8.queue().isEmpty() - ) { - Notification n1 = jo1.queue().peek(); - Notification n2 = jo2.queue().peek(); - Notification n3 = jo3.queue().peek(); - Notification n4 = jo4.queue().peek(); - Notification n5 = jo5.queue().peek(); - Notification n6 = jo6.queue().peek(); - Notification n7 = jo7.queue().peek(); - Notification n8 = jo8.queue().peek(); - - if (n1.isOnCompleted() - || n2.isOnCompleted() - || n3.isOnCompleted() - || n4.isOnCompleted() - || n5.isOnCompleted() - || n6.isOnCompleted() - || n7.isOnCompleted() - || n8.isOnCompleted() - ) { - onCompleted.call(); - } else { - dequeue(); - onNext.call( - n1.getValue(), - n2.getValue(), - n3.getValue(), - n4.getValue(), - n5.getValue(), - n6.getValue(), - n7.getValue(), - n8.getValue() - ); - } - } - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan9.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan9.java deleted file mode 100644 index d2d281de22..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlan9.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Notification; -import rx.functions.Action0; -import rx.functions.Action9; - -/** - * Represents an active plan. - */ -public final class ActivePlan9 extends ActivePlan0 { - private final Action9 onNext; - private final Action0 onCompleted; - private final JoinObserver1 jo1; - private final JoinObserver1 jo2; - private final JoinObserver1 jo3; - private final JoinObserver1 jo4; - private final JoinObserver1 jo5; - private final JoinObserver1 jo6; - private final JoinObserver1 jo7; - private final JoinObserver1 jo8; - private final JoinObserver1 jo9; - - ActivePlan9( - JoinObserver1 jo1, - JoinObserver1 jo2, - JoinObserver1 jo3, - JoinObserver1 jo4, - JoinObserver1 jo5, - JoinObserver1 jo6, - JoinObserver1 jo7, - JoinObserver1 jo8, - JoinObserver1 jo9, - Action9 onNext, - Action0 onCompleted) { - this.onNext = onNext; - this.onCompleted = onCompleted; - this.jo1 = jo1; - this.jo2 = jo2; - this.jo3 = jo3; - this.jo4 = jo4; - this.jo5 = jo5; - this.jo6 = jo6; - this.jo7 = jo7; - this.jo8 = jo8; - this.jo9 = jo9; - addJoinObserver(jo1); - addJoinObserver(jo2); - addJoinObserver(jo3); - addJoinObserver(jo4); - addJoinObserver(jo5); - addJoinObserver(jo6); - addJoinObserver(jo7); - addJoinObserver(jo8); - addJoinObserver(jo9); - } - - @Override - protected void match() { - if (!jo1.queue().isEmpty() - && !jo2.queue().isEmpty() - && !jo3.queue().isEmpty() - && !jo4.queue().isEmpty() - && !jo5.queue().isEmpty() - && !jo6.queue().isEmpty() - && !jo7.queue().isEmpty() - && !jo8.queue().isEmpty() - && !jo9.queue().isEmpty() - ) { - Notification n1 = jo1.queue().peek(); - Notification n2 = jo2.queue().peek(); - Notification n3 = jo3.queue().peek(); - Notification n4 = jo4.queue().peek(); - Notification n5 = jo5.queue().peek(); - Notification n6 = jo6.queue().peek(); - Notification n7 = jo7.queue().peek(); - Notification n8 = jo8.queue().peek(); - Notification n9 = jo9.queue().peek(); - - if (n1.isOnCompleted() - || n2.isOnCompleted() - || n3.isOnCompleted() - || n4.isOnCompleted() - || n5.isOnCompleted() - || n6.isOnCompleted() - || n7.isOnCompleted() - || n8.isOnCompleted() - || n9.isOnCompleted() - ) { - onCompleted.call(); - } else { - dequeue(); - onNext.call( - n1.getValue(), - n2.getValue(), - n3.getValue(), - n4.getValue(), - n5.getValue(), - n6.getValue(), - n7.getValue(), - n8.getValue(), - n9.getValue() - ); - } - } - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlanN.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlanN.java deleted file mode 100644 index c2a7596ed1..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/ActivePlanN.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.ArrayList; -import java.util.List; - -import rx.Notification; -import rx.functions.Action0; -import rx.functions.ActionN; - -/** - * Represents an active plan. - */ -public final class ActivePlanN extends ActivePlan0 { - private final ActionN onNext; - private final Action0 onCompleted; - private final List> observers; - - ActivePlanN(List> observers, - ActionN onNext, - Action0 onCompleted) { - this.onNext = onNext; - this.onCompleted = onCompleted; - this.observers = new ArrayList>(observers); - for (JoinObserver1 jo : this.observers) { - addJoinObserver(jo); - } - } - - @Override - protected void match() { - Object[] notifications = new Object[this.observers.size()]; - int j = 0; - int completedCount = 0; - for (JoinObserver1 jo : this.observers) { - if (jo.queue().isEmpty()) { - return; - } - Notification n = jo.queue().peek(); - if (n.isOnCompleted()) { - completedCount++; - } - notifications[j] = n.getValue(); - j++; - } - if (completedCount == j) { - onCompleted.call(); - } else { - dequeue(); - onNext.call(notifications); - } - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/JoinObserver.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/JoinObserver.java deleted file mode 100644 index 80fe6d9aa0..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/JoinObserver.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Subscription; - -/** - * Base interface to manage joined observations. - */ -public interface JoinObserver extends Subscription { - void subscribe(Object gate); - - void dequeue(); -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/JoinObserver1.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/JoinObserver1.java deleted file mode 100644 index e281ff2118..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/JoinObserver1.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.joins; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; -import java.util.concurrent.atomic.AtomicBoolean; - -import rx.Notification; -import rx.Observable; -import rx.Subscriber; -import rx.functions.Action1; -import rx.observers.SafeSubscriber; - -/** - * Default implementation of a join observer. - */ -final class JoinObserver1 extends Subscriber> implements JoinObserver { - private Object gate; - private final Observable source; - private final Action1 onError; - private final List activePlans; - private final Queue> queue; - private final AtomicBoolean subscribed = new AtomicBoolean(false); - private final SafeSubscriber> safeObserver; - - JoinObserver1(Observable source, Action1 onError) { - this.source = source; - this.onError = onError; - queue = new LinkedList>(); - activePlans = new ArrayList(); - safeObserver = new SafeSubscriber>(new InnerObserver()); - // add this subscription so it gets unsubscribed when the parent does - add(safeObserver); - } - - public Queue> queue() { - return queue; - } - - public void addActivePlan(ActivePlan0 activePlan) { - activePlans.add(activePlan); - } - - @Override - public void subscribe(Object gate) { - if (subscribed.compareAndSet(false, true)) { - this.gate = gate; - source.materialize().unsafeSubscribe(this); - } else { - throw new IllegalStateException("Can only be subscribed to once."); - } - } - - @Override - public void dequeue() { - queue.remove(); - } - - - @Override - public void onNext(Notification args) { - safeObserver.onNext(args); - } - - @Override - public void onError(Throwable e) { - safeObserver.onError(e); - } - - @Override - public void onCompleted() { - safeObserver.onCompleted(); - } - - void removeActivePlan(ActivePlan0 activePlan) { - activePlans.remove(activePlan); - if (activePlans.isEmpty()) { - unsubscribe(); - } - } - - - private final class InnerObserver extends Subscriber> { - - @Override - public void onNext(Notification args) { - synchronized (gate) { - if (!isUnsubscribed()) { - if (args.isOnError()) { - onError.call(args.getThrowable()); - return; - } - queue.add(args); - - // remark: activePlans might change while iterating - for (ActivePlan0 a : new ArrayList(activePlans)) { - a.match(); - } - } - } - } - - @Override - public void onError(Throwable e) { - // not expected - } - - @Override - public void onCompleted() { - // not expected or ignored - } - } - -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern.java deleted file mode 100644 index a1d9f58a10..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package rx.joins; - -/** - * Base interface for join patterns. - * - * @see MSDN: Pattern - */ -public interface Pattern { - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern1.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern1.java deleted file mode 100644 index c14525e255..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern1.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Observable; -import rx.functions.Func1; - -/** - * Represents a join pattern over one observable sequence. - */ -public final class Pattern1 implements Pattern { - private final Observable o1; - - public Pattern1(Observable o1) { - this.o1 = o1; - } - - Observable o1() { - return o1; - } - - /** - * Matches when all observable sequences have an available - * element and projects the elements by invoking the selector function. - * - * @param selector - * the function that will be invoked for elements in the source sequences. - * @return the plan for the matching - * @throws NullPointerException - * if selector is null - */ - public Plan0 then(Func1 selector) { - if (selector == null) { - throw new NullPointerException(); - } - return new Plan1(this, selector); - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern2.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern2.java deleted file mode 100644 index ea6f51d8e9..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern2.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Observable; -import rx.functions.Func2; - -/** - * Represents a join pattern over observable sequences. - */ -public final class Pattern2 implements Pattern { - private final Observable o1; - private final Observable o2; - - public Pattern2(Observable o1, Observable o2) { - this.o1 = o1; - this.o2 = o2; - } - - Observable o1() { - return o1; - } - - Observable o2() { - return o2; - } - - /** - * Creates a pattern that matches when all three observable sequences have an available element. - * - * @param other - * Observable sequence to match with the two previous sequences. - * @return Pattern object that matches when all observable sequences have an available element. - */ - public Pattern3 and(Observable other) { - if (other == null) { - throw new NullPointerException(); - } - return new Pattern3(o1, o2, other); - } - - /** - * Matches when all observable sequences have an available - * element and projects the elements by invoking the selector function. - * - * @param selector - * the function that will be invoked for elements in the source sequences. - * @return the plan for the matching - * @throws NullPointerException - * if selector is null - */ - public Plan0 then(Func2 selector) { - if (selector == null) { - throw new NullPointerException(); - } - return new Plan2(this, selector); - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern3.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern3.java deleted file mode 100644 index 5a8b231f95..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern3.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Observable; -import rx.functions.Func3; - -/** - * Represents a join pattern over observable sequences. - */ -public final class Pattern3 implements Pattern { - private final Observable o1; - private final Observable o2; - private final Observable o3; - - public Pattern3(Observable o1, Observable o2, - Observable o3) { - this.o1 = o1; - this.o2 = o2; - this.o3 = o3; - } - - Observable o1() { - return o1; - } - - Observable o2() { - return o2; - } - - Observable o3() { - return o3; - } - - /** - * Creates a pattern that matches when all three observable sequences have an available element. - * - * @param other - * Observable sequence to match with the two previous sequences. - * @return Pattern object that matches when all observable sequences have an available element. - */ - public Pattern4 and(Observable other) { - if (other == null) { - throw new NullPointerException(); - } - return new Pattern4(o1, o2, o3, other); - } - - /** - * Matches when all observable sequences have an available - * element and projects the elements by invoking the selector function. - * - * @param selector - * the function that will be invoked for elements in the source sequences. - * @return the plan for the matching - * @throws NullPointerException - * if selector is null - */ - public Plan0 then(Func3 selector) { - if (selector == null) { - throw new NullPointerException(); - } - return new Plan3(this, selector); - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern4.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern4.java deleted file mode 100644 index 58d69e86a2..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern4.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Observable; -import rx.functions.Func4; - -/** - * Represents a join pattern over observable sequences. - */ -public final class Pattern4 implements Pattern { - private final Observable o1; - private final Observable o2; - private final Observable o3; - private final Observable o4; - - public Pattern4( - Observable o1, - Observable o2, - Observable o3, - Observable o4 - ) { - this.o1 = o1; - this.o2 = o2; - this.o3 = o3; - this.o4 = o4; - } - - Observable o1() { - return o1; - } - - Observable o2() { - return o2; - } - - Observable o3() { - return o3; - } - - Observable o4() { - return o4; - } - - /** - * Creates a pattern that matches when all four observable sequences have an available element. - * - * @param other - * Observable sequence to match with the three previous sequences. - * @return Pattern object that matches when all observable sequences have an available element. - */ - public Pattern5 and(Observable other) { - if (other == null) { - throw new NullPointerException(); - } - return new Pattern5(o1, o2, o3, o4, other); - } - /** - * Matches when all observable sequences have an available - * element and projects the elements by invoking the selector function. - * - * @param selector - * the function that will be invoked for elements in the source sequences. - * @return the plan for the matching - * @throws NullPointerException - * if selector is null - */ - public Plan0 then(Func4 selector) { - if (selector == null) { - throw new NullPointerException(); - } - return new Plan4(this, selector); - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern5.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern5.java deleted file mode 100644 index ce068c3c41..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern5.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Observable; -import rx.functions.Func5; - -/** - * Represents a join pattern over observable sequences. - */ -public final class Pattern5 implements Pattern { - private final Observable o1; - private final Observable o2; - private final Observable o3; - private final Observable o4; - private final Observable o5; - - public Pattern5( - Observable o1, - Observable o2, - Observable o3, - Observable o4, - Observable o5 - ) { - this.o1 = o1; - this.o2 = o2; - this.o3 = o3; - this.o4 = o4; - this.o5 = o5; - } - - Observable o1() { - return o1; - } - - Observable o2() { - return o2; - } - - Observable o3() { - return o3; - } - - Observable o4() { - return o4; - } - - Observable o5() { - return o5; - } - - /** - * Creates a pattern that matches when all five observable sequences have an available element. - * - * @param other - * Observable sequence to match with the four previous sequences. - * @return Pattern object that matches when all observable sequences have an available element. - */ - public Pattern6 and(Observable other) { - if (other == null) { - throw new NullPointerException(); - } - return new Pattern6(o1, o2, o3, o4, o5, other); - } - /** - * Matches when all observable sequences have an available - * element and projects the elements by invoking the selector function. - * - * @param selector - * the function that will be invoked for elements in the source sequences. - * @return the plan for the matching - * @throws NullPointerException - * if selector is null - */ - public Plan0 then(Func5 selector) { - if (selector == null) { - throw new NullPointerException(); - } - return new Plan5(this, selector); - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern6.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern6.java deleted file mode 100644 index eae8e20be4..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern6.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Observable; -import rx.functions.Func6; - -/** - * Represents a join pattern over observable sequences. - */ -public final class Pattern6 implements Pattern { - private final Observable o1; - private final Observable o2; - private final Observable o3; - private final Observable o4; - private final Observable o5; - private final Observable o6; - - public Pattern6( - Observable o1, - Observable o2, - Observable o3, - Observable o4, - Observable o5, - Observable o6 - ) { - this.o1 = o1; - this.o2 = o2; - this.o3 = o3; - this.o4 = o4; - this.o5 = o5; - this.o6 = o6; - } - - Observable o1() { - return o1; - } - - Observable o2() { - return o2; - } - - Observable o3() { - return o3; - } - - Observable o4() { - return o4; - } - - Observable o5() { - return o5; - } - - Observable o6() { - return o6; - } - - /** - * Creates a pattern that matches when all six observable sequences have an available element. - * - * @param other - * Observable sequence to match with the five previous sequences. - * @return Pattern object that matches when all observable sequences have an available element. - */ - public Pattern7 and(Observable other) { - if (other == null) { - throw new NullPointerException(); - } - return new Pattern7(o1, o2, o3, o4, o5, o6, other); - } - /** - * Matches when all observable sequences have an available - * element and projects the elements by invoking the selector function. - * - * @param selector - * the function that will be invoked for elements in the source sequences. - * @return the plan for the matching - * @throws NullPointerException - * if selector is null - */ - public Plan0 then(Func6 selector) { - if (selector == null) { - throw new NullPointerException(); - } - return new Plan6(this, selector); - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern7.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern7.java deleted file mode 100644 index 70df807fd8..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern7.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Observable; -import rx.functions.Func7; - -/** - * Represents a join pattern over observable sequences. - */ -public final class Pattern7 implements Pattern { - private final Observable o1; - private final Observable o2; - private final Observable o3; - private final Observable o4; - private final Observable o5; - private final Observable o6; - private final Observable o7; - - public Pattern7( - Observable o1, - Observable o2, - Observable o3, - Observable o4, - Observable o5, - Observable o6, - Observable o7 - ) { - this.o1 = o1; - this.o2 = o2; - this.o3 = o3; - this.o4 = o4; - this.o5 = o5; - this.o6 = o6; - this.o7 = o7; - } - - Observable o1() { - return o1; - } - - Observable o2() { - return o2; - } - - Observable o3() { - return o3; - } - - Observable o4() { - return o4; - } - - Observable o5() { - return o5; - } - - Observable o6() { - return o6; - } - - Observable o7() { - return o7; - } - - /** - * Creates a pattern that matches when all seven observable sequences have an available element. - * - * @param other - * Observable sequence to match with the six previous sequences. - * @return Pattern object that matches when all observable sequences have an available element. - */ - public Pattern8 and(Observable other) { - if (other == null) { - throw new NullPointerException(); - } - return new Pattern8(o1, o2, o3, o4, o5, o6, o7, other); - } - /** - * Matches when all observable sequences have an available - * element and projects the elements by invoking the selector function. - * - * @param selector - * the function that will be invoked for elements in the source sequences. - * @return the plan for the matching - * @throws NullPointerException - * if selector is null - */ - public Plan0 then(Func7 selector) { - if (selector == null) { - throw new NullPointerException(); - } - return new Plan7(this, selector); - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern8.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern8.java deleted file mode 100644 index 17557ae3e6..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern8.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import rx.Observable; -import rx.functions.Func8; - -/** - * Represents a join pattern over observable sequences. - */ -public final class Pattern8 implements Pattern { - private final Observable o1; - private final Observable o2; - private final Observable o3; - private final Observable o4; - private final Observable o5; - private final Observable o6; - private final Observable o7; - private final Observable o8; - - public Pattern8( - Observable o1, - Observable o2, - Observable o3, - Observable o4, - Observable o5, - Observable o6, - Observable o7, - Observable o8 - ) { - this.o1 = o1; - this.o2 = o2; - this.o3 = o3; - this.o4 = o4; - this.o5 = o5; - this.o6 = o6; - this.o7 = o7; - this.o8 = o8; - } - - Observable o1() { - return o1; - } - - Observable o2() { - return o2; - } - - Observable o3() { - return o3; - } - - Observable o4() { - return o4; - } - - Observable o5() { - return o5; - } - - Observable o6() { - return o6; - } - - Observable o7() { - return o7; - } - - Observable o8() { - return o8; - } - - /** - * Creates a pattern that matches when all eight observable sequences have an available element. - * - * @param other - * Observable sequence to match with the seven previous sequences. - * @return Pattern object that matches when all observable sequences have an available element. - */ - public Pattern9 and(Observable other) { - if (other == null) { - throw new NullPointerException(); - } - return new Pattern9(o1, o2, o3, o4, o5, o6, o7, o8, other); - } - /** - * Matches when all observable sequences have an available - * element and projects the elements by invoking the selector function. - * - * @param selector - * the function that will be invoked for elements in the source sequences. - * @return the plan for the matching - * @throws NullPointerException - * if selector is null - */ - public Plan0 then(Func8 selector) { - if (selector == null) { - throw new NullPointerException(); - } - return new Plan8(this, selector); - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern9.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern9.java deleted file mode 100644 index 238e86e4be..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Pattern9.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.ArrayList; -import java.util.List; - -import rx.Observable; -import rx.functions.Func9; - -/** - * Represents a join pattern over observable sequences. - */ -public final class Pattern9 implements Pattern { - private final Observable o1; - private final Observable o2; - private final Observable o3; - private final Observable o4; - private final Observable o5; - private final Observable o6; - private final Observable o7; - private final Observable o8; - private final Observable o9; - - public Pattern9( - Observable o1, - Observable o2, - Observable o3, - Observable o4, - Observable o5, - Observable o6, - Observable o7, - Observable o8, - Observable o9 - ) { - this.o1 = o1; - this.o2 = o2; - this.o3 = o3; - this.o4 = o4; - this.o5 = o5; - this.o6 = o6; - this.o7 = o7; - this.o8 = o8; - this.o9 = o9; - } - - Observable o1() { - return o1; - } - - Observable o2() { - return o2; - } - - Observable o3() { - return o3; - } - - Observable o4() { - return o4; - } - - Observable o5() { - return o5; - } - - Observable o6() { - return o6; - } - - Observable o7() { - return o7; - } - - Observable o8() { - return o8; - } - - Observable o9() { - return o9; - } - - /** - * Creates a pattern that matches when all nine observable sequences have an available element. - * - * @param other - * Observable sequence to match with the eight previous sequences. - * @return Pattern object that matches when all observable sequences have an available element. - */ - public PatternN and(Observable other) { - if (other == null) { - throw new NullPointerException(); - } - List> list = new ArrayList>(); - list.add(o1); - list.add(o2); - list.add(o3); - list.add(o4); - list.add(o5); - list.add(o6); - list.add(o7); - list.add(o8); - list.add(o9); - list.add(other); - return new PatternN(list); - } - /** - * Matches when all observable sequences have an available - * element and projects the elements by invoking the selector function. - * - * @param selector - * the function that will be invoked for elements in the source sequences. - * @return the plan for the matching - * @throws NullPointerException - * if selector is null - */ - public Plan0 then(Func9 selector) { - if (selector == null) { - throw new NullPointerException(); - } - return new Plan9(this, selector); - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/PatternN.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/PatternN.java deleted file mode 100644 index 085235ed22..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/PatternN.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.ArrayList; -import java.util.List; - -import rx.Observable; -import rx.functions.FuncN; - -/** - * Represents a join pattern over observable sequences. - */ -public final class PatternN implements Pattern { - private final List> observables; - - public PatternN(List> observables) { - this.observables = observables; - } - - public PatternN(List> observables, Observable other) { - this.observables = new ArrayList>(observables); - this.observables.add(other); - } - - /** - * @return the number of observables in this pattern. - */ - int size() { - return observables.size(); - } - /** - * Returns the specific Observable from this pattern. - * @param index the index - * @return the observable - */ - Observable get(int index) { - return observables.get(index); - } - - /** - * Creates a pattern that matches when all previous observable sequences have an available element. - * - * @param other - * Observable sequence to match with the previous sequences. - * @return Pattern object that matches when all observable sequences have an available element. - */ - public PatternN and(Observable other) { - if (other == null) { - throw new NullPointerException(); - } - return new PatternN(observables, other); - } - - /** - * Matches when all observable sequences have an available - * element and projects the elements by invoking the selector function. - * - * @param selector - * the function that will be invoked for elements in the source sequences. - * @return the plan for the matching - * @throws NullPointerException - * if selector is null - */ - public Plan0 then(FuncN selector) { - if (selector == null) { - throw new NullPointerException(); - } - return new PlanN(this, selector); - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan0.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan0.java deleted file mode 100644 index 452cf30e4a..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan0.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.joins; - -import java.util.Map; - -import rx.Observable; -import rx.Observer; -import rx.functions.Action1; - -/** - * Represents an execution plan for join patterns. - */ -public abstract class Plan0 { - public abstract ActivePlan0 activate(Map externalSubscriptions, - Observer observer, Action1 deactivate); - - @SuppressWarnings("unchecked") - public static final JoinObserver1 createObserver( - Map externalSubscriptions, - Observable observable, - Action1 onError - ) { - JoinObserver1 observer; - JoinObserver nonGeneric = externalSubscriptions.get(observable); - if (nonGeneric == null) { - observer = new JoinObserver1(observable, onError); - externalSubscriptions.put(observable, observer); - } else { - observer = (JoinObserver1) nonGeneric; - } - return observer; - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan1.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan1.java deleted file mode 100644 index e70fa727c5..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan1.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.joins; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Actions; -import rx.functions.Func1; - -/** - * Represents an execution plan for join patterns. - */ -public final class Plan1 extends Plan0 { - protected final Pattern1 expression; - protected final Func1 selector; - - public Plan1(Pattern1 expression, Func1 selector) { - this.expression = expression; - this.selector = selector; - } - - @Override - public ActivePlan0 activate(Map externalSubscriptions, final Observer observer, final Action1 deactivate) { - Action1 onError = Actions.onErrorFrom(observer); - - final JoinObserver1 firstJoinObserver = createObserver(externalSubscriptions, expression.o1(), onError); - - final AtomicReference> self = new AtomicReference>(); - - ActivePlan1 activePlan = new ActivePlan1(firstJoinObserver, new Action1() { - @Override - public void call(T1 t1) { - R result; - try { - result = selector.call(t1); - } catch (Throwable t) { - observer.onError(t); - return; - } - observer.onNext(result); - } - }, - new Action0() { - @Override - public void call() { - ActivePlan0 ap = self.get(); - firstJoinObserver.removeActivePlan(ap); - deactivate.call(ap); - } - }); - - self.set(activePlan); - - firstJoinObserver.addActivePlan(activePlan); - return activePlan; - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan2.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan2.java deleted file mode 100644 index 288fad97a7..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan2.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action2; -import rx.functions.Actions; -import rx.functions.Func2; - -/** - * Represents an execution plan for join patterns. - */ -public final class Plan2 extends Plan0 { - protected final Pattern2 expression; - protected final Func2 selector; - - public Plan2(Pattern2 expression, Func2 selector) { - this.expression = expression; - this.selector = selector; - } - - @Override - public ActivePlan0 activate(Map externalSubscriptions, - final Observer observer, final Action1 deactivate) { - Action1 onError = Actions.onErrorFrom(observer); - - final JoinObserver1 jo1 = createObserver(externalSubscriptions, expression.o1(), onError); - final JoinObserver1 jo2 = createObserver(externalSubscriptions, expression.o2(), onError); - - final AtomicReference> self = new AtomicReference>(); - - ActivePlan2 activePlan = new ActivePlan2(jo1, jo2, new Action2() { - @Override - public void call(T1 t1, T2 t2) { - R result; - try { - result = selector.call(t1, t2); - } catch (Throwable t) { - observer.onError(t); - return; - } - observer.onNext(result); - } - }, - new Action0() { - @Override - public void call() { - ActivePlan0 ap = self.get(); - jo1.removeActivePlan(ap); - jo2.removeActivePlan(ap); - deactivate.call(ap); - } - }); - - self.set(activePlan); - - jo1.addActivePlan(activePlan); - jo2.addActivePlan(activePlan); - - return activePlan; - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan3.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan3.java deleted file mode 100644 index 4f95ac3b60..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan3.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action3; -import rx.functions.Actions; -import rx.functions.Func3; - -/** - * Represents an execution plan for join patterns. - */ -public final class Plan3 extends Plan0 { - protected final Pattern3 expression; - protected final Func3 selector; - - public Plan3(Pattern3 expression, Func3 selector) { - this.expression = expression; - this.selector = selector; - } - - @Override - public ActivePlan0 activate(Map externalSubscriptions, - final Observer observer, final Action1 deactivate) { - Action1 onError = Actions.onErrorFrom(observer); - - final JoinObserver1 jo1 = createObserver(externalSubscriptions, expression.o1(), onError); - final JoinObserver1 jo2 = createObserver(externalSubscriptions, expression.o2(), onError); - final JoinObserver1 jo3 = createObserver(externalSubscriptions, expression.o3(), onError); - - final AtomicReference> self = new AtomicReference>(); - - ActivePlan3 activePlan = new ActivePlan3( - jo1, jo2, jo3, - new Action3() { - @Override - public void call(T1 t1, T2 t2, T3 t3) { - R result; - try { - result = selector.call(t1, t2, t3); - } catch (Throwable t) { - observer.onError(t); - return; - } - observer.onNext(result); - } - }, - new Action0() { - @Override - public void call() { - ActivePlan0 ap = self.get(); - jo1.removeActivePlan(ap); - jo2.removeActivePlan(ap); - jo3.removeActivePlan(ap); - deactivate.call(ap); - } - }); - - self.set(activePlan); - - jo1.addActivePlan(activePlan); - jo2.addActivePlan(activePlan); - jo3.addActivePlan(activePlan); - - return activePlan; - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan4.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan4.java deleted file mode 100644 index 3856be263b..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan4.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action4; -import rx.functions.Actions; -import rx.functions.Func4; - -/** - * Represents an execution plan for join patterns. - */ -public final class Plan4 extends Plan0 { - protected final Pattern4 expression; - protected final Func4 selector; - - public Plan4(Pattern4 expression, Func4 selector) { - this.expression = expression; - this.selector = selector; - } - - @Override - public ActivePlan0 activate(Map externalSubscriptions, - final Observer observer, final Action1 deactivate) { - Action1 onError = Actions.onErrorFrom(observer); - - final JoinObserver1 jo1 = createObserver(externalSubscriptions, expression.o1(), onError); - final JoinObserver1 jo2 = createObserver(externalSubscriptions, expression.o2(), onError); - final JoinObserver1 jo3 = createObserver(externalSubscriptions, expression.o3(), onError); - final JoinObserver1 jo4 = createObserver(externalSubscriptions, expression.o4(), onError); - - final AtomicReference self = new AtomicReference(); - - ActivePlan0 activePlan = new ActivePlan4( - jo1, jo2, jo3, jo4, - new Action4() { - @Override - public void call(T1 t1, T2 t2, T3 t3, T4 t4) { - R result; - try { - result = selector.call(t1, t2, t3, t4); - } catch (Throwable t) { - observer.onError(t); - return; - } - observer.onNext(result); - } - }, - new Action0() { - @Override - public void call() { - ActivePlan0 ap = self.get(); - jo1.removeActivePlan(ap); - jo2.removeActivePlan(ap); - jo3.removeActivePlan(ap); - jo4.removeActivePlan(ap); - deactivate.call(ap); - } - }); - - self.set(activePlan); - - jo1.addActivePlan(activePlan); - jo2.addActivePlan(activePlan); - jo3.addActivePlan(activePlan); - jo4.addActivePlan(activePlan); - - return activePlan; - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan5.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan5.java deleted file mode 100644 index 98b47448d2..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan5.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action5; -import rx.functions.Actions; -import rx.functions.Func5; - -/** - * Represents an execution plan for join patterns. - */ -public final class Plan5 extends Plan0 { - protected final Pattern5 expression; - protected final Func5 selector; - - public Plan5(Pattern5 expression, Func5 selector) { - this.expression = expression; - this.selector = selector; - } - - @Override - public ActivePlan0 activate(Map externalSubscriptions, - final Observer observer, final Action1 deactivate) { - Action1 onError = Actions.onErrorFrom(observer); - - final JoinObserver1 jo1 = createObserver(externalSubscriptions, expression.o1(), onError); - final JoinObserver1 jo2 = createObserver(externalSubscriptions, expression.o2(), onError); - final JoinObserver1 jo3 = createObserver(externalSubscriptions, expression.o3(), onError); - final JoinObserver1 jo4 = createObserver(externalSubscriptions, expression.o4(), onError); - final JoinObserver1 jo5 = createObserver(externalSubscriptions, expression.o5(), onError); - - final AtomicReference self = new AtomicReference(); - - ActivePlan0 activePlan = new ActivePlan5( - jo1, jo2, jo3, jo4, jo5, - new Action5() { - @Override - public void call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) { - R result; - try { - result = selector.call(t1, t2, t3, t4, t5); - } catch (Throwable t) { - observer.onError(t); - return; - } - observer.onNext(result); - } - }, - new Action0() { - @Override - public void call() { - ActivePlan0 ap = self.get(); - jo1.removeActivePlan(ap); - jo2.removeActivePlan(ap); - jo3.removeActivePlan(ap); - jo4.removeActivePlan(ap); - jo5.removeActivePlan(ap); - deactivate.call(ap); - } - }); - - self.set(activePlan); - - jo1.addActivePlan(activePlan); - jo2.addActivePlan(activePlan); - jo3.addActivePlan(activePlan); - jo4.addActivePlan(activePlan); - jo5.addActivePlan(activePlan); - - return activePlan; - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan6.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan6.java deleted file mode 100644 index cd87e855cf..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan6.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action6; -import rx.functions.Actions; -import rx.functions.Func6; - -/** - * Represents an execution plan for join patterns. - */ -public final class Plan6 extends Plan0 { - protected final Pattern6 expression; - protected final Func6 selector; - - public Plan6(Pattern6 expression, Func6 selector) { - this.expression = expression; - this.selector = selector; - } - - @Override - public ActivePlan0 activate(Map externalSubscriptions, - final Observer observer, final Action1 deactivate) { - Action1 onError = Actions.onErrorFrom(observer); - - final JoinObserver1 jo1 = createObserver(externalSubscriptions, expression.o1(), onError); - final JoinObserver1 jo2 = createObserver(externalSubscriptions, expression.o2(), onError); - final JoinObserver1 jo3 = createObserver(externalSubscriptions, expression.o3(), onError); - final JoinObserver1 jo4 = createObserver(externalSubscriptions, expression.o4(), onError); - final JoinObserver1 jo5 = createObserver(externalSubscriptions, expression.o5(), onError); - final JoinObserver1 jo6 = createObserver(externalSubscriptions, expression.o6(), onError); - - final AtomicReference self = new AtomicReference(); - - ActivePlan0 activePlan = new ActivePlan6( - jo1, jo2, jo3, jo4, jo5, jo6, - new Action6() { - @Override - public void call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) { - R result; - try { - result = selector.call(t1, t2, t3, t4, t5, t6); - } catch (Throwable t) { - observer.onError(t); - return; - } - observer.onNext(result); - } - }, - new Action0() { - @Override - public void call() { - ActivePlan0 ap = self.get(); - jo1.removeActivePlan(ap); - jo2.removeActivePlan(ap); - jo3.removeActivePlan(ap); - jo4.removeActivePlan(ap); - jo5.removeActivePlan(ap); - jo6.removeActivePlan(ap); - deactivate.call(ap); - } - }); - - self.set(activePlan); - - jo1.addActivePlan(activePlan); - jo2.addActivePlan(activePlan); - jo3.addActivePlan(activePlan); - jo4.addActivePlan(activePlan); - jo5.addActivePlan(activePlan); - jo6.addActivePlan(activePlan); - - return activePlan; - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan7.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan7.java deleted file mode 100644 index 64eef70c12..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan7.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action7; -import rx.functions.Actions; -import rx.functions.Func7; - -/** - * Represents an execution plan for join patterns. - */ -public final class Plan7 extends Plan0 { - protected final Pattern7 expression; - protected final Func7 selector; - - public Plan7(Pattern7 expression, Func7 selector) { - this.expression = expression; - this.selector = selector; - } - - @Override - public ActivePlan0 activate(Map externalSubscriptions, - final Observer observer, final Action1 deactivate) { - Action1 onError = Actions.onErrorFrom(observer); - - final JoinObserver1 jo1 = createObserver(externalSubscriptions, expression.o1(), onError); - final JoinObserver1 jo2 = createObserver(externalSubscriptions, expression.o2(), onError); - final JoinObserver1 jo3 = createObserver(externalSubscriptions, expression.o3(), onError); - final JoinObserver1 jo4 = createObserver(externalSubscriptions, expression.o4(), onError); - final JoinObserver1 jo5 = createObserver(externalSubscriptions, expression.o5(), onError); - final JoinObserver1 jo6 = createObserver(externalSubscriptions, expression.o6(), onError); - final JoinObserver1 jo7 = createObserver(externalSubscriptions, expression.o7(), onError); - - final AtomicReference self = new AtomicReference(); - - ActivePlan0 activePlan = new ActivePlan7( - jo1, jo2, jo3, jo4, jo5, jo6, jo7, - new Action7() { - @Override - public void call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) { - R result; - try { - result = selector.call(t1, t2, t3, t4, t5, t6, t7); - } catch (Throwable t) { - observer.onError(t); - return; - } - observer.onNext(result); - } - }, - new Action0() { - @Override - public void call() { - ActivePlan0 ap = self.get(); - jo1.removeActivePlan(ap); - jo2.removeActivePlan(ap); - jo3.removeActivePlan(ap); - jo4.removeActivePlan(ap); - jo5.removeActivePlan(ap); - jo6.removeActivePlan(ap); - jo7.removeActivePlan(ap); - deactivate.call(ap); - } - }); - - self.set(activePlan); - - jo1.addActivePlan(activePlan); - jo2.addActivePlan(activePlan); - jo3.addActivePlan(activePlan); - jo4.addActivePlan(activePlan); - jo5.addActivePlan(activePlan); - jo6.addActivePlan(activePlan); - jo7.addActivePlan(activePlan); - - return activePlan; - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan8.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan8.java deleted file mode 100644 index 1dead50de7..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan8.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action8; -import rx.functions.Actions; -import rx.functions.Func8; - -/** - * Represents an execution plan for join patterns. - */ -public final class Plan8 extends Plan0 { - protected final Pattern8 expression; - protected final Func8 selector; - - public Plan8(Pattern8 expression, Func8 selector) { - this.expression = expression; - this.selector = selector; - } - - @Override - public ActivePlan0 activate(Map externalSubscriptions, - final Observer observer, final Action1 deactivate) { - Action1 onError = Actions.onErrorFrom(observer); - - final JoinObserver1 jo1 = createObserver(externalSubscriptions, expression.o1(), onError); - final JoinObserver1 jo2 = createObserver(externalSubscriptions, expression.o2(), onError); - final JoinObserver1 jo3 = createObserver(externalSubscriptions, expression.o3(), onError); - final JoinObserver1 jo4 = createObserver(externalSubscriptions, expression.o4(), onError); - final JoinObserver1 jo5 = createObserver(externalSubscriptions, expression.o5(), onError); - final JoinObserver1 jo6 = createObserver(externalSubscriptions, expression.o6(), onError); - final JoinObserver1 jo7 = createObserver(externalSubscriptions, expression.o7(), onError); - final JoinObserver1 jo8 = createObserver(externalSubscriptions, expression.o8(), onError); - - final AtomicReference self = new AtomicReference(); - - ActivePlan0 activePlan = new ActivePlan8( - jo1, jo2, jo3, jo4, jo5, jo6, jo7, jo8, - new Action8() { - @Override - public void call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8) { - R result; - try { - result = selector.call(t1, t2, t3, t4, t5, t6, t7, t8); - } catch (Throwable t) { - observer.onError(t); - return; - } - observer.onNext(result); - } - }, - new Action0() { - @Override - public void call() { - ActivePlan0 ap = self.get(); - jo1.removeActivePlan(ap); - jo2.removeActivePlan(ap); - jo3.removeActivePlan(ap); - jo4.removeActivePlan(ap); - jo5.removeActivePlan(ap); - jo6.removeActivePlan(ap); - jo7.removeActivePlan(ap); - jo8.removeActivePlan(ap); - deactivate.call(ap); - } - }); - - self.set(activePlan); - - jo1.addActivePlan(activePlan); - jo2.addActivePlan(activePlan); - jo3.addActivePlan(activePlan); - jo4.addActivePlan(activePlan); - jo5.addActivePlan(activePlan); - jo6.addActivePlan(activePlan); - jo7.addActivePlan(activePlan); - jo8.addActivePlan(activePlan); - - return activePlan; - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan9.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan9.java deleted file mode 100644 index 6a628eef18..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/Plan9.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.Action9; -import rx.functions.Actions; -import rx.functions.Func9; - -/** - * Represents an execution plan for join patterns. - */ -public final class Plan9 extends Plan0 { - protected final Pattern9 expression; - protected final Func9 selector; - - public Plan9(Pattern9 expression, Func9 selector) { - this.expression = expression; - this.selector = selector; - } - - @Override - public ActivePlan0 activate(Map externalSubscriptions, - final Observer observer, final Action1 deactivate) { - Action1 onError = Actions.onErrorFrom(observer); - - final JoinObserver1 jo1 = createObserver(externalSubscriptions, expression.o1(), onError); - final JoinObserver1 jo2 = createObserver(externalSubscriptions, expression.o2(), onError); - final JoinObserver1 jo3 = createObserver(externalSubscriptions, expression.o3(), onError); - final JoinObserver1 jo4 = createObserver(externalSubscriptions, expression.o4(), onError); - final JoinObserver1 jo5 = createObserver(externalSubscriptions, expression.o5(), onError); - final JoinObserver1 jo6 = createObserver(externalSubscriptions, expression.o6(), onError); - final JoinObserver1 jo7 = createObserver(externalSubscriptions, expression.o7(), onError); - final JoinObserver1 jo8 = createObserver(externalSubscriptions, expression.o8(), onError); - final JoinObserver1 jo9 = createObserver(externalSubscriptions, expression.o9(), onError); - - final AtomicReference self = new AtomicReference(); - - ActivePlan0 activePlan = new ActivePlan9( - jo1, jo2, jo3, jo4, jo5, jo6, jo7, jo8, jo9, - new Action9() { - @Override - public void call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9) { - R result; - try { - result = selector.call(t1, t2, t3, t4, t5, t6, t7, t8, t9); - } catch (Throwable t) { - observer.onError(t); - return; - } - observer.onNext(result); - } - }, - new Action0() { - @Override - public void call() { - ActivePlan0 ap = self.get(); - jo1.removeActivePlan(ap); - jo2.removeActivePlan(ap); - jo3.removeActivePlan(ap); - jo4.removeActivePlan(ap); - jo5.removeActivePlan(ap); - jo6.removeActivePlan(ap); - jo7.removeActivePlan(ap); - jo8.removeActivePlan(ap); - jo9.removeActivePlan(ap); - deactivate.call(ap); - } - }); - - self.set(activePlan); - - jo1.addActivePlan(activePlan); - jo2.addActivePlan(activePlan); - jo3.addActivePlan(activePlan); - jo4.addActivePlan(activePlan); - jo5.addActivePlan(activePlan); - jo6.addActivePlan(activePlan); - jo7.addActivePlan(activePlan); - jo8.addActivePlan(activePlan); - jo9.addActivePlan(activePlan); - - return activePlan; - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/PlanN.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/PlanN.java deleted file mode 100644 index 33e8591320..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/PlanN.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import rx.Observer; -import rx.functions.Action0; -import rx.functions.Action1; -import rx.functions.ActionN; -import rx.functions.Actions; -import rx.functions.FuncN; - -/** - * Represents an execution plan for join patterns. - */ -public final class PlanN extends Plan0 { - protected final PatternN expression; - protected final FuncN selector; - - public PlanN(PatternN expression, FuncN selector) { - this.expression = expression; - this.selector = selector; - } - - @Override - public ActivePlan0 activate(Map externalSubscriptions, - final Observer observer, final Action1 deactivate) { - Action1 onError = Actions.onErrorFrom(observer); - - final List> observers = new ArrayList>(); - for (int i = 0; i < expression.size(); i++) { - observers.add(createObserver(externalSubscriptions, expression.get(i), onError)); - } - final AtomicReference self = new AtomicReference(); - - ActivePlanN activePlan = new ActivePlanN(observers, new ActionN() { - @Override - public void call(Object... args) { - R result; - try { - result = selector.call(args); - } catch (Throwable t) { - observer.onError(t); - return; - } - observer.onNext(result); - } - }, - new Action0() { - @Override - public void call() { - for (JoinObserver1 jo : observers) { - jo.removeActivePlan(self.get()); - } - deactivate.call(self.get()); - } - }); - - self.set(activePlan); - - for (JoinObserver1 jo : observers) { - jo.addActivePlan(activePlan); - } - - return activePlan; - } - -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/operators/OperatorJoinPatterns.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/operators/OperatorJoinPatterns.java deleted file mode 100644 index 5ec7e1c3df..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/joins/operators/OperatorJoinPatterns.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins.operators; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import rx.Observable; -import rx.Observable.OnSubscribe; -import rx.Observer; -import rx.Subscriber; -import rx.functions.Action1; -import rx.functions.Func1; -import rx.joins.ActivePlan0; -import rx.joins.JoinObserver; -import rx.joins.Pattern1; -import rx.joins.Pattern2; -import rx.joins.Plan0; -import rx.subscriptions.CompositeSubscription; - -/** - * Join patterns: And, Then, When. - */ -public final class OperatorJoinPatterns { - public OperatorJoinPatterns() { throw new IllegalStateException("No instances!"); } - /** - * Creates a pattern that matches when both observable sequences have an available element. - */ - public static Pattern2 and(/* this */Observable left, Observable right) { - if (left == null) { - throw new NullPointerException("left"); - } - if (right == null) { - throw new NullPointerException("right"); - } - return new Pattern2(left, right); - } - - /** - * Matches when the observable sequence has an available element and projects the element by invoking the selector function. - */ - public static Plan0 then(/* this */Observable source, Func1 selector) { - if (source == null) { - throw new NullPointerException("source"); - } - if (selector == null) { - throw new NullPointerException("selector"); - } - return new Pattern1(source).then(selector); - } - - /** - * Joins together the results from several patterns. - */ - public static OnSubscribe when(Plan0... plans) { - if (plans == null) { - throw new NullPointerException("plans"); - } - return when(Arrays.asList(plans)); - } - - /** - * Joins together the results from several patterns. - */ - public static OnSubscribe when(final Iterable> plans) { - if (plans == null) { - throw new NullPointerException("plans"); - } - return new OnSubscribe() { - @Override - public void call(final Subscriber t1) { - final Map externalSubscriptions = new HashMap(); - final Object gate = new Object(); - final List activePlans = new ArrayList(); - - final Observer out = new Observer() { - @Override - public void onNext(R args) { - t1.onNext(args); - } - - @Override - public void onError(Throwable e) { - for (JoinObserver po : externalSubscriptions.values()) { - po.unsubscribe(); - } - t1.onError(e); - } - - @Override - public void onCompleted() { - t1.onCompleted(); - } - }; - - try { - for (Plan0 plan : plans) { - activePlans.add(plan.activate(externalSubscriptions, out, new Action1() { - @Override - public void call(ActivePlan0 activePlan) { - activePlans.remove(activePlan); - if (activePlans.isEmpty()) { - out.onCompleted(); - } - } - })); - } - } catch (Throwable t) { - Observable. error(t).unsafeSubscribe(t1); - return; - } - CompositeSubscription group = new CompositeSubscription(); - t1.add(group); - for (JoinObserver jo : externalSubscriptions.values()) { - jo.subscribe(gate); - group.add(jo); - } - } - }; - } -} diff --git a/rxjava-contrib/rxjava-joins/src/main/java/rx/observables/JoinObservable.java b/rxjava-contrib/rxjava-joins/src/main/java/rx/observables/JoinObservable.java deleted file mode 100644 index 75d9e0325f..0000000000 --- a/rxjava-contrib/rxjava-joins/src/main/java/rx/observables/JoinObservable.java +++ /dev/null @@ -1,322 +0,0 @@ -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; - } -} diff --git a/rxjava-contrib/rxjava-joins/src/test/java/rx/joins/operators/OperatorJoinsTest.java b/rxjava-contrib/rxjava-joins/src/test/java/rx/joins/operators/OperatorJoinsTest.java deleted file mode 100644 index 73f8cf7a8c..0000000000 --- a/rxjava-contrib/rxjava-joins/src/test/java/rx/joins/operators/OperatorJoinsTest.java +++ /dev/null @@ -1,1389 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package rx.joins.operators; - -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.util.Arrays; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InOrder; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import rx.Observable; -import rx.Observer; -import rx.exceptions.TestException; -import rx.functions.Func0; -import rx.functions.Func1; -import rx.functions.Func2; -import rx.functions.Func3; -import rx.functions.Func4; -import rx.functions.Func5; -import rx.functions.Func6; -import rx.functions.Func7; -import rx.functions.Func8; -import rx.functions.Func9; -import rx.functions.FuncN; -import rx.functions.Functions; -import rx.joins.PatternN; -import rx.joins.Plan0; -import rx.observables.JoinObservable; -import rx.observers.TestSubscriber; -import rx.subjects.PublishSubject; - -public class OperatorJoinsTest { - @Mock - Observer observer; - - static final class Adder implements - Func2, - Func3, - Func4, - Func5, - Func6, - Func7, - Func8, - Func9, - FuncN - { - - @Override - public Integer call(Object... args) { - int sum = 0; - - for(Object o : args) { - sum += (Integer)o; - } - - return sum; - } - - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, - Integer t5, Integer t6, Integer t7, Integer t8, Integer t9) { - return t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9; - } - - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, - Integer t5, Integer t6, Integer t7, Integer t8) { - return t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8; - } - - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, - Integer t5, Integer t6, Integer t7) { - return t1 + t2 + t3 + t4 + t5 + t6 + t7; - } - - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, - Integer t5, Integer t6) { - return t1 + t2 + t3 + t4 + t5 + t6; - } - - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4, - Integer t5) { - return t1 + t2 + t3 + t4 + t5; - } - - @Override - public Integer call(Integer t1, Integer t2, Integer t3, Integer t4) { - return t1 + t2 + t3 + t4; - } - - @Override - public Integer call(Integer t1, Integer t2, Integer t3) { - return t1 + t2 + t3; - } - - @Override - public Integer call(Integer t1, Integer t2) { - return t1 + t2; - } - - } - Adder add = new Adder(); - Func2 mul2 = new Func2() { - @Override - public Integer call(Integer t1, Integer t2) { - return t1 * t2; - } - }; - Func2 sub2 = new Func2() { - @Override - public Integer call(Integer t1, Integer t2) { - return t1 - t2; - } - }; - - static final class ThrowFunc implements - Func0, - Func1, - Func2, - Func3, - Func4, - Func5, - Func6, - Func7, - Func8, - Func9, - FuncN - { - @Override - public R call() { - throw new TestException("Forced failure"); - } - @Override - public R call(Integer t1) { - return call(); - } - @Override - public R call(Object... args) { - return call(); - } - @Override - public R call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, - Integer t6, Integer t7, Integer t8, Integer t9) { - return call(); - } - @Override - public R call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, - Integer t6, Integer t7, Integer t8) { - return call(); - } - @Override - public R call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, - Integer t6, Integer t7) { - return call(); - } - @Override - public R call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, - Integer t6) { - return call(); - } - @Override - public R call(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5) { - return call(); - } - @Override - public R call(Integer t1, Integer t2, Integer t3, Integer t4) { - return call(); - } - @Override - public R call(Integer t1, Integer t2, Integer t3) { - return call(); - } - @Override - public R call(Integer t1, Integer t2) { - return call(); - } - } - ThrowFunc throwFunc = new ThrowFunc(); - - Observable some = Observable.just(1); - - Observable error = Observable.error(new TestException("Forced failure")); - - @Before - public void before() { - MockitoAnnotations.initMocks(this); - } - - @Test(expected = NullPointerException.class) - public void and2ArgumentNull() { - JoinObservable.from(some).and(null); - } - - @Test(expected = NullPointerException.class) - public void and3argumentNull() { - JoinObservable.from(some).and(some).and(null); - } - - void verifyAnd(JoinObservable m, int count) { - - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - - m.toObservable().subscribe(o); - - verify(o, never()).onError(any(Throwable.class)); - verify(o, times(1)).onNext(count); - verify(o, times(1)).onCompleted(); - } - void verifyError(JoinObservable m) { - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - - m.toObservable().subscribe(o); - - verify(o, times(1)).onError(any(TestException.class)); - verify(o, never()).onNext(any(Integer.class)); - verify(o, never()).onCompleted(); - } - - @Test - public void and2() { - verifyAnd(JoinObservable.when(JoinObservable.from(some).and(some).then(add)), 2); - } - - @Test - public void and2Error1() { - verifyError(JoinObservable.when(JoinObservable.from(error).and(some).then(add))); - } - - @Test - public void and2Error2() { - verifyError(JoinObservable.when(JoinObservable.from(some).and(error).then(add))); - } - - @Test - public void and3() { - verifyAnd(JoinObservable.when(JoinObservable.from(some).and(some).and(some).then(add)), 3); - } - - @Test - public void and3Error1() { - verifyError(JoinObservable.when(JoinObservable.from(error).and(some).and(some).then(add))); - } - - @Test - public void and3Error2() { - verifyError(JoinObservable.when(JoinObservable.from(some).and(error).and(some).then(add))); - } - - @Test - public void and3Error3() { - verifyError(JoinObservable.when(JoinObservable.from(some).and(some).and(error).then(add))); - } - - @Test(expected = NullPointerException.class) - public void thenArgumentNull() { - JoinObservable.from(some).then(null); - } - - @Test(expected = NullPointerException.class) - public void then2ArgumentNull() { - JoinObservable.from(some).and(some).then(null); - } - - @Test(expected = NullPointerException.class) - public void then3ArgumentNull() { - JoinObservable.from(some).and(some).and(some).then(null); - } - - @Test(expected = NullPointerException.class) - public void then4ArgumentNull() { - JoinObservable.from(some).and(some).and(some).and(some).then(null); - } - - @Test(expected = NullPointerException.class) - public void then5ArgumentNull() { - JoinObservable.from(some).and(some).and(some).and(some).and(some).then(null); - } - - @Test(expected = NullPointerException.class) - public void then6ArgumentNull() { - JoinObservable.from(some).and(some).and(some).and(some).and(some).and(some).then(null); - } - - @Test(expected = NullPointerException.class) - public void then7ArgumentNull() { - JoinObservable.from(some).and(some).and(some).and(some).and(some).and(some).and(some).then(null); - } - - @Test(expected = NullPointerException.class) - public void then8ArgumentNull() { - JoinObservable.from(some).and(some).and(some).and(some).and(some).and(some).and(some).and(some).then(null); - } - - @Test(expected = NullPointerException.class) - public void then9ArgumentNull() { - JoinObservable.from(some).and(some).and(some).and(some).and(some).and(some).and(some).and(some).and(some).then(null); - } - - @Test - public void thenNArgumentNull() { - for (int n = 10; n < 100; n++) { - PatternN p = JoinObservable.from(some).and(some) - .and(some).and(some) - .and(some).and(some) - .and(some).and(some) - .and(some).and(some); - try { - for (int j = 0; j < n - 10; j++) { - p = p.and(some); - } - p.then(null); - fail("Failed to throw exception with pattern length " + n); - } catch (NullPointerException ex) { - // expected, continue - } - } - } - - @Test(expected = NullPointerException.class) - public void then10ArgumentNull() { - JoinObservable.from(some).and(some).and(some).and(some).and(some).and(some).and(some).and(some).and(some).and(some).then(null); - } - - @Test - public void then1() { - verifyAnd(JoinObservable.when(JoinObservable.from(some).then(Functions. identity())), 1); - } - - @Test - public void then1Error() { - verifyError(JoinObservable.when(JoinObservable.from(error).then(Functions. identity()))); - } - - @Test - public void then1Throws() { - verifyError(JoinObservable.when(JoinObservable.from(some).then(throwFunc))); - } - - @Test - public void then2Throws() { - verifyError(JoinObservable.when(JoinObservable.from(some).and(some).then(throwFunc))); - } - - @Test - public void then3Throws() { - verifyError(JoinObservable.when(JoinObservable.from(some).and(some).and(some).then(throwFunc))); - } - - @Test(expected = NullPointerException.class) - public void whenArgumentNull1() { - JoinObservable.when((Plan0[]) null); - } - - @Test(expected = NullPointerException.class) - public void whenArgumentNull2() { - JoinObservable.when((Iterable>) null); - } - - @Test - public void whenMultipleSymmetric() { - Observable source1 = Observable.just(1, 2, 3); - Observable source2 = Observable.just(4, 5, 6); - - Observable m = JoinObservable.when(JoinObservable.from(source1).and(source2).then(add)).toObservable(); - m.subscribe(observer); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(1 + 4); - verify(observer, times(1)).onNext(2 + 5); - verify(observer, times(1)).onNext(3 + 6); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void whenMultipleAsymSymmetric() { - Observable source1 = Observable.just(1, 2, 3); - Observable source2 = Observable.just(4, 5); - - Observable m = JoinObservable.when(JoinObservable.from(source1).and(source2).then(add)).toObservable(); - m.subscribe(observer); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, times(1)).onNext(1 + 4); - verify(observer, times(1)).onNext(2 + 5); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void whenEmptyEmpty() { - Observable source1 = Observable.empty(); - Observable source2 = Observable.empty(); - - Observable m = JoinObservable.when(JoinObservable.from(source1).and(source2).then(add)).toObservable(); - m.subscribe(observer); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, never()).onNext(any(Integer.class)); - verify(observer, times(1)).onCompleted(); - } - - @Test - public void whenNeverNever() { - Observable source1 = Observable.never(); - Observable source2 = Observable.never(); - - Observable m = JoinObservable.when(JoinObservable.from(source1).and(source2).then(add)).toObservable(); - m.subscribe(observer); - - verify(observer, never()).onError(any(Throwable.class)); - verify(observer, never()).onNext(any(Integer.class)); - verify(observer, never()).onCompleted(); - } - - @Test - public void whenThrowNonEmpty() { - Observable source1 = Observable.empty(); - Observable source2 = Observable.error(new TestException("Forced failure")); - - Observable m = JoinObservable.when(JoinObservable.from(source1).and(source2).then(add)).toObservable(); - m.subscribe(observer); - - verify(observer, times(1)).onError(any(Throwable.class)); - verify(observer, never()).onNext(any(Integer.class)); - verify(observer, never()).onCompleted(); - } - - @Test - public void whenComplicated() { - PublishSubject xs = PublishSubject.create(); - PublishSubject ys = PublishSubject.create(); - PublishSubject zs = PublishSubject.create(); - - Observable m = JoinObservable.when( - JoinObservable.from(xs).and(ys).then(add), // 1+4=5, 2+5=7, 3+6=9 - JoinObservable.from(xs).and(zs).then(mul2), // 1*7=7, 2*8=16, 3*9=27 - JoinObservable.from(ys).and(zs).then(sub2) // 4-7=-3, 5-8=-3, 6-9=-3 - ).toObservable(); - - TestSubscriber to = new TestSubscriber(observer); - m.subscribe(to); - - xs.onNext(1); // t == 210, xs[1], ys[], zs[] - - xs.onNext(2); // t == 220, xs[1, 2], ys[], zs[] - zs.onNext(7); // t == 220, xs[1, 2], ys[], zs[7] triggers x and z; emit 1 * 7, remains xs[2], ys[], zs[] - - xs.onNext(3); // t == 230, xs[2,3], ys[], zs[] - zs.onNext(8); // t == 230, xs[2,3], ys[], zs[8] triggers x and z, emit 2 * 8, remains xs[3], ys[], zs[] - - ys.onNext(4); // t == 240, xs[], ys[4], zs[] triggers x and y, emit 3 + 4, remains xs[], ys[], zs[] - zs.onNext(9); // t == 240, xs[], ys[], zs[9] - xs.onCompleted(); // t == 240, completed 1 - - ys.onNext(5); // t == 250, xs[], ys[5], zs[9], triggers ys and zs, emits 5 - 9, remains xs[], ys[], zs[] - - ys.onNext(6); // t == 260, xs[], ys[6], zs[] - - ys.onCompleted(); // t == 270, completed 2 - - zs.onCompleted(); // t == 300, completed 3, triggers when() oncompleted - - System.out.println("Events: " + to.getOnNextEvents()); - - to.assertReceivedOnNext(Arrays.asList(7, 16, 7, -4)); - to.assertTerminalEvent(); - - InOrder inOrder = inOrder(observer); - - inOrder.verify(observer, times(1)).onNext(1 * 7); - inOrder.verify(observer, times(1)).onNext(2 * 8); - inOrder.verify(observer, times(1)).onNext(3 + 4); - inOrder.verify(observer, times(1)).onNext(5 - 9); - inOrder.verify(observer, times(1)).onCompleted(); - verify(observer, never()).onError(any(Throwable.class)); - } - - // ----------------- - - @Test - public void and4() { - verifyAnd(JoinObservable.when(JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .then(add)), 4); - } - - @Test - public void and4Error1() { - verifyError(JoinObservable.when( - JoinObservable.from(error) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and4Error2() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(error) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and4Error3() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(error) - .and(some) - .then(add))); - } - - @Test - public void and4Error4() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(error) - .then(add))); - } - - @Test - public void then4Throws() { - verifyError(JoinObservable.when( - JoinObservable - .from(some) - .and(some) - .and(some) - .and(some) - .then(throwFunc))); - } - - // ----------------- - - @Test - public void and5() { - verifyAnd(JoinObservable.when(JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add)), 5); - } - - @Test - public void and5Error1() { - verifyError(JoinObservable.when( - JoinObservable.from(error) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and5Error2() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(error) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and5Error3() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(error) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and5Error4() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(error) - .and(some) - .then(add))); - } - @Test - public void and5Error5() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(error) - .then(add))); - } - - @Test - public void then5Throws() { - verifyError(JoinObservable.when( - JoinObservable - .from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(throwFunc))); - } - - // ----------------- - - @Test - public void and6() { - verifyAnd(JoinObservable.when(JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add)), 6); - } - - @Test - public void and6Error1() { - verifyError(JoinObservable.when( - JoinObservable.from(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and6Error2() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and6Error3() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and6Error4() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .then(add))); - } - @Test - public void and6Error5() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .then(add))); - } - - @Test - public void and6Error6() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .then(add))); - } - - @Test - public void then6Throws() { - verifyError(JoinObservable.when( - JoinObservable - .from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(throwFunc))); - } - // ----------------- - - @Test - public void and7() { - verifyAnd(JoinObservable.when(JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add)), 7); - } - - @Test - public void and7Error1() { - verifyError(JoinObservable.when( - JoinObservable.from(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and7Error2() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and7Error3() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and7Error4() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .then(add))); - } - @Test - public void and7Error5() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and7Error6() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .then(add))); - } - - @Test - public void and7Error7() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .then(add))); - } - - @Test - public void then7Throws() { - verifyError(JoinObservable.when( - JoinObservable - .from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(throwFunc))); - } - // ----------------- - - @Test - public void and8() { - verifyAnd(JoinObservable.when(JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add)), 8); - } - - @Test - public void and8Error1() { - verifyError(JoinObservable.when( - JoinObservable.from(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and8Error2() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and8Error3() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and8Error4() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - @Test - public void and8Error5() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and8Error6() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and8Error7() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .then(add))); - } - - @Test - public void and8Error8() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .then(add))); - } - - @Test - public void then8Throws() { - verifyError(JoinObservable.when( - JoinObservable - .from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(throwFunc))); - } - // ----------------- - - @Test - public void and9() { - verifyAnd(JoinObservable.when(JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add)), 9); - } - - @Test - public void and9Error1() { - verifyError(JoinObservable.when( - JoinObservable.from(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and9Error2() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and9Error3() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and9Error4() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - @Test - public void and9Error5() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and9Error6() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and9Error7() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void and9Error8() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .then(add))); - } - @Test - public void and9Error9() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .then(add))); - } - - @Test - public void then9Throws() { - verifyError(JoinObservable.when( - JoinObservable - .from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(throwFunc))); - } - // ----------------- - - @Test - public void andN() { - int s = 10; - for (int n = s; n < 100; n++) { - System.out.println("AndN(" + n + ")"); - PatternN p = JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some); - - for (int j = 0; j < n - s; j++) { - p = p.and(some); - } - verifyAnd(JoinObservable.when(p.then(add)), n); - } - } - - @Test - public void andNError1() { - verifyError(JoinObservable.when( - JoinObservable.from(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void andNError2() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void andNError3() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void andNError4() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - @Test - public void andNError5() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void andNError6() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void andNError7() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void andNError8() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .and(some) - .then(add))); - } - - @Test - public void andNError9() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .and(some) - .then(add))); - } - - @Test - public void andNErrorN() { - verifyError(JoinObservable.when( - JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(error) - .then(add))); - } - - @Test - public void andNErrorNRange() { - for (int n = 10; n < 100; n++) { - PatternN p = JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some); - - for (int j = 0; j < n - 10; j++) { - p = p.and(some); - } - p = p.and(error); - - verifyError(JoinObservable.when(p.then(add))); - } - } - - - @Test - public void thenNThrows() { - for (int n = 10; n < 100; n++) { - PatternN p = JoinObservable.from(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some) - .and(some); - - for (int j = 0; j < n - 10; j++) { - p = p.and(some); - } - verifyError(JoinObservable.when(p.then(throwFunc))); - } - } -} diff --git a/rxjava-contrib/rxjava-math/build.gradle b/rxjava-contrib/rxjava-math/build.gradle deleted file mode 100644 index a8337efbda..0000000000 --- a/rxjava-contrib/rxjava-math/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -apply plugin: 'osgi' - -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - -dependencies { - compile project(':rxjava') - testCompile project(":rxjava").sourceSets.test.output - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' -} - -javadoc { - options { - doclet = "org.benjchristensen.doclet.DocletExclude" - docletpath = [rootProject.file('./gradle/doclet-exclude.jar')] - stylesheetFile = rootProject.file('./gradle/javadocStyleSheet.css') - windowTitle = "RxJava Javadoc ${project.version}" - } - options.addStringOption('top').value = '

RxJava

' -} - -jar { - manifest { - name = 'rxjava-math' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/ReactiveX/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } -} diff --git a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageDouble.java b/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageDouble.java deleted file mode 100644 index d2071a9b49..0000000000 --- a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageDouble.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.math.operators; - -import rx.Observable.Operator; -import rx.Subscriber; -import rx.functions.Func1; - -/** - * Compute the average by extracting double values from the source via an - * extractor function. - * - * @param - * the source value type - */ -public final class OperatorAverageDouble implements Operator { - final Func1 valueExtractor; - - public OperatorAverageDouble(Func1 valueExtractor) { - this.valueExtractor = valueExtractor; - } - - @Override - public Subscriber call(Subscriber child) { - return new AverageObserver(child); - } - - /** Computes the average. */ - private final class AverageObserver extends Subscriber { - final Subscriber child; - double sum; - int count; - - public AverageObserver(Subscriber subscriber) { - super(subscriber); - this.child = subscriber; - } - - @Override - public void onNext(T args) { - sum += valueExtractor.call(args); - count++; - } - - @Override - public void onError(Throwable e) { - child.onError(e); - } - - @Override - public void onCompleted() { - if (count > 0) { - try { - child.onNext(sum / count); - } catch (Throwable t) { - child.onError(t); - return; - } - child.onCompleted(); - } else { - child.onError(new IllegalArgumentException("Sequence contains no elements")); - } - } - - } -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageFloat.java b/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageFloat.java deleted file mode 100644 index 15ef0a7045..0000000000 --- a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageFloat.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.math.operators; - -import rx.Observable.Operator; -import rx.Subscriber; -import rx.functions.Func1; - -/** - * Compute the average by extracting float values from the source via an - * extractor function. - * - * @param - * the source value type - */ -public final class OperatorAverageFloat implements Operator { - final Func1 valueExtractor; - - public OperatorAverageFloat(Func1 valueExtractor) { - this.valueExtractor = valueExtractor; - } - - @Override - public Subscriber call(Subscriber child) { - return new AverageObserver(child); - } - - /** Computes the average. */ - private final class AverageObserver extends Subscriber { - final Subscriber child; - float sum; - int count; - - public AverageObserver(Subscriber subscriber) { - super(subscriber); - this.child = subscriber; - } - - @Override - public void onNext(T args) { - sum += valueExtractor.call(args); - count++; - } - - @Override - public void onError(Throwable e) { - child.onError(e); - } - - @Override - public void onCompleted() { - if (count > 0) { - try { - child.onNext(sum / count); - } catch (Throwable t) { - child.onError(t); - return; - } - child.onCompleted(); - } else { - child.onError(new IllegalArgumentException("Sequence contains no elements")); - } - } - - } -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageInteger.java b/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageInteger.java deleted file mode 100644 index 437975e887..0000000000 --- a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageInteger.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.math.operators; - -import rx.Observable.Operator; -import rx.Subscriber; -import rx.functions.Func1; - -/** - * Compute the average by extracting integer values from the source via an - * extractor function. - * - * @param - * the source value type - */ -public final class OperatorAverageInteger implements Operator { - final Func1 valueExtractor; - - public OperatorAverageInteger(Func1 valueExtractor) { - this.valueExtractor = valueExtractor; - } - - @Override - public Subscriber call(Subscriber t1) { - return new AverageObserver(t1); - } - - /** Computes the average. */ - private final class AverageObserver extends Subscriber { - final Subscriber child; - int sum; - int count; - - public AverageObserver(Subscriber subscriber) { - super(subscriber); - this.child = subscriber; - } - - @Override - public void onNext(T args) { - sum += valueExtractor.call(args); - count++; - } - - @Override - public void onError(Throwable e) { - child.onError(e); - } - - @Override - public void onCompleted() { - if (count > 0) { - try { - child.onNext(sum / count); - } catch (Throwable t) { - child.onError(t); - return; - } - child.onCompleted(); - } else { - child.onError(new IllegalArgumentException("Sequence contains no elements")); - } - } - - } -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageLong.java b/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageLong.java deleted file mode 100644 index a5725adfb2..0000000000 --- a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorAverageLong.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.math.operators; - -import rx.Observable.Operator; -import rx.Subscriber; -import rx.functions.Func1; - -/** - * Compute the average by extracting long values from the source via an - * extractor function. - * - * @param - * the source value type - */ -public final class OperatorAverageLong implements Operator { - final Func1 valueExtractor; - - public OperatorAverageLong(Func1 valueExtractor) { - this.valueExtractor = valueExtractor; - } - - @Override - public Subscriber call(Subscriber child) { - return new AverageObserver(child); - } - - /** Computes the average. */ - private final class AverageObserver extends Subscriber { - final Subscriber child; - long sum; - int count; - - public AverageObserver(Subscriber subscriber) { - super(subscriber); - this.child = subscriber; - } - - @Override - public void onNext(T args) { - sum += valueExtractor.call(args); - count++; - } - - @Override - public void onError(Throwable e) { - child.onError(e); - } - - @Override - public void onCompleted() { - if (count > 0) { - try { - child.onNext(sum / count); - } catch (Throwable t) { - child.onError(t); - return; - } - child.onCompleted(); - } else { - child.onError(new IllegalArgumentException("Sequence contains no elements")); - } - } - - } -} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorMinMax.java b/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorMinMax.java deleted file mode 100644 index 75d7696879..0000000000 --- a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorMinMax.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.math.operators; - -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; - -import rx.Observable; -import rx.functions.Func1; -import rx.functions.Func2; - -/** - * Returns the minimum element in an observable sequence. - */ -public final class OperatorMinMax { - private OperatorMinMax() { throw new IllegalStateException("No instances!"); } - - public static > Observable min( - Observable source) { - return minMax(source, -1L); - } - - public static Observable min(Observable source, - final Comparator comparator) { - return minMax(source, comparator, -1L); - } - - public static > Observable> minBy( - Observable source, final Func1 selector) { - return minMaxBy(source, selector, -1L); - } - - public static Observable> minBy(Observable source, - final Func1 selector, final Comparator comparator) { - return minMaxBy(source, selector, comparator, -1L); - } - - public static > Observable max( - Observable source) { - return minMax(source, 1L); - } - - public static Observable max(Observable source, - final Comparator comparator) { - return minMax(source, comparator, 1L); - } - - public static > Observable> maxBy( - Observable source, final Func1 selector) { - return minMaxBy(source, selector, 1L); - } - - public static Observable> maxBy(Observable source, - final Func1 selector, final Comparator comparator) { - return minMaxBy(source, selector, comparator, 1L); - } - - private static > Observable minMax( - Observable source, final long flag) { - return source.reduce(new Func2() { - @Override - public T call(T acc, T value) { - if (flag * acc.compareTo(value) > 0) { - return acc; - } - return value; - } - }); - } - - private static Observable minMax(Observable source, - final Comparator comparator, final long flag) { - return source.reduce(new Func2() { - @Override - public T call(T acc, T value) { - if (flag * comparator.compare(acc, value) > 0) { - return acc; - } - return value; - } - }); - } - - private static > Observable> minMaxBy( - Observable source, final Func1 selector, final long flag) { - return source.reduce(new ArrayList(), - new Func2, T, List>() { - - @Override - public List call(List acc, T value) { - if (acc.isEmpty()) { - acc.add(value); - } else { - int compareResult = selector.call(acc.get(0)) - .compareTo(selector.call(value)); - if (compareResult == 0) { - acc.add(value); - } else if (flag * compareResult < 0) { - acc.clear(); - acc.add(value); - } - } - return acc; - } - }); - } - - private static Observable> minMaxBy(Observable source, - final Func1 selector, final Comparator comparator, - final long flag) { - return source.reduce(new ArrayList(), - new Func2, T, List>() { - - @Override - public List call(List acc, T value) { - if (acc.isEmpty()) { - acc.add(value); - } else { - int compareResult = comparator.compare( - selector.call(acc.get(0)), - selector.call(value)); - if (compareResult == 0) { - acc.add(value); - } else if (flag * compareResult < 0) { - acc.clear(); - acc.add(value); - } - } - return acc; - } - }); - } - -} diff --git a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorSum.java b/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorSum.java deleted file mode 100644 index cdd3acf21d..0000000000 --- a/rxjava-contrib/rxjava-math/src/main/java/rx/math/operators/OperatorSum.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.math.operators; - -import rx.Observable; -import rx.functions.Func2; - -/** - * A few operators for implementing the sum operation. - * - * @see MSDN: - * Observable.Sum - */ -public final class OperatorSum { - private OperatorSum() { throw new IllegalStateException("No instances!"); } - - public static Observable sumIntegers(Observable source) { - return source.reduce(0, ACCUM_INT); - } - - public static Observable sumLongs(Observable source) { - return source.reduce(0l, ACCUM_LONG); - } - - public static Observable sumFloats(Observable source) { - return source.reduce(0.0f, ACCUM_FLOAT); - } - - public static Observable sumDoubles(Observable source) { - return source.reduce(0.0d, ACCUM_DOUBLE); - } - - public static Observable sumAtLeastOneIntegers(Observable source) { - return source.reduce(ACCUM_INT); - } - - public static Observable sumAtLeastOneLongs(Observable source) { - return source.reduce(ACCUM_LONG); - } - - public static Observable sumAtLeastOneFloats(Observable source) { - return source.reduce(ACCUM_FLOAT); - } - - public static Observable sumAtLeastOneDoubles(Observable source) { - return source.reduce(ACCUM_DOUBLE); - } - - private static final Func2 ACCUM_INT = new Func2() { - @Override - public Integer call(Integer accu, Integer next) { - return accu + next; - } - }; - - private static final Func2 ACCUM_LONG = new Func2() { - @Override - public Long call(Long accu, Long next) { - return accu + next; - } - }; - - private static final Func2 ACCUM_FLOAT = new Func2() { - @Override - public Float call(Float accu, Float next) { - return accu + next; - } - }; - - private static final Func2 ACCUM_DOUBLE = new Func2() { - @Override - public Double call(Double accu, Double next) { - return accu + next; - } - }; -} diff --git a/rxjava-contrib/rxjava-math/src/main/java/rx/observables/MathObservable.java b/rxjava-contrib/rxjava-math/src/main/java/rx/observables/MathObservable.java deleted file mode 100644 index 4e08caeeaa..0000000000 --- a/rxjava-contrib/rxjava-math/src/main/java/rx/observables/MathObservable.java +++ /dev/null @@ -1,382 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.observables; - -import java.util.Comparator; - -import rx.Observable; -import rx.functions.Func1; -import rx.functions.Functions; -import rx.math.operators.OperatorMinMax; -import rx.math.operators.OperatorSum; -import rx.math.operators.OperatorAverageDouble; -import rx.math.operators.OperatorAverageFloat; -import rx.math.operators.OperatorAverageInteger; -import rx.math.operators.OperatorAverageLong; - -public class MathObservable { - - private final Observable o; - - private MathObservable(Observable o) { - this.o = o; - } - - public static MathObservable from(Observable o) { - return new MathObservable(o); - } - - /** - * Returns an Observable that emits the average of the Doubles emitted by the source Observable. - *

- * - * - * @param source - * source Observable to compute the average of - * @return an Observable that emits a single item: the average of all the Doubles emitted by the source - * Observable - * @see RxJava Wiki: averageDouble() - * @see MSDN: Observable.Average - */ - public final static Observable averageDouble(Observable source) { - return source.lift(new OperatorAverageDouble(Functions.identity())); - } - - /** - * Returns an Observable that emits the average of the Floats emitted by the source Observable. - *

- * - * - * @param source - * source Observable to compute the average of - * @return an Observable that emits a single item: the average of all the Floats emitted by the source - * Observable - * @see RxJava Wiki: averageFloat() - * @see MSDN: Observable.Average - */ - public final static Observable averageFloat(Observable source) { - return source.lift(new OperatorAverageFloat(Functions.identity())); - } - - /** - * Returns an Observable that emits the average of the Integers emitted by the source Observable. - *

- * - * - * @param source - * source Observable to compute the average of - * @return an Observable that emits a single item: the average of all the Integers emitted by the source - * Observable - * @throws IllegalArgumentException - * if the source Observable emits no items - * @see RxJava Wiki: averageInteger() - * @see MSDN: Observable.Average - */ - public final static Observable averageInteger(Observable source) { - return source.lift(new OperatorAverageInteger(Functions.identity())); - } - - /** - * Returns an Observable that emits the average of the Longs emitted by the source Observable. - *

- * - * - * @param source - * source Observable to compute the average of - * @return an Observable that emits a single item: the average of all the Longs emitted by the source - * Observable - * @see RxJava Wiki: averageLong() - * @see MSDN: Observable.Average - */ - public final static Observable averageLong(Observable source) { - return source.lift(new OperatorAverageLong(Functions.identity())); - } - - /** - * Returns an Observable that emits the single item emitted by the source Observable with the maximum - * numeric value. If there is more than one item with the same maximum value, it emits the last-emitted of - * these. - *

- * - * - * @param source - * an Observable to scan for the maximum emitted item - * @return an Observable that emits this maximum item - * @throws IllegalArgumentException - * if the source is empty - * @see RxJava Wiki: max() - * @see MSDN: Observable.Max - */ - public final static > Observable max(Observable source) { - return OperatorMinMax.max(source); - } - - /** - * Returns an Observable that emits the single numerically minimum item emitted by the source Observable. - * If there is more than one such item, it returns the last-emitted one. - *

- * - * - * @param source - * an Observable to determine the minimum item of - * @return an Observable that emits the minimum item emitted by the source Observable - * @throws IllegalArgumentException - * if the source is empty - * @see MSDN: Observable.Min - */ - public final static > Observable min(Observable source) { - return OperatorMinMax.min(source); - } - - /** - * Returns an Observable that emits the sum of all the Doubles emitted by the source Observable. - *

- * - * - * @param source - * the source Observable to compute the sum of - * @return an Observable that emits a single item: the sum of all the Doubles emitted by the source - * Observable - * @see RxJava Wiki: sumDouble() - * @see MSDN: Observable.Sum - */ - public final static Observable sumDouble(Observable source) { - return OperatorSum.sumDoubles(source); - } - - /** - * Returns an Observable that emits the sum of all the Floats emitted by the source Observable. - *

- * - * - * @param source - * the source Observable to compute the sum of - * @return an Observable that emits a single item: the sum of all the Floats emitted by the source - * Observable - * @see RxJava Wiki: sumFloat() - * @see MSDN: Observable.Sum - */ - public final static Observable sumFloat(Observable source) { - return OperatorSum.sumFloats(source); - } - - /** - * Returns an Observable that emits the sum of all the Integers emitted by the source Observable. - *

- * - * - * @param source - * source Observable to compute the sum of - * @return an Observable that emits a single item: the sum of all the Integers emitted by the source - * Observable - * @see RxJava Wiki: sumInteger() - * @see MSDN: Observable.Sum - */ - public final static Observable sumInteger(Observable source) { - return OperatorSum.sumIntegers(source); - } - - /** - * Returns an Observable that emits the sum of all the Longs emitted by the source Observable. - *

- * - * - * @param source - * source Observable to compute the sum of - * @return an Observable that emits a single item: the sum of all the Longs emitted by the - * source Observable - * @see RxJava Wiki: sumLong() - * @see MSDN: Observable.Sum - */ - public final static Observable sumLong(Observable source) { - return OperatorSum.sumLongs(source); - } - - /** - * Returns an Observable that transforms items emitted by the source Observable into Doubles by using a - * function you provide and then emits the Double average of the complete sequence of transformed values. - *

- * - * - * @param valueExtractor - * the function to transform an item emitted by the source Observable into a Double - * @return an Observable that emits a single item: the Double average of the complete sequence of items - * emitted by the source Observable when transformed into Doubles by the specified function - * @see RxJava Wiki: averageDouble() - * @see MSDN: Observable.Average - */ - public final Observable averageDouble(Func1 valueExtractor) { - return o.lift(new OperatorAverageDouble(valueExtractor)); - } - - /** - * Returns an Observable that transforms items emitted by the source Observable into Floats by using a - * function you provide and then emits the Float average of the complete sequence of transformed values. - *

- * - * - * @param valueExtractor - * the function to transform an item emitted by the source Observable into a Float - * @return an Observable that emits a single item: the Float average of the complete sequence of items - * emitted by the source Observable when transformed into Floats by the specified function - * @see RxJava Wiki: averageFloat() - * @see MSDN: Observable.Average - */ - public final Observable averageFloat(Func1 valueExtractor) { - return o.lift(new OperatorAverageFloat(valueExtractor)); - } - - /** - * Returns an Observable that transforms items emitted by the source Observable into Integers by using a - * function you provide and then emits the Integer average of the complete sequence of transformed values. - *

- * - * - * @param valueExtractor - * the function to transform an item emitted by the source Observable into an Integer - * @return an Observable that emits a single item: the Integer average of the complete sequence of items - * emitted by the source Observable when transformed into Integers by the specified function - * @see RxJava Wiki: averageInteger() - * @see MSDN: Observable.Average - */ - public final Observable averageInteger(Func1 valueExtractor) { - return o.lift(new OperatorAverageInteger(valueExtractor)); - } - - /** - * Returns an Observable that transforms items emitted by the source Observable into Longs by using a - * function you provide and then emits the Long average of the complete sequence of transformed values. - *

- * - * - * @param valueExtractor - * the function to transform an item emitted by the source Observable into a Long - * @return an Observable that emits a single item: the Long average of the complete sequence of items - * emitted by the source Observable when transformed into Longs by the specified function - * @see RxJava Wiki: averageLong() - * @see MSDN: Observable.Average - */ - public final Observable averageLong(Func1 valueExtractor) { - return o.lift(new OperatorAverageLong(valueExtractor)); - } - - /** - * Returns an Observable that emits the maximum item emitted by the source Observable, according to the - * specified comparator. If there is more than one item with the same maximum value, it emits the - * last-emitted of these. - *

- * - * - * @param comparator - * the comparer used to compare items - * @return an Observable that emits the maximum item emitted by the source Observable, according to the - * specified comparator - * @throws IllegalArgumentException - * if the source is empty - * @see RxJava Wiki: max() - * @see MSDN: Observable.Max - */ - public final Observable max(Comparator comparator) { - return OperatorMinMax.max(o, comparator); - } - - /** - * Returns an Observable that emits the minimum item emitted by the source Observable, according to a - * specified comparator. If there is more than one such item, it returns the last-emitted one. - *

- * - * - * @param comparator - * the comparer used to compare elements - * @return an Observable that emits the minimum item emitted by the source Observable according to the - * specified comparator - * @throws IllegalArgumentException - * if the source is empty - * @see RxJava Wiki: min() - * @see MSDN: Observable.Min - */ - public final Observable min(Comparator comparator) { - return OperatorMinMax.min(o, comparator); - } - - /** - * Returns an Observable that extracts a Double from each of the items emitted by the source Observable via - * a function you specify, and then emits the sum of these Doubles. - *

- * - * - * @param valueExtractor - * the function to extract a Double from each item emitted by the source Observable - * @return an Observable that emits the Double sum of the Double values corresponding to the items emitted - * by the source Observable as transformed by the provided function - * @see RxJava Wiki: sumDouble() - * @see MSDN: Observable.Sum - */ - public final Observable sumDouble(Func1 valueExtractor) { - return OperatorSum.sumAtLeastOneDoubles(o.map(valueExtractor)); - } - - /** - * Returns an Observable that extracts a Float from each of the items emitted by the source Observable via - * a function you specify, and then emits the sum of these Floats. - *

- * - * - * @param valueExtractor - * the function to extract a Float from each item emitted by the source Observable - * @return an Observable that emits the Float sum of the Float values corresponding to the items emitted by - * the source Observable as transformed by the provided function - * @see RxJava Wiki: sumFloat() - * @see MSDN: Observable.Sum - */ - public final Observable sumFloat(Func1 valueExtractor) { - return OperatorSum.sumAtLeastOneFloats(o.map(valueExtractor)); - } - - /** - * Returns an Observable that extracts an Integer from each of the items emitted by the source Observable - * via a function you specify, and then emits the sum of these Integers. - *

- * - * - * @param valueExtractor - * the function to extract an Integer from each item emitted by the source Observable - * @return an Observable that emits the Integer sum of the Integer values corresponding to the items emitted - * by the source Observable as transformed by the provided function - * @see RxJava Wiki: sumInteger() - * @see MSDN: Observable.Sum - */ - public final Observable sumInteger(Func1 valueExtractor) { - return OperatorSum.sumAtLeastOneIntegers(o.map(valueExtractor)); - } - - /** - * Returns an Observable that extracts a Long from each of the items emitted by the source Observable via a - * function you specify, and then emits the sum of these Longs. - *

- * - * - * @param valueExtractor - * the function to extract a Long from each item emitted by the source Observable - * @return an Observable that emits the Long sum of the Long values corresponding to the items emitted by - * the source Observable as transformed by the provided function - * @see RxJava Wiki: sumLong() - * @see MSDN: Observable.Sum - */ - public final Observable sumLong(Func1 valueExtractor) { - return OperatorSum.sumAtLeastOneLongs(o.map(valueExtractor)); - } -} diff --git a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorAverageTest.java b/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorAverageTest.java deleted file mode 100644 index 2c2a0d756f..0000000000 --- a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorAverageTest.java +++ /dev/null @@ -1,363 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.math.operators; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyDouble; -import static org.mockito.Matchers.anyFloat; -import static org.mockito.Matchers.anyInt; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.isA; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import org.junit.Test; - -import rx.Observable; -import rx.Observer; -import rx.functions.Func1; -import rx.observables.MathObservable; -import static rx.observables.MathObservable.*; - -public class OperatorAverageTest { - - @SuppressWarnings("unchecked") - Observer w = mock(Observer.class); - @SuppressWarnings("unchecked") - Observer wl = mock(Observer.class); - @SuppressWarnings("unchecked") - Observer wf = mock(Observer.class); - @SuppressWarnings("unchecked") - Observer wd = mock(Observer.class); - - @Test - public void testAverageOfAFewInts() throws Throwable { - Observable src = Observable.just(1, 2, 3, 4, 6); - averageInteger(src).subscribe(w); - - verify(w, times(1)).onNext(anyInt()); - verify(w).onNext(3); - verify(w, never()).onError(any(Throwable.class)); - verify(w, times(1)).onCompleted(); - } - - @Test - public void testEmptyAverage() throws Throwable { - Observable src = Observable.empty(); - averageInteger(src).subscribe(w); - - verify(w, never()).onNext(anyInt()); - verify(w, times(1)).onError(isA(IllegalArgumentException.class)); - verify(w, never()).onCompleted(); - } - - @Test - public void testAverageOfAFewLongs() throws Throwable { - Observable src = Observable.just(1L, 2L, 3L, 4L, 6L); - averageLong(src).subscribe(wl); - - verify(wl, times(1)).onNext(anyLong()); - verify(wl).onNext(3L); - verify(wl, never()).onError(any(Throwable.class)); - verify(wl, times(1)).onCompleted(); - } - - @Test - public void testEmptyAverageLongs() throws Throwable { - Observable src = Observable.empty(); - averageLong(src).subscribe(wl); - - verify(wl, never()).onNext(anyLong()); - verify(wl, times(1)).onError(isA(IllegalArgumentException.class)); - verify(wl, never()).onCompleted(); - } - - @Test - public void testAverageOfAFewFloats() throws Throwable { - Observable src = Observable.just(1.0f, 2.0f); - averageFloat(src).subscribe(wf); - - verify(wf, times(1)).onNext(anyFloat()); - verify(wf).onNext(1.5f); - verify(wf, never()).onError(any(Throwable.class)); - verify(wf, times(1)).onCompleted(); - } - - @Test - public void testEmptyAverageFloats() throws Throwable { - Observable src = Observable.empty(); - averageFloat(src).subscribe(wf); - - verify(wf, never()).onNext(anyFloat()); - verify(wf, times(1)).onError(isA(IllegalArgumentException.class)); - verify(wf, never()).onCompleted(); - } - - @Test - public void testAverageOfAFewDoubles() throws Throwable { - Observable src = Observable.just(1.0d, 2.0d); - averageDouble(src).subscribe(wd); - - verify(wd, times(1)).onNext(anyDouble()); - verify(wd).onNext(1.5d); - verify(wd, never()).onError(any(Throwable.class)); - verify(wd, times(1)).onCompleted(); - } - - @Test - public void testEmptyAverageDoubles() throws Throwable { - Observable src = Observable.empty(); - averageDouble(src).subscribe(wd); - - verify(wd, never()).onNext(anyDouble()); - verify(wd, times(1)).onError(isA(IllegalArgumentException.class)); - verify(wd, never()).onCompleted(); - } - - void testThrows(Observer o, Class errorClass) { - verify(o, never()).onNext(any()); - verify(o, never()).onCompleted(); - verify(o, times(1)).onError(any(errorClass)); - } - - void testValue(Observer o, N value) { - verify(o, times(1)).onNext(value); - verify(o, times(1)).onCompleted(); - verify(o, never()).onError(any(Throwable.class)); - } - - @Test - public void testIntegerAverageSelector() { - Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Func1 length = new Func1() { - @Override - public Integer call(String t1) { - return t1.length(); - } - }; - - Observable result = MathObservable.from(source).averageInteger(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testValue(o, 2); - } - - @Test - public void testLongAverageSelector() { - Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Func1 length = new Func1() { - @Override - public Long call(String t1) { - return (long) t1.length(); - } - }; - - Observable result = MathObservable.from(source).averageLong(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testValue(o, 2L); - } - - @Test - public void testFloatAverageSelector() { - Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Func1 length = new Func1() { - @Override - public Float call(String t1) { - return (float) t1.length(); - } - }; - - Observable result = MathObservable.from(source).averageFloat(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testValue(o, 2.5f); - } - - @Test - public void testDoubleAverageSelector() { - Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Func1 length = new Func1() { - @Override - public Double call(String t1) { - return (double) t1.length(); - } - }; - - Observable result = MathObservable.from(source).averageDouble(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testValue(o, 2.5d); - } - - @Test - public void testIntegerAverageSelectorEmpty() { - Observable source = Observable.empty(); - Func1 length = new Func1() { - @Override - public Integer call(String t1) { - return t1.length(); - } - }; - - Observable result = MathObservable.from(source).averageInteger(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, IllegalArgumentException.class); - } - - @Test - public void testLongAverageSelectorEmpty() { - Observable source = Observable.empty(); - Func1 length = new Func1() { - @Override - public Long call(String t1) { - return (long) t1.length(); - } - }; - - Observable result = MathObservable.from(source).averageLong(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, IllegalArgumentException.class); - } - - @Test - public void testFloatAverageSelectorEmpty() { - Observable source = Observable.empty(); - Func1 length = new Func1() { - @Override - public Float call(String t1) { - return (float) t1.length(); - } - }; - - Observable result = MathObservable.from(source).averageFloat(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, IllegalArgumentException.class); - } - - @Test - public void testDoubleAverageSelectorEmpty() { - Observable source = Observable.empty(); - Func1 length = new Func1() { - @Override - public Double call(String t1) { - return (double) t1.length(); - } - }; - - Observable result = MathObservable.from(source).averageDouble(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, IllegalArgumentException.class); - } - - @Test - public void testIntegerAverageSelectorThrows() { - Observable source = Observable.just("a"); - Func1 length = new Func1() { - @Override - public Integer call(String t1) { - throw new CustomException(); - } - }; - - Observable result = MathObservable.from(source).averageInteger(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, CustomException.class); - } - - @Test - public void testLongAverageSelectorThrows() { - Observable source = Observable.just("a"); - Func1 length = new Func1() { - @Override - public Long call(String t1) { - throw new CustomException(); - } - }; - - Observable result = MathObservable.from(source).averageLong(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, CustomException.class); - } - - @Test - public void testFloatAverageSelectorThrows() { - Observable source = Observable.just("a"); - Func1 length = new Func1() { - @Override - public Float call(String t1) { - throw new CustomException(); - } - }; - - Observable result = MathObservable.from(source).averageFloat(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, CustomException.class); - } - - @Test - public void testDoubleAverageSelectorThrows() { - Observable source = Observable.just("a"); - Func1 length = new Func1() { - @Override - public Double call(String t1) { - throw new CustomException(); - } - }; - - Observable result = MathObservable.from(source).averageDouble(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, CustomException.class); - } - - static class CustomException extends RuntimeException { - private static final long serialVersionUID = 6873927510089089979L; - } -} diff --git a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorMinMaxTest.java b/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorMinMaxTest.java deleted file mode 100644 index 4959701821..0000000000 --- a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorMinMaxTest.java +++ /dev/null @@ -1,355 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.math.operators; - -import static org.mockito.Matchers.*; -import static org.mockito.Mockito.*; -import static rx.math.operators.OperatorMinMax.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.NoSuchElementException; - -import org.junit.Test; -import org.mockito.InOrder; - -import rx.Observable; -import rx.Observer; -import rx.functions.Func1; - -public class OperatorMinMaxTest { - @Test - public void testMin() { - Observable observable = min(Observable.just(2, 3, 1, 4)); - - @SuppressWarnings("unchecked") - Observer observer = (Observer) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(1); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMinWithEmpty() { - Observable observable = min(Observable. empty()); - - @SuppressWarnings("unchecked") - Observer observer = (Observer) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onError( - isA(NoSuchElementException.class)); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMinWithComparator() { - Observable observable = min(Observable.just(2, 3, 1, 4), - new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return o2 - o1; - } - }); - - @SuppressWarnings("unchecked") - Observer observer = (Observer) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(4); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMinWithComparatorAndEmpty() { - Observable observable = min(Observable. empty(), - new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return o2 - o1; - } - }); - - @SuppressWarnings("unchecked") - Observer observer = (Observer) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onError( - isA(NoSuchElementException.class)); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMinBy() { - Observable> observable = minBy( - Observable.just("1", "2", "3", "4", "5", "6"), - new Func1() { - @Override - public Integer call(String t1) { - return Integer.parseInt(t1) % 2; - } - }); - - @SuppressWarnings("unchecked") - Observer> observer = (Observer>) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(Arrays.asList("2", "4", "6")); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMinByWithEmpty() { - Observable> observable = minBy( - Observable. empty(), new Func1() { - @Override - public Integer call(String t1) { - return Integer.parseInt(t1) % 2; - } - }); - - @SuppressWarnings("unchecked") - Observer> observer = (Observer>) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(new ArrayList()); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMinByWithComparator() { - Observable> observable = minBy( - Observable.just("1", "2", "3", "4", "5", "6"), - new Func1() { - @Override - public Integer call(String t1) { - return Integer.parseInt(t1) % 2; - } - }, new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return o2 - o1; - } - }); - - @SuppressWarnings("unchecked") - Observer> observer = (Observer>) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(Arrays.asList("1", "3", "5")); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMinByWithComparatorAndEmpty() { - Observable> observable = minBy( - Observable. empty(), new Func1() { - @Override - public Integer call(String t1) { - return Integer.parseInt(t1) % 2; - } - }, new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return o2 - o1; - } - }); - - @SuppressWarnings("unchecked") - Observer> observer = (Observer>) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(new ArrayList()); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMax() { - Observable observable = max(Observable.just(2, 3, 1, 4)); - - @SuppressWarnings("unchecked") - Observer observer = (Observer) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(4); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMaxWithEmpty() { - Observable observable = max(Observable. empty()); - - @SuppressWarnings("unchecked") - Observer observer = (Observer) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onError( - isA(NoSuchElementException.class)); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMaxWithComparator() { - Observable observable = max(Observable.just(2, 3, 1, 4), - new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return o2 - o1; - } - }); - - @SuppressWarnings("unchecked") - Observer observer = (Observer) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(1); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMaxWithComparatorAndEmpty() { - Observable observable = max(Observable. empty(), - new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return o2 - o1; - } - }); - - @SuppressWarnings("unchecked") - Observer observer = (Observer) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onError( - isA(NoSuchElementException.class)); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMaxBy() { - Observable> observable = maxBy( - Observable.just("1", "2", "3", "4", "5", "6"), - new Func1() { - @Override - public Integer call(String t1) { - return Integer.parseInt(t1) % 2; - } - }); - - @SuppressWarnings("unchecked") - Observer> observer = (Observer>) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(Arrays.asList("1", "3", "5")); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMaxByWithEmpty() { - Observable> observable = maxBy( - Observable. empty(), new Func1() { - @Override - public Integer call(String t1) { - return Integer.parseInt(t1) % 2; - } - }); - - @SuppressWarnings("unchecked") - Observer> observer = (Observer>) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(new ArrayList()); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMaxByWithComparator() { - Observable> observable = maxBy( - Observable.just("1", "2", "3", "4", "5", "6"), - new Func1() { - @Override - public Integer call(String t1) { - return Integer.parseInt(t1) % 2; - } - }, new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return o2 - o1; - } - }); - - @SuppressWarnings("unchecked") - Observer> observer = (Observer>) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(Arrays.asList("2", "4", "6")); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } - - @Test - public void testMaxByWithComparatorAndEmpty() { - Observable> observable = maxBy( - Observable. empty(), new Func1() { - @Override - public Integer call(String t1) { - return Integer.parseInt(t1) % 2; - } - }, new Comparator() { - @Override - public int compare(Integer o1, Integer o2) { - return o2 - o1; - } - }); - - @SuppressWarnings("unchecked") - Observer> observer = (Observer>) mock(Observer.class); - - observable.subscribe(observer); - InOrder inOrder = inOrder(observer); - inOrder.verify(observer, times(1)).onNext(new ArrayList()); - inOrder.verify(observer, times(1)).onCompleted(); - inOrder.verifyNoMoreInteractions(); - } -} diff --git a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorSumTest.java b/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorSumTest.java deleted file mode 100644 index ace50c181b..0000000000 --- a/rxjava-contrib/rxjava-math/src/test/java/rx/math/operators/OperatorSumTest.java +++ /dev/null @@ -1,359 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.math.operators; - -import static org.mockito.Matchers.*; -import static org.mockito.Mockito.*; -import static rx.math.operators.OperatorSum.*; - -import org.junit.Test; - -import rx.Observable; -import rx.Observer; -import rx.functions.Func1; -import rx.observables.MathObservable; - -public class OperatorSumTest { - - @SuppressWarnings("unchecked") - Observer w = mock(Observer.class); - @SuppressWarnings("unchecked") - Observer wl = mock(Observer.class); - @SuppressWarnings("unchecked") - Observer wf = mock(Observer.class); - @SuppressWarnings("unchecked") - Observer wd = mock(Observer.class); - - @Test - public void testSumOfAFewInts() throws Throwable { - Observable src = Observable.just(1, 2, 3, 4, 5); - sumIntegers(src).subscribe(w); - - verify(w, times(1)).onNext(anyInt()); - verify(w).onNext(15); - verify(w, never()).onError(any(Throwable.class)); - verify(w, times(1)).onCompleted(); - } - - @Test - public void testEmptySum() throws Throwable { - Observable src = Observable.empty(); - sumIntegers(src).subscribe(w); - - verify(w, times(1)).onNext(anyInt()); - verify(w).onNext(0); - verify(w, never()).onError(any(Throwable.class)); - verify(w, times(1)).onCompleted(); - } - - @Test - public void testSumOfAFewLongs() throws Throwable { - Observable src = Observable.just(1L, 2L, 3L, 4L, 5L); - sumLongs(src).subscribe(wl); - - verify(wl, times(1)).onNext(anyLong()); - verify(wl).onNext(15L); - verify(wl, never()).onError(any(Throwable.class)); - verify(wl, times(1)).onCompleted(); - } - - @Test - public void testEmptySumLongs() throws Throwable { - Observable src = Observable.empty(); - sumLongs(src).subscribe(wl); - - verify(wl, times(1)).onNext(anyLong()); - verify(wl).onNext(0L); - verify(wl, never()).onError(any(Throwable.class)); - verify(wl, times(1)).onCompleted(); - } - - @Test - public void testSumOfAFewFloats() throws Throwable { - Observable src = Observable.just(1.0f); - sumFloats(src).subscribe(wf); - - verify(wf, times(1)).onNext(anyFloat()); - verify(wf).onNext(1.0f); - verify(wf, never()).onError(any(Throwable.class)); - verify(wf, times(1)).onCompleted(); - } - - @Test - public void testEmptySumFloats() throws Throwable { - Observable src = Observable.empty(); - sumFloats(src).subscribe(wf); - - verify(wf, times(1)).onNext(anyFloat()); - verify(wf).onNext(0.0f); - verify(wf, never()).onError(any(Throwable.class)); - verify(wf, times(1)).onCompleted(); - } - - @Test - public void testSumOfAFewDoubles() throws Throwable { - Observable src = Observable.just(0.0d, 1.0d, 0.5d); - sumDoubles(src).subscribe(wd); - - verify(wd, times(1)).onNext(anyDouble()); - verify(wd).onNext(1.5d); - verify(wd, never()).onError(any(Throwable.class)); - verify(wd, times(1)).onCompleted(); - } - - @Test - public void testEmptySumDoubles() throws Throwable { - Observable src = Observable.empty(); - sumDoubles(src).subscribe(wd); - - verify(wd, times(1)).onNext(anyDouble()); - verify(wd).onNext(0.0d); - verify(wd, never()).onError(any(Throwable.class)); - verify(wd, times(1)).onCompleted(); - } - - void testThrows(Observer o, Class errorClass) { - verify(o, never()).onNext(any()); - verify(o, never()).onCompleted(); - verify(o, times(1)).onError(any(errorClass)); - } - - void testValue(Observer o, N value) { - verify(o, times(1)).onNext(value); - verify(o, times(1)).onCompleted(); - verify(o, never()).onError(any(Throwable.class)); - } - - @Test - public void testIntegerSumSelector() { - Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Func1 length = new Func1() { - @Override - public Integer call(String t1) { - return t1.length(); - } - }; - - Observable result = MathObservable.from(source).sumInteger(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testValue(o, 10); - } - - @Test - public void testLongSumSelector() { - Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Func1 length = new Func1() { - @Override - public Long call(String t1) { - return (long) t1.length(); - } - }; - - Observable result = MathObservable.from(source).sumLong(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testValue(o, 10L); - } - - @Test - public void testFloatSumSelector() { - Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Func1 length = new Func1() { - @Override - public Float call(String t1) { - return (float) t1.length(); - } - }; - - Observable result = MathObservable.from(source).sumFloat(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testValue(o, 10f); - } - - @Test - public void testDoubleSumSelector() { - Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Func1 length = new Func1() { - @Override - public Double call(String t1) { - return (double) t1.length(); - } - }; - - Observable result = MathObservable.from(source).sumDouble(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testValue(o, 10d); - } - - @Test - public void testIntegerSumSelectorEmpty() { - Observable source = Observable.empty(); - Func1 length = new Func1() { - @Override - public Integer call(String t1) { - return t1.length(); - } - }; - - Observable result = MathObservable.from(source).sumInteger(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, IllegalArgumentException.class); - } - - @Test - public void testLongSumSelectorEmpty() { - Observable source = Observable.empty(); - Func1 length = new Func1() { - @Override - public Long call(String t1) { - return (long) t1.length(); - } - }; - - Observable result = MathObservable.from(source).sumLong(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, IllegalArgumentException.class); - } - - @Test - public void testFloatSumSelectorEmpty() { - Observable source = Observable.empty(); - Func1 length = new Func1() { - @Override - public Float call(String t1) { - return (float) t1.length(); - } - }; - - Observable result = MathObservable.from(source).sumFloat(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, IllegalArgumentException.class); - } - - @Test - public void testDoubleSumSelectorEmpty() { - Observable source = Observable.empty(); - Func1 length = new Func1() { - @Override - public Double call(String t1) { - return (double) t1.length(); - } - }; - - Observable result = MathObservable.from(source).sumDouble(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, IllegalArgumentException.class); - } - - @Test - public void testIntegerSumSelectorThrows() { - Observable source = Observable.just("a"); - Func1 length = new Func1() { - @Override - public Integer call(String t1) { - throw new CustomException(); - } - }; - - Observable result = MathObservable.from(source).sumInteger(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, CustomException.class); - } - - @Test - public void testLongSumSelectorThrows() { - Observable source = Observable.just("a"); - Func1 length = new Func1() { - @Override - public Long call(String t1) { - throw new CustomException(); - } - }; - - Observable result = MathObservable.from(source).sumLong(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, CustomException.class); - } - - @Test - public void testFloatSumSelectorThrows() { - Observable source = Observable.just("a"); - Func1 length = new Func1() { - @Override - public Float call(String t1) { - throw new CustomException(); - } - }; - - Observable result = MathObservable.from(source).sumFloat(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, CustomException.class); - } - - @Test - public void testDoubleSumSelectorThrows() { - Observable source = Observable.just("a"); - Func1 length = new Func1() { - @Override - public Double call(String t1) { - throw new CustomException(); - } - }; - - Observable result = MathObservable.from(source).sumDouble(length); - @SuppressWarnings("unchecked") - Observer o = mock(Observer.class); - result.subscribe(o); - - testThrows(o, CustomException.class); - } - - static class CustomException extends RuntimeException { - private static final long serialVersionUID = 8825937249852675778L; - } -} diff --git a/rxjava-contrib/rxjava-string/build.gradle b/rxjava-contrib/rxjava-string/build.gradle deleted file mode 100644 index 7de6a27512..0000000000 --- a/rxjava-contrib/rxjava-string/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -apply plugin: 'osgi' - -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - -dependencies { - compile project(':rxjava') - testCompile project(":rxjava").sourceSets.test.output - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' -} - -javadoc { - options { - doclet = "org.benjchristensen.doclet.DocletExclude" - docletpath = [rootProject.file('./gradle/doclet-exclude.jar')] - stylesheetFile = rootProject.file('./gradle/javadocStyleSheet.css') - windowTitle = "RxJava Javadoc ${project.version}" - } - options.addStringOption('top').value = '

RxJava

' -} - -jar { - manifest { - name = 'rxjava-string' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/ReactiveX/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } -} diff --git a/rxjava-contrib/rxjava-string/src/main/java/rx/observables/StringObservable.java b/rxjava-contrib/rxjava-string/src/main/java/rx/observables/StringObservable.java deleted file mode 100644 index 976cd4fb2f..0000000000 --- a/rxjava-contrib/rxjava-string/src/main/java/rx/observables/StringObservable.java +++ /dev/null @@ -1,597 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.observables; - -import rx.Observable; -import rx.Observable.OnSubscribe; -import rx.Observable.Operator; -import rx.Subscriber; -import rx.functions.Action1; -import rx.functions.Func0; -import rx.functions.Func1; -import rx.functions.Func2; - -import java.io.Closeable; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.CharacterCodingException; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; -import java.nio.charset.CodingErrorAction; -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.regex.Pattern; - -public class StringObservable { - /** - * Reads from the bytes from a source {@link InputStream} and outputs {@link Observable} of - * {@code byte[]}s - *

- * - * - * @param i - * Source {@link InputStream} - * @return the Observable containing read byte arrays from the input - */ - public static Observable from(final InputStream i) { - return from(i, 8 * 1024); - } - - /** - * Func0 that allows throwing an {@link IOException}s commonly thrown during IO operations. - * @see StringObservable#using(UnsafeFunc0, Func1) - * - * @param - */ - public static interface UnsafeFunc0 extends Callable { - public R call() throws Exception; - } - - /** - * Helps in creating an Observable that automatically calls {@link Closeable#close()} on completion, error or unsubscribe. - * - *

-     * StringObservable.using(() -> new FileReader(file), (reader) -> StringObservable.from(reader))
-     * 
- * - * @param resourceFactory - * Generates a new {@link Closeable} resource for each new subscription to the returned Observable - * @param observableFactory - * Converts the {@link Closeable} resource into a {@link Observable} with {@link #from(InputStream)} or {@link #from(Reader)} - * @return - * An {@link Observable} that automatically closes the resource when done. - */ - public static Observable using(final UnsafeFunc0 resourceFactory, - final Func1> observableFactory) { - return Observable.using(new Func0() { - @Override - public S call() { - try { - return resourceFactory.call(); - } catch (Throwable e) { - throw new RuntimeException(e); - } - } - }, observableFactory, new Action1() { - @Override - public void call(S resource) { - try { - resource.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - }); - } - - /** - * Reads from the bytes from a source {@link InputStream} and outputs {@link Observable} of - * {@code byte[]}s - *

- * - * - * @param i - * Source {@link InputStream} - * @param size - * internal buffer size - * @return the Observable containing read byte arrays from the input - */ - public static Observable from(final InputStream i, final int size) { - return Observable.create(new OnSubscribe() { - @Override - public void call(Subscriber o) { - byte[] buffer = new byte[size]; - try { - if (o.isUnsubscribed()) - return; - int n = i.read(buffer); - while (n != -1 && !o.isUnsubscribed()) { - o.onNext(Arrays.copyOf(buffer, n)); - if (!o.isUnsubscribed()) - n = i.read(buffer); - } - } catch (IOException e) { - o.onError(e); - } - if (o.isUnsubscribed()) - return; - o.onCompleted(); - } - }); - } - - /** - * Reads from the characters from a source {@link Reader} and outputs {@link Observable} of - * {@link String}s - *

- * - * - * @param i - * Source {@link Reader} - * @return the Observable of Strings read from the source - */ - public static Observable from(final Reader i) { - return from(i, 8 * 1024); - } - - /** - * Reads from the characters from a source {@link Reader} and outputs {@link Observable} of - * {@link String}s - *

- * - * - * @param i - * Source {@link Reader} - * @param size - * internal buffer size - * @return the Observable of Strings read from the source - */ - public static Observable from(final Reader i, final int size) { - return Observable.create(new OnSubscribe() { - @Override - public void call(Subscriber o) { - char[] buffer = new char[size]; - try { - if (o.isUnsubscribed()) - return; - int n = 0; - n = i.read(buffer); - while (n != -1 && !o.isUnsubscribed()) { - o.onNext(new String(buffer, 0, n)); - n = i.read(buffer); - } - } catch (IOException e) { - o.onError(e); - } - if (o.isUnsubscribed()) - return; - o.onCompleted(); - } - }); - } - - /** - * Decodes a stream the multibyte chunks into a stream of strings that works on infinite streams - * and where handles when a multibyte character spans two chunks. - *

- * - * - * @param src - * @param charsetName - * @return the Observable returning a stream of decoded strings - */ - public static Observable decode(Observable src, String charsetName) { - return decode(src, Charset.forName(charsetName)); - } - - /** - * Decodes a stream the multibyte chunks into a stream of strings that works on infinite streams - * and where handles when a multibyte character spans two chunks. - *

- * - * - * @param src - * @param charset - * @return the Observable returning a stream of decoded strings - */ - public static Observable decode(Observable src, Charset charset) { - return decode(src, charset.newDecoder().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE)); - } - - /** - * Decodes a stream the multibyte chunks into a stream of strings that works on infinite streams - * and where it handles when a multibyte character spans two chunks. - * This method allows for more control over how malformed and unmappable characters are handled. - *

- * - * - * @param src - * @param charsetDecoder - * @return the Observable returning a stream of decoded strings - */ - public static Observable decode(final Observable src, final CharsetDecoder charsetDecoder) { - return src.lift(new Operator() { - @Override - public Subscriber call(final Subscriber o) { - return new Subscriber(o) { - private ByteBuffer leftOver = null; - - @Override - public void onCompleted() { - if (process(null, leftOver, true)) - o.onCompleted(); - } - - @Override - public void onError(Throwable e) { - if (process(null, leftOver, true)) - o.onError(e); - } - - @Override - public void onNext(byte[] bytes) { - process(bytes, leftOver, false); - } - - public boolean process(byte[] next, ByteBuffer last, boolean endOfInput) { - if (o.isUnsubscribed()) - return false; - - ByteBuffer bb; - if (last != null) { - if (next != null) { - // merge leftover in front of the next bytes - bb = ByteBuffer.allocate(last.remaining() + next.length); - bb.put(last); - bb.put(next); - bb.flip(); - } - else { // next == null - bb = last; - } - } - else { // last == null - if (next != null) { - bb = ByteBuffer.wrap(next); - } - else { // next == null - return true; - } - } - - CharBuffer cb = CharBuffer.allocate((int) (bb.limit() * charsetDecoder.averageCharsPerByte())); - CoderResult cr = charsetDecoder.decode(bb, cb, endOfInput); - cb.flip(); - - if (cr.isError()) { - try { - cr.throwException(); - } - catch (CharacterCodingException e) { - o.onError(e); - return false; - } - } - - if (bb.remaining() > 0) { - leftOver = bb; - } - else { - leftOver = null; - } - - String string = cb.toString(); - if (!string.isEmpty()) - o.onNext(string); - - return true; - } - }; - } - }); - } - - /** - * Encodes a possible infinite stream of strings into a Observable of byte arrays. - *

- * - * - * @param src - * @param charsetName - * @return the Observable with a stream of encoded byte arrays - */ - public static Observable encode(Observable src, String charsetName) { - return encode(src, Charset.forName(charsetName)); - } - - /** - * Encodes a possible infinite stream of strings into a Observable of byte arrays. - *

- * - * - * @param src - * @param charset - * @return the Observable with a stream of encoded byte arrays - */ - public static Observable encode(Observable src, Charset charset) { - return encode(src, charset.newEncoder().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE)); - } - - /** - * Encodes a possible infinite stream of strings into a Observable of byte arrays. - * This method allows for more control over how malformed and unmappable characters are handled. - *

- * - * - * @param src - * @param charsetEncoder - * @return the Observable with a stream of encoded byte arrays - */ - public static Observable encode(Observable src, final CharsetEncoder charsetEncoder) { - return src.map(new Func1() { - @Override - public byte[] call(String str) { - CharBuffer cb = CharBuffer.wrap(str); - ByteBuffer bb; - try { - bb = charsetEncoder.encode(cb); - } catch (CharacterCodingException e) { - throw new RuntimeException(e); - } - return Arrays.copyOfRange(bb.array(), bb.position(), bb.limit()); - } - }); - } - - /** - * Gather up all of the strings in to one string to be able to use it as one message. Don't use - * this on infinite streams. - *

- * - * - * @param src - * @return the Observable returing all strings concatenated as a single string - */ - public static Observable stringConcat(Observable src) { - return toString(src.reduce(new StringBuilder(), new Func2() { - @Override - public StringBuilder call(StringBuilder a, String b) { - return a.append(b); - } - })); - } - - /** - * Maps {@link Observable}<{@link Object}> to {@link Observable}<{@link String}> by using {@link String#valueOf(Object)} - * @param src - * @return An {@link Observable} of only {@link String}s. - */ - public static Observable toString(Observable src) { - return src.map(new Func1() { - @Override - public String call(Object obj) { - return String.valueOf(obj); - } - }); - } - - /** - * Rechunks the strings based on a regex pattern and works on infinite stream. - * - *

-     * split(["boo:an", "d:foo"], ":") --> ["boo", "and", "foo"]
-     * split(["boo:an", "d:foo"], "o") --> ["b", "", ":and:f", "", ""]
-     * 
- * - * See {@link Pattern} - *

- * - * - * @param src - * @param regex - * @return the Observable streaming the split values - */ - public static Observable split(final Observable src, String regex) { - final Pattern pattern = Pattern.compile(regex); - - return src.lift(new Operator() { - @Override - public Subscriber call(final Subscriber o) { - return new Subscriber(o) { - private String leftOver = null; - - @Override - public void onCompleted() { - output(leftOver); - if (!o.isUnsubscribed()) - o.onCompleted(); - } - - @Override - public void onError(Throwable e) { - output(leftOver); - if (!o.isUnsubscribed()) - o.onError(e); - } - - @Override - public void onNext(String segment) { - String[] parts = pattern.split(segment, -1); - - if (leftOver != null) - parts[0] = leftOver + parts[0]; - for (int i = 0; i < parts.length - 1; i++) { - String part = parts[i]; - output(part); - } - leftOver = parts[parts.length - 1]; - } - - private int emptyPartCount = 0; - - /** - * when limit == 0 trailing empty parts are not emitted. - * - * @param part - */ - private void output(String part) { - if (part.isEmpty()) { - emptyPartCount++; - } - else { - for (; emptyPartCount > 0; emptyPartCount--) - if (!o.isUnsubscribed()) - o.onNext(""); - if (!o.isUnsubscribed()) - o.onNext(part); - } - } - }; - } - }); - } - - /** - * Concatenates the sequence of values by adding a separator - * between them and emitting the result once the source completes. - *

- * - *

- * The conversion from the value type to String is performed via - * {@link java.lang.String#valueOf(java.lang.Object)} calls. - *

- * For example: - * - *

-     * Observable<Object> source = Observable.from("a", 1, "c");
-     * Observable<String> result = join(source, ", ");
-     * 
- * - * will yield a single element equal to "a, 1, c". - * - * @param source - * the source sequence of CharSequence values - * @param separator - * the separator to a - * @return an Observable which emits a single String value having the concatenated - * values of the source observable with the separator between elements - */ - public static Observable join(final Observable source, final CharSequence separator) { - return source.lift(new Operator() { - @Override - public Subscriber call(final Subscriber o) { - return new Subscriber(o) { - boolean mayAddSeparator; - StringBuilder b = new StringBuilder(); - - @Override - public void onCompleted() { - String str = b.toString(); - b = null; - if (!o.isUnsubscribed()) - o.onNext(str); - if (!o.isUnsubscribed()) - o.onCompleted(); - } - - @Override - public void onError(Throwable e) { - b = null; - if (!o.isUnsubscribed()) - o.onError(e); - } - - @Override - public void onNext(String t) { - if (mayAddSeparator) { - b.append(separator); - } - mayAddSeparator = true; - b.append(t); - } - }; - } - }); - } - - public final static class Line { - private final int number; - private final String text; - - public Line(int number, String text) { - this.number = number; - this.text = text; - } - - public int getNumber() { - return number; - } - - public String getText() { - return text; - } - - @Override - public int hashCode() { - int result = 31 + number; - result = 31 * result + (text == null ? 0 : text.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Line)) - return false; - Line other = (Line) obj; - if (number != other.number) - return false; - if (other.text == text) - return true; - if (text == null) - return false; - return text.equals(other.text); - } - - @Override - public String toString() { - return number + ":" + text; - } - } - - /** - * Splits the {@link Observable} of Strings by lines and numbers them (zero based index) - *

- * - * - * @param source - * @return the Observable conaining the split lines of the source - */ - public static Observable byLine(Observable source) { - return split(source, System.getProperty("line.separator")).map(new Func1() { - int lineNumber = 0; - - @Override - public Line call(String text) { - return new Line(lineNumber++, text); - } - }); - } -} diff --git a/rxjava-contrib/rxjava-string/src/test/java/rx/observables/StringObservableTest.java b/rxjava-contrib/rxjava-string/src/test/java/rx/observables/StringObservableTest.java deleted file mode 100644 index 17f4d9ea44..0000000000 --- a/rxjava-contrib/rxjava-string/src/test/java/rx/observables/StringObservableTest.java +++ /dev/null @@ -1,383 +0,0 @@ -/** - * Copyright 2014 Netflix, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package rx.observables; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static rx.observables.StringObservable.byLine; -import static rx.observables.StringObservable.decode; -import static rx.observables.StringObservable.encode; -import static rx.observables.StringObservable.from; -import static rx.observables.StringObservable.join; -import static rx.observables.StringObservable.split; -import static rx.observables.StringObservable.using; - -import org.junit.Test; - -import rx.Observable; -import rx.Observer; -import rx.functions.Func1; -import rx.observables.StringObservable.Line; -import rx.observables.StringObservable.UnsafeFunc0; -import rx.observers.TestObserver; -import rx.observers.TestSubscriber; -import rx.util.AssertObservable; - -import java.io.ByteArrayInputStream; -import java.io.FilterReader; -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.nio.charset.Charset; -import java.nio.charset.CharsetDecoder; -import java.nio.charset.MalformedInputException; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; - -public class StringObservableTest { - - @Test - public void testMultibyteSpanningTwoBuffers() { - Observable src = Observable.just(new byte[] { (byte) 0xc2 }, new byte[] { (byte) 0xa1 }); - String out = StringObservable.decode(src, "UTF-8").toBlocking().single(); - - assertEquals("\u00A1", out); - } - - @Test - public void testMalformedAtTheEndReplace() { - Observable src = Observable.just(new byte[] { (byte) 0xc2 }); - String out = decode(src, "UTF-8").toBlocking().single(); - - // REPLACEMENT CHARACTER - assertEquals("\uFFFD", out); - } - - @Test - public void testMalformedInTheMiddleReplace() { - Observable src = Observable.just(new byte[] { (byte) 0xc2, 65 }); - String out = decode(src, "UTF-8").toBlocking().single(); - - // REPLACEMENT CHARACTER - assertEquals("\uFFFDA", out); - } - - @Test(expected = RuntimeException.class) - public void testMalformedAtTheEndReport() { - Observable src = Observable.just(new byte[] { (byte) 0xc2 }); - CharsetDecoder charsetDecoder = Charset.forName("UTF-8").newDecoder(); - decode(src, charsetDecoder).toBlocking().single(); - } - - @Test(expected = RuntimeException.class) - public void testMalformedInTheMiddleReport() { - Observable src = Observable.just(new byte[] { (byte) 0xc2, 65 }); - CharsetDecoder charsetDecoder = Charset.forName("UTF-8").newDecoder(); - decode(src, charsetDecoder).toBlocking().single(); - } - - @Test - public void testPropogateError() { - Observable src = Observable.just(new byte[] { 65 }); - Observable err = Observable.error(new IOException()); - CharsetDecoder charsetDecoder = Charset.forName("UTF-8").newDecoder(); - try { - decode(Observable.concat(src, err), charsetDecoder).toList().toBlocking().single(); - fail(); - } catch (RuntimeException e) { - assertEquals(IOException.class, e.getCause().getClass()); - } - } - - @Test - public void testPropogateErrorInTheMiddleOfMultibyte() { - Observable src = Observable.just(new byte[] { (byte) 0xc2 }); - Observable err = Observable.error(new IOException()); - CharsetDecoder charsetDecoder = Charset.forName("UTF-8").newDecoder(); - try { - decode(Observable.concat(src, err), charsetDecoder).toList().toBlocking().single(); - fail(); - } catch (RuntimeException e) { - assertEquals(MalformedInputException.class, e.getCause().getClass()); - } - } - - @Test - public void testEncode() { - assertArrayEquals( - new byte[] { (byte) 0xc2, (byte) 0xa1 }, encode(Observable.just("\u00A1"), "UTF-8") - .toBlocking().single()); - } - - @Test - public void testSplitOnCollon() { - testSplit("boo:and:foo", ":", 0, "boo", "and", "foo"); - } - - @Test - public void testSplitOnOh() { - testSplit("boo:and:foo", "o", 0, "b", "", ":and:f"); - } - - public void testSplit(String str, String regex, int limit, String... parts) { - testSplit(str, regex, 0, Observable.just(str), parts); - for (int i = 0; i < str.length(); i++) { - String a = str.substring(0, i); - String b = str.substring(i, str.length()); - testSplit(a + "|" + b, regex, limit, Observable.just(a, b), parts); - } - } - - public void testSplit(String message, String regex, int limit, Observable src, String... parts) { - Observable act = split(src, regex); - Observable exp = Observable.from(parts); - AssertObservable.assertObservableEqualsBlocking("when input is " + message + " and limit = " + limit, exp, act); - } - - @Test - public void testJoinMixed() { - Observable source = Observable.from(Arrays.asList("a", "1", "c")); - - Observable result = join(source, ", "); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - - result.subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onNext("a, 1, c"); - verify(observer, times(1)).onCompleted(); - verify(observer, never()).onError(any(Throwable.class)); - } - - @Test - public void testJoinWithEmptyString() { - Observable source = Observable.just("", "b", "c"); - - Observable result = join(source, ", "); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - - result.subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onNext(", b, c"); - verify(observer, times(1)).onCompleted(); - verify(observer, never()).onError(any(Throwable.class)); - } - - @Test - public void testJoinWithNull() { - Observable source = Observable.just("a", null, "c"); - - Observable result = join(source, ", "); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - - result.subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onNext("a, null, c"); - verify(observer, times(1)).onCompleted(); - verify(observer, never()).onError(any(Throwable.class)); - } - - @Test - public void testJoinSingle() { - Observable source = Observable.just("a"); - - Observable result = join(source, ", "); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - - result.subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onNext("a"); - verify(observer, times(1)).onCompleted(); - verify(observer, never()).onError(any(Throwable.class)); - } - - @Test - public void testJoinEmpty() { - Observable source = Observable.empty(); - - Observable result = join(source, ", "); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - - result.subscribe(new TestObserver(observer)); - - verify(observer, times(1)).onNext(""); - verify(observer, times(1)).onCompleted(); - verify(observer, never()).onError(any(Throwable.class)); - } - - @Test - public void testJoinThrows() { - Observable source = Observable.concat(Observable.just("a"), Observable - . error(new RuntimeException("Forced failure"))); - - Observable result = join(source, ", "); - - @SuppressWarnings("unchecked") - Observer observer = mock(Observer.class); - - result.subscribe(new TestObserver(observer)); - - verify(observer, never()).onNext("a"); - verify(observer, never()).onCompleted(); - verify(observer, times(1)).onError(any(Throwable.class)); - } - - @Test - public void testFromInputStream() { - final byte[] inBytes = "test".getBytes(); - final byte[] outBytes = from(new ByteArrayInputStream(inBytes)).toBlocking().single(); - assertNotSame(inBytes, outBytes); - assertArrayEquals(inBytes, outBytes); - } - - @Test - public void testFromInputStreamWillUnsubscribeBeforeCallingNextRead() { - final byte[] inBytes = "test".getBytes(); - final AtomicInteger numReads = new AtomicInteger(0); - ByteArrayInputStream is = new ByteArrayInputStream(inBytes) { - - @Override - public synchronized int read(byte[] b, int off, int len) { - numReads.incrementAndGet(); - return super.read(b, off, len); - } - }; - StringObservable.from(is).first().toBlocking().single(); - assertEquals(1, numReads.get()); - } - - @Test - public void testFromReader() { - final String inStr = "test"; - final String outStr = from(new StringReader(inStr)).toBlocking().single(); - assertNotSame(inStr, outStr); - assertEquals(inStr, outStr); - } - - @Test - public void testByLine() { - String newLine = System.getProperty("line.separator"); - - List lines = byLine(Observable.from(Arrays.asList("qwer", newLine + "asdf" + newLine, "zx", "cv"))) - .toList().toBlocking().single(); - - assertEquals(Arrays.asList(new Line(0, "qwer"), new Line(1, "asdf"), new Line(2, "zxcv")), lines); - } - - @Test - public void testUsingCloseOnComplete() throws IOException { - final TestSubscriber subscriber = new TestSubscriber(); - final Reader reader = spy(new StringReader("hello")); - - using(new UnsafeFunc0() { - @Override - public Reader call() throws Exception { - return reader; - } - }, new Func1>() { - @Override - public Observable call(Reader reader) { - return from(reader, 2); - } - }).subscribe(subscriber); - - assertArrayEquals(new String[]{"he","ll","o"}, subscriber.getOnNextEvents().toArray()); - assertEquals(1, subscriber.getOnCompletedEvents().size()); - assertEquals(0, subscriber.getOnErrorEvents().size()); - - verify(reader, times(1)).close(); - } - - @Test - public void testUsingCloseOnError() throws IOException { - final TestSubscriber subscriber = new TestSubscriber(); - final AtomicBoolean closed = new AtomicBoolean(); - final Reader reader = new FilterReader(new StringReader("hello")) { - @Override - public int read(char[] cbuf) throws IOException { - throw new IOException("boo"); - } - - @Override - public void close() throws IOException { - closed.set(true); - } - }; - - using(new UnsafeFunc0() { - @Override - public Reader call() throws Exception { - return reader; - } - }, new Func1>() { - @Override - public Observable call(Reader reader) { - return from(reader, 2); - } - }).subscribe(subscriber); - - assertEquals(0, subscriber.getOnNextEvents().size()); - assertEquals(0, subscriber.getOnCompletedEvents().size()); - assertEquals(1, subscriber.getOnErrorEvents().size()); - - assertTrue(closed.get()); - } - - @Test - public void testUsingCloseOnUnsubscribe() throws IOException { - final TestSubscriber subscriber = new TestSubscriber(); - final Reader reader = spy(new StringReader("hello")); - - using(new UnsafeFunc0() { - @Override - public Reader call() throws Exception { - return reader; - } - }, new Func1>() { - @Override - public Observable call(Reader reader) { - return from(reader, 2); - } - }).take(1).subscribe(subscriber); - - assertArrayEquals(new String[]{"he"}, subscriber.getOnNextEvents().toArray()); - assertEquals(1, subscriber.getOnNextEvents().size()); - assertEquals(1, subscriber.getOnCompletedEvents().size()); - assertEquals(0, subscriber.getOnErrorEvents().size()); - - verify(reader, times(1)).close(); - } -} diff --git a/rxjava/README.md b/rxjava/README.md deleted file mode 100644 index ef3d4659dd..0000000000 --- a/rxjava/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Common Classes - -- [rx.Observable](https://github.com/ReactiveX/RxJava/blob/1.x/rxjava/src/main/java/rx/Observable.java) -- [rx.Observer](https://github.com/ReactiveX/RxJava/blob/1.x/rxjava/src/main/java/rx/Observer.java) -- [rx.Subscription](https://github.com/ReactiveX/RxJava/blob/1.x/rxjava/src/main/java/rx/Subscription.java) -- [rx.Scheduler](https://github.com/ReactiveX/RxJava/blob/1.x/rxjava/src/main/java/rx/Scheduler.java) - diff --git a/rxjava/build.gradle b/rxjava/build.gradle deleted file mode 100644 index 900207f10e..0000000000 --- a/rxjava/build.gradle +++ /dev/null @@ -1,33 +0,0 @@ -apply plugin: 'maven' -apply plugin: 'osgi' - -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - -dependencies { - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' -} - -javadoc { - // we do not want the org.rx.operations package include - exclude '**/operations/**' - - options { - doclet = "org.benjchristensen.doclet.DocletExclude" - docletpath = [rootProject.file('./gradle/doclet-exclude.jar')] - stylesheetFile = rootProject.file('./gradle/javadocStyleSheet.css') - windowTitle = "RxJava Javadoc ${project.version}" - } - options.addStringOption('top').value = '

RxJava

' -} - -jar { - manifest { - name = 'rxjava' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/ReactiveX/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' - instruction 'Eclipse-ExtensibleAPI', 'true' - } -} \ No newline at end of file diff --git a/rxjava/src/main/java/rx/Notification.java b/src/main/java/rx/Notification.java similarity index 100% rename from rxjava/src/main/java/rx/Notification.java rename to src/main/java/rx/Notification.java diff --git a/rxjava/src/main/java/rx/Observable.java b/src/main/java/rx/Observable.java similarity index 100% rename from rxjava/src/main/java/rx/Observable.java rename to src/main/java/rx/Observable.java diff --git a/rxjava/src/main/java/rx/Observer.java b/src/main/java/rx/Observer.java similarity index 100% rename from rxjava/src/main/java/rx/Observer.java rename to src/main/java/rx/Observer.java diff --git a/rxjava/src/main/java/rx/Producer.java b/src/main/java/rx/Producer.java similarity index 100% rename from rxjava/src/main/java/rx/Producer.java rename to src/main/java/rx/Producer.java diff --git a/rxjava/src/main/java/rx/Scheduler.java b/src/main/java/rx/Scheduler.java similarity index 100% rename from rxjava/src/main/java/rx/Scheduler.java rename to src/main/java/rx/Scheduler.java diff --git a/rxjava/src/main/java/rx/Subscriber.java b/src/main/java/rx/Subscriber.java similarity index 100% rename from rxjava/src/main/java/rx/Subscriber.java rename to src/main/java/rx/Subscriber.java diff --git a/rxjava/src/main/java/rx/Subscription.java b/src/main/java/rx/Subscription.java similarity index 100% rename from rxjava/src/main/java/rx/Subscription.java rename to src/main/java/rx/Subscription.java diff --git a/rxjava/src/main/java/rx/exceptions/CompositeException.java b/src/main/java/rx/exceptions/CompositeException.java similarity index 100% rename from rxjava/src/main/java/rx/exceptions/CompositeException.java rename to src/main/java/rx/exceptions/CompositeException.java diff --git a/rxjava/src/main/java/rx/exceptions/Exceptions.java b/src/main/java/rx/exceptions/Exceptions.java similarity index 100% rename from rxjava/src/main/java/rx/exceptions/Exceptions.java rename to src/main/java/rx/exceptions/Exceptions.java diff --git a/rxjava/src/main/java/rx/exceptions/MissingBackpressureException.java b/src/main/java/rx/exceptions/MissingBackpressureException.java similarity index 100% rename from rxjava/src/main/java/rx/exceptions/MissingBackpressureException.java rename to src/main/java/rx/exceptions/MissingBackpressureException.java diff --git a/rxjava/src/main/java/rx/exceptions/OnErrorFailedException.java b/src/main/java/rx/exceptions/OnErrorFailedException.java similarity index 100% rename from rxjava/src/main/java/rx/exceptions/OnErrorFailedException.java rename to src/main/java/rx/exceptions/OnErrorFailedException.java diff --git a/rxjava/src/main/java/rx/exceptions/OnErrorNotImplementedException.java b/src/main/java/rx/exceptions/OnErrorNotImplementedException.java similarity index 100% rename from rxjava/src/main/java/rx/exceptions/OnErrorNotImplementedException.java rename to src/main/java/rx/exceptions/OnErrorNotImplementedException.java diff --git a/rxjava/src/main/java/rx/exceptions/OnErrorThrowable.java b/src/main/java/rx/exceptions/OnErrorThrowable.java similarity index 100% rename from rxjava/src/main/java/rx/exceptions/OnErrorThrowable.java rename to src/main/java/rx/exceptions/OnErrorThrowable.java diff --git a/rxjava/src/main/java/rx/functions/Action.java b/src/main/java/rx/functions/Action.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action.java rename to src/main/java/rx/functions/Action.java diff --git a/rxjava/src/main/java/rx/functions/Action0.java b/src/main/java/rx/functions/Action0.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action0.java rename to src/main/java/rx/functions/Action0.java diff --git a/rxjava/src/main/java/rx/functions/Action1.java b/src/main/java/rx/functions/Action1.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action1.java rename to src/main/java/rx/functions/Action1.java diff --git a/rxjava/src/main/java/rx/functions/Action2.java b/src/main/java/rx/functions/Action2.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action2.java rename to src/main/java/rx/functions/Action2.java diff --git a/rxjava/src/main/java/rx/functions/Action3.java b/src/main/java/rx/functions/Action3.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action3.java rename to src/main/java/rx/functions/Action3.java diff --git a/rxjava/src/main/java/rx/functions/Action4.java b/src/main/java/rx/functions/Action4.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action4.java rename to src/main/java/rx/functions/Action4.java diff --git a/rxjava/src/main/java/rx/functions/Action5.java b/src/main/java/rx/functions/Action5.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action5.java rename to src/main/java/rx/functions/Action5.java diff --git a/rxjava/src/main/java/rx/functions/Action6.java b/src/main/java/rx/functions/Action6.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action6.java rename to src/main/java/rx/functions/Action6.java diff --git a/rxjava/src/main/java/rx/functions/Action7.java b/src/main/java/rx/functions/Action7.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action7.java rename to src/main/java/rx/functions/Action7.java diff --git a/rxjava/src/main/java/rx/functions/Action8.java b/src/main/java/rx/functions/Action8.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action8.java rename to src/main/java/rx/functions/Action8.java diff --git a/rxjava/src/main/java/rx/functions/Action9.java b/src/main/java/rx/functions/Action9.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Action9.java rename to src/main/java/rx/functions/Action9.java diff --git a/rxjava/src/main/java/rx/functions/ActionN.java b/src/main/java/rx/functions/ActionN.java similarity index 100% rename from rxjava/src/main/java/rx/functions/ActionN.java rename to src/main/java/rx/functions/ActionN.java diff --git a/rxjava/src/main/java/rx/functions/Actions.java b/src/main/java/rx/functions/Actions.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Actions.java rename to src/main/java/rx/functions/Actions.java diff --git a/rxjava/src/main/java/rx/functions/Func0.java b/src/main/java/rx/functions/Func0.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Func0.java rename to src/main/java/rx/functions/Func0.java diff --git a/rxjava/src/main/java/rx/functions/Func1.java b/src/main/java/rx/functions/Func1.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Func1.java rename to src/main/java/rx/functions/Func1.java diff --git a/rxjava/src/main/java/rx/functions/Func2.java b/src/main/java/rx/functions/Func2.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Func2.java rename to src/main/java/rx/functions/Func2.java diff --git a/rxjava/src/main/java/rx/functions/Func3.java b/src/main/java/rx/functions/Func3.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Func3.java rename to src/main/java/rx/functions/Func3.java diff --git a/rxjava/src/main/java/rx/functions/Func4.java b/src/main/java/rx/functions/Func4.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Func4.java rename to src/main/java/rx/functions/Func4.java diff --git a/rxjava/src/main/java/rx/functions/Func5.java b/src/main/java/rx/functions/Func5.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Func5.java rename to src/main/java/rx/functions/Func5.java diff --git a/rxjava/src/main/java/rx/functions/Func6.java b/src/main/java/rx/functions/Func6.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Func6.java rename to src/main/java/rx/functions/Func6.java diff --git a/rxjava/src/main/java/rx/functions/Func7.java b/src/main/java/rx/functions/Func7.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Func7.java rename to src/main/java/rx/functions/Func7.java diff --git a/rxjava/src/main/java/rx/functions/Func8.java b/src/main/java/rx/functions/Func8.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Func8.java rename to src/main/java/rx/functions/Func8.java diff --git a/rxjava/src/main/java/rx/functions/Func9.java b/src/main/java/rx/functions/Func9.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Func9.java rename to src/main/java/rx/functions/Func9.java diff --git a/rxjava/src/main/java/rx/functions/FuncN.java b/src/main/java/rx/functions/FuncN.java similarity index 100% rename from rxjava/src/main/java/rx/functions/FuncN.java rename to src/main/java/rx/functions/FuncN.java diff --git a/rxjava/src/main/java/rx/functions/Function.java b/src/main/java/rx/functions/Function.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Function.java rename to src/main/java/rx/functions/Function.java diff --git a/rxjava/src/main/java/rx/functions/Functions.java b/src/main/java/rx/functions/Functions.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Functions.java rename to src/main/java/rx/functions/Functions.java diff --git a/rxjava/src/main/java/rx/functions/Not.java b/src/main/java/rx/functions/Not.java similarity index 100% rename from rxjava/src/main/java/rx/functions/Not.java rename to src/main/java/rx/functions/Not.java diff --git a/rxjava/src/main/java/rx/internal/operators/BlockingOperatorLatest.java b/src/main/java/rx/internal/operators/BlockingOperatorLatest.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/BlockingOperatorLatest.java rename to src/main/java/rx/internal/operators/BlockingOperatorLatest.java diff --git a/rxjava/src/main/java/rx/internal/operators/BlockingOperatorMostRecent.java b/src/main/java/rx/internal/operators/BlockingOperatorMostRecent.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/BlockingOperatorMostRecent.java rename to src/main/java/rx/internal/operators/BlockingOperatorMostRecent.java diff --git a/rxjava/src/main/java/rx/internal/operators/BlockingOperatorNext.java b/src/main/java/rx/internal/operators/BlockingOperatorNext.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/BlockingOperatorNext.java rename to src/main/java/rx/internal/operators/BlockingOperatorNext.java diff --git a/rxjava/src/main/java/rx/internal/operators/BlockingOperatorToFuture.java b/src/main/java/rx/internal/operators/BlockingOperatorToFuture.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/BlockingOperatorToFuture.java rename to src/main/java/rx/internal/operators/BlockingOperatorToFuture.java diff --git a/rxjava/src/main/java/rx/internal/operators/BlockingOperatorToIterator.java b/src/main/java/rx/internal/operators/BlockingOperatorToIterator.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/BlockingOperatorToIterator.java rename to src/main/java/rx/internal/operators/BlockingOperatorToIterator.java diff --git a/rxjava/src/main/java/rx/internal/operators/BufferUntilSubscriber.java b/src/main/java/rx/internal/operators/BufferUntilSubscriber.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/BufferUntilSubscriber.java rename to src/main/java/rx/internal/operators/BufferUntilSubscriber.java diff --git a/rxjava/src/main/java/rx/internal/operators/NotificationLite.java b/src/main/java/rx/internal/operators/NotificationLite.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/NotificationLite.java rename to src/main/java/rx/internal/operators/NotificationLite.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeAmb.java b/src/main/java/rx/internal/operators/OnSubscribeAmb.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeAmb.java rename to src/main/java/rx/internal/operators/OnSubscribeAmb.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeCache.java b/src/main/java/rx/internal/operators/OnSubscribeCache.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeCache.java rename to src/main/java/rx/internal/operators/OnSubscribeCache.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeCombineLatest.java b/src/main/java/rx/internal/operators/OnSubscribeCombineLatest.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeCombineLatest.java rename to src/main/java/rx/internal/operators/OnSubscribeCombineLatest.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeDefer.java b/src/main/java/rx/internal/operators/OnSubscribeDefer.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeDefer.java rename to src/main/java/rx/internal/operators/OnSubscribeDefer.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeDelay.java b/src/main/java/rx/internal/operators/OnSubscribeDelay.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeDelay.java rename to src/main/java/rx/internal/operators/OnSubscribeDelay.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeDelaySubscription.java b/src/main/java/rx/internal/operators/OnSubscribeDelaySubscription.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeDelaySubscription.java rename to src/main/java/rx/internal/operators/OnSubscribeDelaySubscription.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeDelayWithSelector.java b/src/main/java/rx/internal/operators/OnSubscribeDelayWithSelector.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeDelayWithSelector.java rename to src/main/java/rx/internal/operators/OnSubscribeDelayWithSelector.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeFromIterable.java b/src/main/java/rx/internal/operators/OnSubscribeFromIterable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeFromIterable.java rename to src/main/java/rx/internal/operators/OnSubscribeFromIterable.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeGroupJoin.java b/src/main/java/rx/internal/operators/OnSubscribeGroupJoin.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeGroupJoin.java rename to src/main/java/rx/internal/operators/OnSubscribeGroupJoin.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeJoin.java b/src/main/java/rx/internal/operators/OnSubscribeJoin.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeJoin.java rename to src/main/java/rx/internal/operators/OnSubscribeJoin.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeMulticastSelector.java b/src/main/java/rx/internal/operators/OnSubscribeMulticastSelector.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeMulticastSelector.java rename to src/main/java/rx/internal/operators/OnSubscribeMulticastSelector.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeRange.java b/src/main/java/rx/internal/operators/OnSubscribeRange.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeRange.java rename to src/main/java/rx/internal/operators/OnSubscribeRange.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeRedo.java b/src/main/java/rx/internal/operators/OnSubscribeRedo.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeRedo.java rename to src/main/java/rx/internal/operators/OnSubscribeRedo.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeRefCount.java b/src/main/java/rx/internal/operators/OnSubscribeRefCount.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeRefCount.java rename to src/main/java/rx/internal/operators/OnSubscribeRefCount.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeTimerOnce.java b/src/main/java/rx/internal/operators/OnSubscribeTimerOnce.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeTimerOnce.java rename to src/main/java/rx/internal/operators/OnSubscribeTimerOnce.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeTimerPeriodically.java b/src/main/java/rx/internal/operators/OnSubscribeTimerPeriodically.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeTimerPeriodically.java rename to src/main/java/rx/internal/operators/OnSubscribeTimerPeriodically.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeToObservableFuture.java b/src/main/java/rx/internal/operators/OnSubscribeToObservableFuture.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeToObservableFuture.java rename to src/main/java/rx/internal/operators/OnSubscribeToObservableFuture.java diff --git a/rxjava/src/main/java/rx/internal/operators/OnSubscribeUsing.java b/src/main/java/rx/internal/operators/OnSubscribeUsing.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OnSubscribeUsing.java rename to src/main/java/rx/internal/operators/OnSubscribeUsing.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorAll.java b/src/main/java/rx/internal/operators/OperatorAll.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorAll.java rename to src/main/java/rx/internal/operators/OperatorAll.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorAny.java b/src/main/java/rx/internal/operators/OperatorAny.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorAny.java rename to src/main/java/rx/internal/operators/OperatorAny.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorAsObservable.java b/src/main/java/rx/internal/operators/OperatorAsObservable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorAsObservable.java rename to src/main/java/rx/internal/operators/OperatorAsObservable.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorBufferWithSingleObservable.java b/src/main/java/rx/internal/operators/OperatorBufferWithSingleObservable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorBufferWithSingleObservable.java rename to src/main/java/rx/internal/operators/OperatorBufferWithSingleObservable.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorBufferWithSize.java b/src/main/java/rx/internal/operators/OperatorBufferWithSize.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorBufferWithSize.java rename to src/main/java/rx/internal/operators/OperatorBufferWithSize.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorBufferWithStartEndObservable.java b/src/main/java/rx/internal/operators/OperatorBufferWithStartEndObservable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorBufferWithStartEndObservable.java rename to src/main/java/rx/internal/operators/OperatorBufferWithStartEndObservable.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorBufferWithTime.java b/src/main/java/rx/internal/operators/OperatorBufferWithTime.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorBufferWithTime.java rename to src/main/java/rx/internal/operators/OperatorBufferWithTime.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorCast.java b/src/main/java/rx/internal/operators/OperatorCast.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorCast.java rename to src/main/java/rx/internal/operators/OperatorCast.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorConcat.java b/src/main/java/rx/internal/operators/OperatorConcat.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorConcat.java rename to src/main/java/rx/internal/operators/OperatorConcat.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorDebounceWithSelector.java b/src/main/java/rx/internal/operators/OperatorDebounceWithSelector.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorDebounceWithSelector.java rename to src/main/java/rx/internal/operators/OperatorDebounceWithSelector.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorDebounceWithTime.java b/src/main/java/rx/internal/operators/OperatorDebounceWithTime.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorDebounceWithTime.java rename to src/main/java/rx/internal/operators/OperatorDebounceWithTime.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorDefaultIfEmpty.java b/src/main/java/rx/internal/operators/OperatorDefaultIfEmpty.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorDefaultIfEmpty.java rename to src/main/java/rx/internal/operators/OperatorDefaultIfEmpty.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorDematerialize.java b/src/main/java/rx/internal/operators/OperatorDematerialize.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorDematerialize.java rename to src/main/java/rx/internal/operators/OperatorDematerialize.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorDistinct.java b/src/main/java/rx/internal/operators/OperatorDistinct.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorDistinct.java rename to src/main/java/rx/internal/operators/OperatorDistinct.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorDistinctUntilChanged.java b/src/main/java/rx/internal/operators/OperatorDistinctUntilChanged.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorDistinctUntilChanged.java rename to src/main/java/rx/internal/operators/OperatorDistinctUntilChanged.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorDoOnEach.java b/src/main/java/rx/internal/operators/OperatorDoOnEach.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorDoOnEach.java rename to src/main/java/rx/internal/operators/OperatorDoOnEach.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorDoOnSubscribe.java b/src/main/java/rx/internal/operators/OperatorDoOnSubscribe.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorDoOnSubscribe.java rename to src/main/java/rx/internal/operators/OperatorDoOnSubscribe.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorDoOnUnsubscribe.java b/src/main/java/rx/internal/operators/OperatorDoOnUnsubscribe.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorDoOnUnsubscribe.java rename to src/main/java/rx/internal/operators/OperatorDoOnUnsubscribe.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorElementAt.java b/src/main/java/rx/internal/operators/OperatorElementAt.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorElementAt.java rename to src/main/java/rx/internal/operators/OperatorElementAt.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorFilter.java b/src/main/java/rx/internal/operators/OperatorFilter.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorFilter.java rename to src/main/java/rx/internal/operators/OperatorFilter.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorFinally.java b/src/main/java/rx/internal/operators/OperatorFinally.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorFinally.java rename to src/main/java/rx/internal/operators/OperatorFinally.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorGroupBy.java b/src/main/java/rx/internal/operators/OperatorGroupBy.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorGroupBy.java rename to src/main/java/rx/internal/operators/OperatorGroupBy.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorGroupByUntil.java b/src/main/java/rx/internal/operators/OperatorGroupByUntil.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorGroupByUntil.java rename to src/main/java/rx/internal/operators/OperatorGroupByUntil.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorMap.java b/src/main/java/rx/internal/operators/OperatorMap.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorMap.java rename to src/main/java/rx/internal/operators/OperatorMap.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorMapNotification.java b/src/main/java/rx/internal/operators/OperatorMapNotification.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorMapNotification.java rename to src/main/java/rx/internal/operators/OperatorMapNotification.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorMapPair.java b/src/main/java/rx/internal/operators/OperatorMapPair.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorMapPair.java rename to src/main/java/rx/internal/operators/OperatorMapPair.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorMaterialize.java b/src/main/java/rx/internal/operators/OperatorMaterialize.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorMaterialize.java rename to src/main/java/rx/internal/operators/OperatorMaterialize.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorMerge.java b/src/main/java/rx/internal/operators/OperatorMerge.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorMerge.java rename to src/main/java/rx/internal/operators/OperatorMerge.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorMergeDelayError.java b/src/main/java/rx/internal/operators/OperatorMergeDelayError.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorMergeDelayError.java rename to src/main/java/rx/internal/operators/OperatorMergeDelayError.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorMergeMaxConcurrent.java b/src/main/java/rx/internal/operators/OperatorMergeMaxConcurrent.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorMergeMaxConcurrent.java rename to src/main/java/rx/internal/operators/OperatorMergeMaxConcurrent.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorMulticast.java b/src/main/java/rx/internal/operators/OperatorMulticast.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorMulticast.java rename to src/main/java/rx/internal/operators/OperatorMulticast.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorObserveOn.java b/src/main/java/rx/internal/operators/OperatorObserveOn.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorObserveOn.java rename to src/main/java/rx/internal/operators/OperatorObserveOn.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorOnBackpressureBuffer.java b/src/main/java/rx/internal/operators/OperatorOnBackpressureBuffer.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorOnBackpressureBuffer.java rename to src/main/java/rx/internal/operators/OperatorOnBackpressureBuffer.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorOnBackpressureDrop.java b/src/main/java/rx/internal/operators/OperatorOnBackpressureDrop.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorOnBackpressureDrop.java rename to src/main/java/rx/internal/operators/OperatorOnBackpressureDrop.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorOnErrorFlatMap.java b/src/main/java/rx/internal/operators/OperatorOnErrorFlatMap.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorOnErrorFlatMap.java rename to src/main/java/rx/internal/operators/OperatorOnErrorFlatMap.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunction.java b/src/main/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunction.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunction.java rename to src/main/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunction.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservable.java b/src/main/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservable.java rename to src/main/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservable.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorOnErrorReturn.java b/src/main/java/rx/internal/operators/OperatorOnErrorReturn.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorOnErrorReturn.java rename to src/main/java/rx/internal/operators/OperatorOnErrorReturn.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservable.java b/src/main/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservable.java rename to src/main/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservable.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorParallel.java b/src/main/java/rx/internal/operators/OperatorParallel.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorParallel.java rename to src/main/java/rx/internal/operators/OperatorParallel.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorParallelMerge.java b/src/main/java/rx/internal/operators/OperatorParallelMerge.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorParallelMerge.java rename to src/main/java/rx/internal/operators/OperatorParallelMerge.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorReplay.java b/src/main/java/rx/internal/operators/OperatorReplay.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorReplay.java rename to src/main/java/rx/internal/operators/OperatorReplay.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorRetryWithPredicate.java b/src/main/java/rx/internal/operators/OperatorRetryWithPredicate.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorRetryWithPredicate.java rename to src/main/java/rx/internal/operators/OperatorRetryWithPredicate.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSampleWithObservable.java b/src/main/java/rx/internal/operators/OperatorSampleWithObservable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSampleWithObservable.java rename to src/main/java/rx/internal/operators/OperatorSampleWithObservable.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSampleWithTime.java b/src/main/java/rx/internal/operators/OperatorSampleWithTime.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSampleWithTime.java rename to src/main/java/rx/internal/operators/OperatorSampleWithTime.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorScan.java b/src/main/java/rx/internal/operators/OperatorScan.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorScan.java rename to src/main/java/rx/internal/operators/OperatorScan.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSequenceEqual.java b/src/main/java/rx/internal/operators/OperatorSequenceEqual.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSequenceEqual.java rename to src/main/java/rx/internal/operators/OperatorSequenceEqual.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSerialize.java b/src/main/java/rx/internal/operators/OperatorSerialize.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSerialize.java rename to src/main/java/rx/internal/operators/OperatorSerialize.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSingle.java b/src/main/java/rx/internal/operators/OperatorSingle.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSingle.java rename to src/main/java/rx/internal/operators/OperatorSingle.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSkip.java b/src/main/java/rx/internal/operators/OperatorSkip.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSkip.java rename to src/main/java/rx/internal/operators/OperatorSkip.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSkipLast.java b/src/main/java/rx/internal/operators/OperatorSkipLast.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSkipLast.java rename to src/main/java/rx/internal/operators/OperatorSkipLast.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSkipLastTimed.java b/src/main/java/rx/internal/operators/OperatorSkipLastTimed.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSkipLastTimed.java rename to src/main/java/rx/internal/operators/OperatorSkipLastTimed.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSkipTimed.java b/src/main/java/rx/internal/operators/OperatorSkipTimed.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSkipTimed.java rename to src/main/java/rx/internal/operators/OperatorSkipTimed.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSkipUntil.java b/src/main/java/rx/internal/operators/OperatorSkipUntil.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSkipUntil.java rename to src/main/java/rx/internal/operators/OperatorSkipUntil.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSkipWhile.java b/src/main/java/rx/internal/operators/OperatorSkipWhile.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSkipWhile.java rename to src/main/java/rx/internal/operators/OperatorSkipWhile.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSubscribeOn.java b/src/main/java/rx/internal/operators/OperatorSubscribeOn.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSubscribeOn.java rename to src/main/java/rx/internal/operators/OperatorSubscribeOn.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorSwitch.java b/src/main/java/rx/internal/operators/OperatorSwitch.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorSwitch.java rename to src/main/java/rx/internal/operators/OperatorSwitch.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTake.java b/src/main/java/rx/internal/operators/OperatorTake.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTake.java rename to src/main/java/rx/internal/operators/OperatorTake.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTakeLast.java b/src/main/java/rx/internal/operators/OperatorTakeLast.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTakeLast.java rename to src/main/java/rx/internal/operators/OperatorTakeLast.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTakeLastTimed.java b/src/main/java/rx/internal/operators/OperatorTakeLastTimed.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTakeLastTimed.java rename to src/main/java/rx/internal/operators/OperatorTakeLastTimed.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTakeTimed.java b/src/main/java/rx/internal/operators/OperatorTakeTimed.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTakeTimed.java rename to src/main/java/rx/internal/operators/OperatorTakeTimed.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTakeUntil.java b/src/main/java/rx/internal/operators/OperatorTakeUntil.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTakeUntil.java rename to src/main/java/rx/internal/operators/OperatorTakeUntil.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTakeWhile.java b/src/main/java/rx/internal/operators/OperatorTakeWhile.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTakeWhile.java rename to src/main/java/rx/internal/operators/OperatorTakeWhile.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorThrottleFirst.java b/src/main/java/rx/internal/operators/OperatorThrottleFirst.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorThrottleFirst.java rename to src/main/java/rx/internal/operators/OperatorThrottleFirst.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTimeInterval.java b/src/main/java/rx/internal/operators/OperatorTimeInterval.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTimeInterval.java rename to src/main/java/rx/internal/operators/OperatorTimeInterval.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTimeout.java b/src/main/java/rx/internal/operators/OperatorTimeout.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTimeout.java rename to src/main/java/rx/internal/operators/OperatorTimeout.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTimeoutBase.java b/src/main/java/rx/internal/operators/OperatorTimeoutBase.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTimeoutBase.java rename to src/main/java/rx/internal/operators/OperatorTimeoutBase.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTimeoutWithSelector.java b/src/main/java/rx/internal/operators/OperatorTimeoutWithSelector.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTimeoutWithSelector.java rename to src/main/java/rx/internal/operators/OperatorTimeoutWithSelector.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorTimestamp.java b/src/main/java/rx/internal/operators/OperatorTimestamp.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorTimestamp.java rename to src/main/java/rx/internal/operators/OperatorTimestamp.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorToMap.java b/src/main/java/rx/internal/operators/OperatorToMap.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorToMap.java rename to src/main/java/rx/internal/operators/OperatorToMap.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorToMultimap.java b/src/main/java/rx/internal/operators/OperatorToMultimap.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorToMultimap.java rename to src/main/java/rx/internal/operators/OperatorToMultimap.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorToObservableList.java b/src/main/java/rx/internal/operators/OperatorToObservableList.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorToObservableList.java rename to src/main/java/rx/internal/operators/OperatorToObservableList.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorToObservableSortedList.java b/src/main/java/rx/internal/operators/OperatorToObservableSortedList.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorToObservableSortedList.java rename to src/main/java/rx/internal/operators/OperatorToObservableSortedList.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorUnsubscribeOn.java b/src/main/java/rx/internal/operators/OperatorUnsubscribeOn.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorUnsubscribeOn.java rename to src/main/java/rx/internal/operators/OperatorUnsubscribeOn.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorWindowWithObservable.java b/src/main/java/rx/internal/operators/OperatorWindowWithObservable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorWindowWithObservable.java rename to src/main/java/rx/internal/operators/OperatorWindowWithObservable.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorWindowWithSize.java b/src/main/java/rx/internal/operators/OperatorWindowWithSize.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorWindowWithSize.java rename to src/main/java/rx/internal/operators/OperatorWindowWithSize.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorWindowWithStartEndObservable.java b/src/main/java/rx/internal/operators/OperatorWindowWithStartEndObservable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorWindowWithStartEndObservable.java rename to src/main/java/rx/internal/operators/OperatorWindowWithStartEndObservable.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorWindowWithTime.java b/src/main/java/rx/internal/operators/OperatorWindowWithTime.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorWindowWithTime.java rename to src/main/java/rx/internal/operators/OperatorWindowWithTime.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorZip.java b/src/main/java/rx/internal/operators/OperatorZip.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorZip.java rename to src/main/java/rx/internal/operators/OperatorZip.java diff --git a/rxjava/src/main/java/rx/internal/operators/OperatorZipIterable.java b/src/main/java/rx/internal/operators/OperatorZipIterable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/OperatorZipIterable.java rename to src/main/java/rx/internal/operators/OperatorZipIterable.java diff --git a/rxjava/src/main/java/rx/internal/operators/README.md b/src/main/java/rx/internal/operators/README.md similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/README.md rename to src/main/java/rx/internal/operators/README.md diff --git a/rxjava/src/main/java/rx/internal/operators/TakeLastQueueProducer.java b/src/main/java/rx/internal/operators/TakeLastQueueProducer.java similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/TakeLastQueueProducer.java rename to src/main/java/rx/internal/operators/TakeLastQueueProducer.java diff --git a/rxjava/src/main/java/rx/internal/operators/package.html b/src/main/java/rx/internal/operators/package.html similarity index 100% rename from rxjava/src/main/java/rx/internal/operators/package.html rename to src/main/java/rx/internal/operators/package.html diff --git a/rxjava/src/main/java/rx/internal/schedulers/NewThreadWorker.java b/src/main/java/rx/internal/schedulers/NewThreadWorker.java similarity index 100% rename from rxjava/src/main/java/rx/internal/schedulers/NewThreadWorker.java rename to src/main/java/rx/internal/schedulers/NewThreadWorker.java diff --git a/rxjava/src/main/java/rx/internal/schedulers/ScheduledAction.java b/src/main/java/rx/internal/schedulers/ScheduledAction.java similarity index 100% rename from rxjava/src/main/java/rx/internal/schedulers/ScheduledAction.java rename to src/main/java/rx/internal/schedulers/ScheduledAction.java diff --git a/rxjava/src/main/java/rx/internal/util/FrontPadding.java b/src/main/java/rx/internal/util/FrontPadding.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/FrontPadding.java rename to src/main/java/rx/internal/util/FrontPadding.java diff --git a/rxjava/src/main/java/rx/internal/util/IndexedRingBuffer.java b/src/main/java/rx/internal/util/IndexedRingBuffer.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/IndexedRingBuffer.java rename to src/main/java/rx/internal/util/IndexedRingBuffer.java diff --git a/rxjava/src/main/java/rx/internal/util/MpscPaddedQueue.java b/src/main/java/rx/internal/util/MpscPaddedQueue.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/MpscPaddedQueue.java rename to src/main/java/rx/internal/util/MpscPaddedQueue.java diff --git a/rxjava/src/main/java/rx/internal/util/ObjectPool.java b/src/main/java/rx/internal/util/ObjectPool.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/ObjectPool.java rename to src/main/java/rx/internal/util/ObjectPool.java diff --git a/rxjava/src/main/java/rx/internal/util/PaddedAtomicInteger.java b/src/main/java/rx/internal/util/PaddedAtomicInteger.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/PaddedAtomicInteger.java rename to src/main/java/rx/internal/util/PaddedAtomicInteger.java diff --git a/rxjava/src/main/java/rx/internal/util/PaddedAtomicIntegerBase.java b/src/main/java/rx/internal/util/PaddedAtomicIntegerBase.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/PaddedAtomicIntegerBase.java rename to src/main/java/rx/internal/util/PaddedAtomicIntegerBase.java diff --git a/rxjava/src/main/java/rx/internal/util/README.md b/src/main/java/rx/internal/util/README.md similarity index 100% rename from rxjava/src/main/java/rx/internal/util/README.md rename to src/main/java/rx/internal/util/README.md diff --git a/rxjava/src/main/java/rx/internal/util/RxRingBuffer.java b/src/main/java/rx/internal/util/RxRingBuffer.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/RxRingBuffer.java rename to src/main/java/rx/internal/util/RxRingBuffer.java diff --git a/rxjava/src/main/java/rx/internal/util/RxThreadFactory.java b/src/main/java/rx/internal/util/RxThreadFactory.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/RxThreadFactory.java rename to src/main/java/rx/internal/util/RxThreadFactory.java diff --git a/rxjava/src/main/java/rx/internal/util/ScalarSynchronousObservable.java b/src/main/java/rx/internal/util/ScalarSynchronousObservable.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/ScalarSynchronousObservable.java rename to src/main/java/rx/internal/util/ScalarSynchronousObservable.java diff --git a/rxjava/src/main/java/rx/internal/util/SubscriptionIndexedRingBuffer.java b/src/main/java/rx/internal/util/SubscriptionIndexedRingBuffer.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/SubscriptionIndexedRingBuffer.java rename to src/main/java/rx/internal/util/SubscriptionIndexedRingBuffer.java diff --git a/rxjava/src/main/java/rx/internal/util/SubscriptionList.java b/src/main/java/rx/internal/util/SubscriptionList.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/SubscriptionList.java rename to src/main/java/rx/internal/util/SubscriptionList.java diff --git a/rxjava/src/main/java/rx/internal/util/SubscriptionRandomList.java b/src/main/java/rx/internal/util/SubscriptionRandomList.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/SubscriptionRandomList.java rename to src/main/java/rx/internal/util/SubscriptionRandomList.java diff --git a/rxjava/src/main/java/rx/internal/util/SynchronizedQueue.java b/src/main/java/rx/internal/util/SynchronizedQueue.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/SynchronizedQueue.java rename to src/main/java/rx/internal/util/SynchronizedQueue.java diff --git a/rxjava/src/main/java/rx/internal/util/SynchronizedSubscription.java b/src/main/java/rx/internal/util/SynchronizedSubscription.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/SynchronizedSubscription.java rename to src/main/java/rx/internal/util/SynchronizedSubscription.java diff --git a/rxjava/src/main/java/rx/internal/util/unsafe/ConcurrentCircularArrayQueue.java b/src/main/java/rx/internal/util/unsafe/ConcurrentCircularArrayQueue.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/unsafe/ConcurrentCircularArrayQueue.java rename to src/main/java/rx/internal/util/unsafe/ConcurrentCircularArrayQueue.java diff --git a/rxjava/src/main/java/rx/internal/util/unsafe/ConcurrentSequencedCircularArrayQueue.java b/src/main/java/rx/internal/util/unsafe/ConcurrentSequencedCircularArrayQueue.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/unsafe/ConcurrentSequencedCircularArrayQueue.java rename to src/main/java/rx/internal/util/unsafe/ConcurrentSequencedCircularArrayQueue.java diff --git a/rxjava/src/main/java/rx/internal/util/unsafe/MessagePassingQueue.java b/src/main/java/rx/internal/util/unsafe/MessagePassingQueue.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/unsafe/MessagePassingQueue.java rename to src/main/java/rx/internal/util/unsafe/MessagePassingQueue.java diff --git a/rxjava/src/main/java/rx/internal/util/unsafe/MpmcArrayQueue.java b/src/main/java/rx/internal/util/unsafe/MpmcArrayQueue.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/unsafe/MpmcArrayQueue.java rename to src/main/java/rx/internal/util/unsafe/MpmcArrayQueue.java diff --git a/rxjava/src/main/java/rx/internal/util/unsafe/Pow2.java b/src/main/java/rx/internal/util/unsafe/Pow2.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/unsafe/Pow2.java rename to src/main/java/rx/internal/util/unsafe/Pow2.java diff --git a/rxjava/src/main/java/rx/internal/util/unsafe/README.md b/src/main/java/rx/internal/util/unsafe/README.md similarity index 100% rename from rxjava/src/main/java/rx/internal/util/unsafe/README.md rename to src/main/java/rx/internal/util/unsafe/README.md diff --git a/rxjava/src/main/java/rx/internal/util/unsafe/SpmcArrayQueue.java b/src/main/java/rx/internal/util/unsafe/SpmcArrayQueue.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/unsafe/SpmcArrayQueue.java rename to src/main/java/rx/internal/util/unsafe/SpmcArrayQueue.java diff --git a/rxjava/src/main/java/rx/internal/util/unsafe/SpscArrayQueue.java b/src/main/java/rx/internal/util/unsafe/SpscArrayQueue.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/unsafe/SpscArrayQueue.java rename to src/main/java/rx/internal/util/unsafe/SpscArrayQueue.java diff --git a/rxjava/src/main/java/rx/internal/util/unsafe/UnsafeAccess.java b/src/main/java/rx/internal/util/unsafe/UnsafeAccess.java similarity index 100% rename from rxjava/src/main/java/rx/internal/util/unsafe/UnsafeAccess.java rename to src/main/java/rx/internal/util/unsafe/UnsafeAccess.java diff --git a/rxjava/src/main/java/rx/observables/BlockingObservable.java b/src/main/java/rx/observables/BlockingObservable.java similarity index 100% rename from rxjava/src/main/java/rx/observables/BlockingObservable.java rename to src/main/java/rx/observables/BlockingObservable.java diff --git a/rxjava/src/main/java/rx/observables/ConnectableObservable.java b/src/main/java/rx/observables/ConnectableObservable.java similarity index 100% rename from rxjava/src/main/java/rx/observables/ConnectableObservable.java rename to src/main/java/rx/observables/ConnectableObservable.java diff --git a/rxjava/src/main/java/rx/observables/GroupedObservable.java b/src/main/java/rx/observables/GroupedObservable.java similarity index 100% rename from rxjava/src/main/java/rx/observables/GroupedObservable.java rename to src/main/java/rx/observables/GroupedObservable.java diff --git a/rxjava/src/main/java/rx/observers/EmptyObserver.java b/src/main/java/rx/observers/EmptyObserver.java similarity index 100% rename from rxjava/src/main/java/rx/observers/EmptyObserver.java rename to src/main/java/rx/observers/EmptyObserver.java diff --git a/rxjava/src/main/java/rx/observers/Observers.java b/src/main/java/rx/observers/Observers.java similarity index 100% rename from rxjava/src/main/java/rx/observers/Observers.java rename to src/main/java/rx/observers/Observers.java diff --git a/rxjava/src/main/java/rx/observers/SafeSubscriber.java b/src/main/java/rx/observers/SafeSubscriber.java similarity index 100% rename from rxjava/src/main/java/rx/observers/SafeSubscriber.java rename to src/main/java/rx/observers/SafeSubscriber.java diff --git a/rxjava/src/main/java/rx/observers/SerializedObserver.java b/src/main/java/rx/observers/SerializedObserver.java similarity index 100% rename from rxjava/src/main/java/rx/observers/SerializedObserver.java rename to src/main/java/rx/observers/SerializedObserver.java diff --git a/rxjava/src/main/java/rx/observers/SerializedSubscriber.java b/src/main/java/rx/observers/SerializedSubscriber.java similarity index 100% rename from rxjava/src/main/java/rx/observers/SerializedSubscriber.java rename to src/main/java/rx/observers/SerializedSubscriber.java diff --git a/rxjava/src/main/java/rx/observers/Subscribers.java b/src/main/java/rx/observers/Subscribers.java similarity index 100% rename from rxjava/src/main/java/rx/observers/Subscribers.java rename to src/main/java/rx/observers/Subscribers.java diff --git a/rxjava/src/main/java/rx/observers/TestObserver.java b/src/main/java/rx/observers/TestObserver.java similarity index 100% rename from rxjava/src/main/java/rx/observers/TestObserver.java rename to src/main/java/rx/observers/TestObserver.java diff --git a/rxjava/src/main/java/rx/observers/TestSubscriber.java b/src/main/java/rx/observers/TestSubscriber.java similarity index 100% rename from rxjava/src/main/java/rx/observers/TestSubscriber.java rename to src/main/java/rx/observers/TestSubscriber.java diff --git a/rxjava/src/main/java/rx/package-info.java b/src/main/java/rx/package-info.java similarity index 100% rename from rxjava/src/main/java/rx/package-info.java rename to src/main/java/rx/package-info.java diff --git a/rxjava/src/main/java/rx/plugins/RxJavaErrorHandler.java b/src/main/java/rx/plugins/RxJavaErrorHandler.java similarity index 100% rename from rxjava/src/main/java/rx/plugins/RxJavaErrorHandler.java rename to src/main/java/rx/plugins/RxJavaErrorHandler.java diff --git a/rxjava/src/main/java/rx/plugins/RxJavaErrorHandlerDefault.java b/src/main/java/rx/plugins/RxJavaErrorHandlerDefault.java similarity index 100% rename from rxjava/src/main/java/rx/plugins/RxJavaErrorHandlerDefault.java rename to src/main/java/rx/plugins/RxJavaErrorHandlerDefault.java diff --git a/rxjava/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java b/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java similarity index 100% rename from rxjava/src/main/java/rx/plugins/RxJavaObservableExecutionHook.java rename to src/main/java/rx/plugins/RxJavaObservableExecutionHook.java diff --git a/rxjava/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java b/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java similarity index 100% rename from rxjava/src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java rename to src/main/java/rx/plugins/RxJavaObservableExecutionHookDefault.java diff --git a/rxjava/src/main/java/rx/plugins/RxJavaPlugins.java b/src/main/java/rx/plugins/RxJavaPlugins.java similarity index 100% rename from rxjava/src/main/java/rx/plugins/RxJavaPlugins.java rename to src/main/java/rx/plugins/RxJavaPlugins.java diff --git a/rxjava/src/main/java/rx/plugins/RxJavaSchedulersHook.java b/src/main/java/rx/plugins/RxJavaSchedulersHook.java similarity index 100% rename from rxjava/src/main/java/rx/plugins/RxJavaSchedulersHook.java rename to src/main/java/rx/plugins/RxJavaSchedulersHook.java diff --git a/rxjava/src/main/java/rx/schedulers/CachedThreadScheduler.java b/src/main/java/rx/schedulers/CachedThreadScheduler.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/CachedThreadScheduler.java rename to src/main/java/rx/schedulers/CachedThreadScheduler.java diff --git a/rxjava/src/main/java/rx/schedulers/EventLoopsScheduler.java b/src/main/java/rx/schedulers/EventLoopsScheduler.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/EventLoopsScheduler.java rename to src/main/java/rx/schedulers/EventLoopsScheduler.java diff --git a/rxjava/src/main/java/rx/schedulers/ExecutorScheduler.java b/src/main/java/rx/schedulers/ExecutorScheduler.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/ExecutorScheduler.java rename to src/main/java/rx/schedulers/ExecutorScheduler.java diff --git a/rxjava/src/main/java/rx/schedulers/GenericScheduledExecutorService.java b/src/main/java/rx/schedulers/GenericScheduledExecutorService.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/GenericScheduledExecutorService.java rename to src/main/java/rx/schedulers/GenericScheduledExecutorService.java diff --git a/rxjava/src/main/java/rx/schedulers/ImmediateScheduler.java b/src/main/java/rx/schedulers/ImmediateScheduler.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/ImmediateScheduler.java rename to src/main/java/rx/schedulers/ImmediateScheduler.java diff --git a/rxjava/src/main/java/rx/schedulers/NewThreadScheduler.java b/src/main/java/rx/schedulers/NewThreadScheduler.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/NewThreadScheduler.java rename to src/main/java/rx/schedulers/NewThreadScheduler.java diff --git a/rxjava/src/main/java/rx/schedulers/Schedulers.java b/src/main/java/rx/schedulers/Schedulers.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/Schedulers.java rename to src/main/java/rx/schedulers/Schedulers.java diff --git a/rxjava/src/main/java/rx/schedulers/SleepingAction.java b/src/main/java/rx/schedulers/SleepingAction.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/SleepingAction.java rename to src/main/java/rx/schedulers/SleepingAction.java diff --git a/rxjava/src/main/java/rx/schedulers/TestScheduler.java b/src/main/java/rx/schedulers/TestScheduler.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/TestScheduler.java rename to src/main/java/rx/schedulers/TestScheduler.java diff --git a/rxjava/src/main/java/rx/schedulers/TimeInterval.java b/src/main/java/rx/schedulers/TimeInterval.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/TimeInterval.java rename to src/main/java/rx/schedulers/TimeInterval.java diff --git a/rxjava/src/main/java/rx/schedulers/Timestamped.java b/src/main/java/rx/schedulers/Timestamped.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/Timestamped.java rename to src/main/java/rx/schedulers/Timestamped.java diff --git a/rxjava/src/main/java/rx/schedulers/TrampolineScheduler.java b/src/main/java/rx/schedulers/TrampolineScheduler.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/TrampolineScheduler.java rename to src/main/java/rx/schedulers/TrampolineScheduler.java diff --git a/rxjava/src/main/java/rx/schedulers/package-info.java b/src/main/java/rx/schedulers/package-info.java similarity index 100% rename from rxjava/src/main/java/rx/schedulers/package-info.java rename to src/main/java/rx/schedulers/package-info.java diff --git a/rxjava/src/main/java/rx/subjects/AsyncSubject.java b/src/main/java/rx/subjects/AsyncSubject.java similarity index 100% rename from rxjava/src/main/java/rx/subjects/AsyncSubject.java rename to src/main/java/rx/subjects/AsyncSubject.java diff --git a/rxjava/src/main/java/rx/subjects/BehaviorSubject.java b/src/main/java/rx/subjects/BehaviorSubject.java similarity index 100% rename from rxjava/src/main/java/rx/subjects/BehaviorSubject.java rename to src/main/java/rx/subjects/BehaviorSubject.java diff --git a/rxjava/src/main/java/rx/subjects/PublishSubject.java b/src/main/java/rx/subjects/PublishSubject.java similarity index 100% rename from rxjava/src/main/java/rx/subjects/PublishSubject.java rename to src/main/java/rx/subjects/PublishSubject.java diff --git a/rxjava/src/main/java/rx/subjects/ReplaySubject.java b/src/main/java/rx/subjects/ReplaySubject.java similarity index 100% rename from rxjava/src/main/java/rx/subjects/ReplaySubject.java rename to src/main/java/rx/subjects/ReplaySubject.java diff --git a/rxjava/src/main/java/rx/subjects/Subject.java b/src/main/java/rx/subjects/Subject.java similarity index 100% rename from rxjava/src/main/java/rx/subjects/Subject.java rename to src/main/java/rx/subjects/Subject.java diff --git a/rxjava/src/main/java/rx/subjects/SubjectSubscriptionManager.java b/src/main/java/rx/subjects/SubjectSubscriptionManager.java similarity index 100% rename from rxjava/src/main/java/rx/subjects/SubjectSubscriptionManager.java rename to src/main/java/rx/subjects/SubjectSubscriptionManager.java diff --git a/rxjava/src/main/java/rx/subjects/TestSubject.java b/src/main/java/rx/subjects/TestSubject.java similarity index 100% rename from rxjava/src/main/java/rx/subjects/TestSubject.java rename to src/main/java/rx/subjects/TestSubject.java diff --git a/rxjava/src/main/java/rx/subscriptions/BooleanSubscription.java b/src/main/java/rx/subscriptions/BooleanSubscription.java similarity index 100% rename from rxjava/src/main/java/rx/subscriptions/BooleanSubscription.java rename to src/main/java/rx/subscriptions/BooleanSubscription.java diff --git a/rxjava/src/main/java/rx/subscriptions/CompositeSubscription.java b/src/main/java/rx/subscriptions/CompositeSubscription.java similarity index 100% rename from rxjava/src/main/java/rx/subscriptions/CompositeSubscription.java rename to src/main/java/rx/subscriptions/CompositeSubscription.java diff --git a/rxjava/src/main/java/rx/subscriptions/MultipleAssignmentSubscription.java b/src/main/java/rx/subscriptions/MultipleAssignmentSubscription.java similarity index 100% rename from rxjava/src/main/java/rx/subscriptions/MultipleAssignmentSubscription.java rename to src/main/java/rx/subscriptions/MultipleAssignmentSubscription.java diff --git a/rxjava/src/main/java/rx/subscriptions/RefCountSubscription.java b/src/main/java/rx/subscriptions/RefCountSubscription.java similarity index 100% rename from rxjava/src/main/java/rx/subscriptions/RefCountSubscription.java rename to src/main/java/rx/subscriptions/RefCountSubscription.java diff --git a/rxjava/src/main/java/rx/subscriptions/SerialSubscription.java b/src/main/java/rx/subscriptions/SerialSubscription.java similarity index 100% rename from rxjava/src/main/java/rx/subscriptions/SerialSubscription.java rename to src/main/java/rx/subscriptions/SerialSubscription.java diff --git a/rxjava/src/main/java/rx/subscriptions/Subscriptions.java b/src/main/java/rx/subscriptions/Subscriptions.java similarity index 100% rename from rxjava/src/main/java/rx/subscriptions/Subscriptions.java rename to src/main/java/rx/subscriptions/Subscriptions.java diff --git a/rxjava/src/perf/java/rx/PerfBaseline.java b/src/perf/java/rx/PerfBaseline.java similarity index 100% rename from rxjava/src/perf/java/rx/PerfBaseline.java rename to src/perf/java/rx/PerfBaseline.java diff --git a/rxjava/src/perf/java/rx/internal/IndexedRingBufferPerf.java b/src/perf/java/rx/internal/IndexedRingBufferPerf.java similarity index 100% rename from rxjava/src/perf/java/rx/internal/IndexedRingBufferPerf.java rename to src/perf/java/rx/internal/IndexedRingBufferPerf.java diff --git a/rxjava/src/perf/java/rx/internal/RxRingBufferPerf.java b/src/perf/java/rx/internal/RxRingBufferPerf.java similarity index 100% rename from rxjava/src/perf/java/rx/internal/RxRingBufferPerf.java rename to src/perf/java/rx/internal/RxRingBufferPerf.java diff --git a/rxjava/src/perf/java/rx/jmh/InputWithIncrementingInteger.java b/src/perf/java/rx/jmh/InputWithIncrementingInteger.java similarity index 100% rename from rxjava/src/perf/java/rx/jmh/InputWithIncrementingInteger.java rename to src/perf/java/rx/jmh/InputWithIncrementingInteger.java diff --git a/rxjava/src/perf/java/rx/jmh/LatchedObserver.java b/src/perf/java/rx/jmh/LatchedObserver.java similarity index 100% rename from rxjava/src/perf/java/rx/jmh/LatchedObserver.java rename to src/perf/java/rx/jmh/LatchedObserver.java diff --git a/rxjava/src/perf/java/rx/jmh/README.txt b/src/perf/java/rx/jmh/README.txt similarity index 100% rename from rxjava/src/perf/java/rx/jmh/README.txt rename to src/perf/java/rx/jmh/README.txt diff --git a/rxjava/src/perf/java/rx/observables/BlockingObservablePerf.java b/src/perf/java/rx/observables/BlockingObservablePerf.java similarity index 100% rename from rxjava/src/perf/java/rx/observables/BlockingObservablePerf.java rename to src/perf/java/rx/observables/BlockingObservablePerf.java diff --git a/rxjava/src/perf/java/rx/operators/OperatorFlatMapPerf.java b/src/perf/java/rx/operators/OperatorFlatMapPerf.java similarity index 100% rename from rxjava/src/perf/java/rx/operators/OperatorFlatMapPerf.java rename to src/perf/java/rx/operators/OperatorFlatMapPerf.java diff --git a/rxjava/src/perf/java/rx/operators/OperatorMapPerf.java b/src/perf/java/rx/operators/OperatorMapPerf.java similarity index 100% rename from rxjava/src/perf/java/rx/operators/OperatorMapPerf.java rename to src/perf/java/rx/operators/OperatorMapPerf.java diff --git a/rxjava/src/perf/java/rx/operators/OperatorMergePerf.java b/src/perf/java/rx/operators/OperatorMergePerf.java similarity index 100% rename from rxjava/src/perf/java/rx/operators/OperatorMergePerf.java rename to src/perf/java/rx/operators/OperatorMergePerf.java diff --git a/rxjava/src/perf/java/rx/operators/OperatorObserveOnPerf.java b/src/perf/java/rx/operators/OperatorObserveOnPerf.java similarity index 100% rename from rxjava/src/perf/java/rx/operators/OperatorObserveOnPerf.java rename to src/perf/java/rx/operators/OperatorObserveOnPerf.java diff --git a/rxjava/src/perf/java/rx/operators/OperatorRangePerf.java b/src/perf/java/rx/operators/OperatorRangePerf.java similarity index 100% rename from rxjava/src/perf/java/rx/operators/OperatorRangePerf.java rename to src/perf/java/rx/operators/OperatorRangePerf.java diff --git a/rxjava/src/perf/java/rx/operators/OperatorSerializePerf.java b/src/perf/java/rx/operators/OperatorSerializePerf.java similarity index 100% rename from rxjava/src/perf/java/rx/operators/OperatorSerializePerf.java rename to src/perf/java/rx/operators/OperatorSerializePerf.java diff --git a/rxjava/src/perf/java/rx/schedulers/ComputationSchedulerPerf.java b/src/perf/java/rx/schedulers/ComputationSchedulerPerf.java similarity index 100% rename from rxjava/src/perf/java/rx/schedulers/ComputationSchedulerPerf.java rename to src/perf/java/rx/schedulers/ComputationSchedulerPerf.java diff --git a/rxjava/src/perf/java/rx/schedulers/IOSchedulerPerf.java b/src/perf/java/rx/schedulers/IOSchedulerPerf.java similarity index 100% rename from rxjava/src/perf/java/rx/schedulers/IOSchedulerPerf.java rename to src/perf/java/rx/schedulers/IOSchedulerPerf.java diff --git a/rxjava/src/perf/java/rx/subjects/ReplaySubjectPerf.java b/src/perf/java/rx/subjects/ReplaySubjectPerf.java similarity index 100% rename from rxjava/src/perf/java/rx/subjects/ReplaySubjectPerf.java rename to src/perf/java/rx/subjects/ReplaySubjectPerf.java diff --git a/rxjava/src/test/java/rx/BackpressureTests.java b/src/test/java/rx/BackpressureTests.java similarity index 100% rename from rxjava/src/test/java/rx/BackpressureTests.java rename to src/test/java/rx/BackpressureTests.java diff --git a/rxjava/src/test/java/rx/CombineLatestTests.java b/src/test/java/rx/CombineLatestTests.java similarity index 100% rename from rxjava/src/test/java/rx/CombineLatestTests.java rename to src/test/java/rx/CombineLatestTests.java diff --git a/rxjava/src/test/java/rx/ConcatTests.java b/src/test/java/rx/ConcatTests.java similarity index 100% rename from rxjava/src/test/java/rx/ConcatTests.java rename to src/test/java/rx/ConcatTests.java diff --git a/rxjava/src/test/java/rx/CovarianceTest.java b/src/test/java/rx/CovarianceTest.java similarity index 100% rename from rxjava/src/test/java/rx/CovarianceTest.java rename to src/test/java/rx/CovarianceTest.java diff --git a/rxjava/src/test/java/rx/ErrorHandlingTests.java b/src/test/java/rx/ErrorHandlingTests.java similarity index 100% rename from rxjava/src/test/java/rx/ErrorHandlingTests.java rename to src/test/java/rx/ErrorHandlingTests.java diff --git a/rxjava/src/test/java/rx/EventStream.java b/src/test/java/rx/EventStream.java similarity index 100% rename from rxjava/src/test/java/rx/EventStream.java rename to src/test/java/rx/EventStream.java diff --git a/rxjava/src/test/java/rx/GroupByTests.java b/src/test/java/rx/GroupByTests.java similarity index 100% rename from rxjava/src/test/java/rx/GroupByTests.java rename to src/test/java/rx/GroupByTests.java diff --git a/rxjava/src/test/java/rx/IntervalDemo.java b/src/test/java/rx/IntervalDemo.java similarity index 100% rename from rxjava/src/test/java/rx/IntervalDemo.java rename to src/test/java/rx/IntervalDemo.java diff --git a/rxjava/src/test/java/rx/MergeTests.java b/src/test/java/rx/MergeTests.java similarity index 100% rename from rxjava/src/test/java/rx/MergeTests.java rename to src/test/java/rx/MergeTests.java diff --git a/rxjava/src/test/java/rx/ObservableDoOnTest.java b/src/test/java/rx/ObservableDoOnTest.java similarity index 100% rename from rxjava/src/test/java/rx/ObservableDoOnTest.java rename to src/test/java/rx/ObservableDoOnTest.java diff --git a/rxjava/src/test/java/rx/ObservableTests.java b/src/test/java/rx/ObservableTests.java similarity index 100% rename from rxjava/src/test/java/rx/ObservableTests.java rename to src/test/java/rx/ObservableTests.java diff --git a/rxjava/src/test/java/rx/ObservableWindowTests.java b/src/test/java/rx/ObservableWindowTests.java similarity index 100% rename from rxjava/src/test/java/rx/ObservableWindowTests.java rename to src/test/java/rx/ObservableWindowTests.java diff --git a/rxjava/src/test/java/rx/ReduceTests.java b/src/test/java/rx/ReduceTests.java similarity index 100% rename from rxjava/src/test/java/rx/ReduceTests.java rename to src/test/java/rx/ReduceTests.java diff --git a/rxjava/src/test/java/rx/RefCountTests.java b/src/test/java/rx/RefCountTests.java similarity index 100% rename from rxjava/src/test/java/rx/RefCountTests.java rename to src/test/java/rx/RefCountTests.java diff --git a/rxjava/src/test/java/rx/ScanTests.java b/src/test/java/rx/ScanTests.java similarity index 100% rename from rxjava/src/test/java/rx/ScanTests.java rename to src/test/java/rx/ScanTests.java diff --git a/rxjava/src/test/java/rx/StartWithTests.java b/src/test/java/rx/StartWithTests.java similarity index 100% rename from rxjava/src/test/java/rx/StartWithTests.java rename to src/test/java/rx/StartWithTests.java diff --git a/rxjava/src/test/java/rx/SubscriberTest.java b/src/test/java/rx/SubscriberTest.java similarity index 100% rename from rxjava/src/test/java/rx/SubscriberTest.java rename to src/test/java/rx/SubscriberTest.java diff --git a/rxjava/src/test/java/rx/ThrottleLastTests.java b/src/test/java/rx/ThrottleLastTests.java similarity index 100% rename from rxjava/src/test/java/rx/ThrottleLastTests.java rename to src/test/java/rx/ThrottleLastTests.java diff --git a/rxjava/src/test/java/rx/ThrottleWithTimeoutTests.java b/src/test/java/rx/ThrottleWithTimeoutTests.java similarity index 100% rename from rxjava/src/test/java/rx/ThrottleWithTimeoutTests.java rename to src/test/java/rx/ThrottleWithTimeoutTests.java diff --git a/rxjava/src/test/java/rx/ZipTests.java b/src/test/java/rx/ZipTests.java similarity index 100% rename from rxjava/src/test/java/rx/ZipTests.java rename to src/test/java/rx/ZipTests.java diff --git a/rxjava/src/test/java/rx/exceptions/CompositeExceptionTest.java b/src/test/java/rx/exceptions/CompositeExceptionTest.java similarity index 100% rename from rxjava/src/test/java/rx/exceptions/CompositeExceptionTest.java rename to src/test/java/rx/exceptions/CompositeExceptionTest.java diff --git a/rxjava/src/test/java/rx/exceptions/ExceptionsTest.java b/src/test/java/rx/exceptions/ExceptionsTest.java similarity index 100% rename from rxjava/src/test/java/rx/exceptions/ExceptionsTest.java rename to src/test/java/rx/exceptions/ExceptionsTest.java diff --git a/rxjava/src/test/java/rx/exceptions/OnNextValueTest.java b/src/test/java/rx/exceptions/OnNextValueTest.java similarity index 100% rename from rxjava/src/test/java/rx/exceptions/OnNextValueTest.java rename to src/test/java/rx/exceptions/OnNextValueTest.java diff --git a/rxjava/src/test/java/rx/exceptions/TestException.java b/src/test/java/rx/exceptions/TestException.java similarity index 100% rename from rxjava/src/test/java/rx/exceptions/TestException.java rename to src/test/java/rx/exceptions/TestException.java diff --git a/rxjava/src/test/java/rx/internal/operators/BlockingOperatorLatestTest.java b/src/test/java/rx/internal/operators/BlockingOperatorLatestTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/BlockingOperatorLatestTest.java rename to src/test/java/rx/internal/operators/BlockingOperatorLatestTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/BlockingOperatorMostRecentTest.java b/src/test/java/rx/internal/operators/BlockingOperatorMostRecentTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/BlockingOperatorMostRecentTest.java rename to src/test/java/rx/internal/operators/BlockingOperatorMostRecentTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/BlockingOperatorNextTest.java b/src/test/java/rx/internal/operators/BlockingOperatorNextTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/BlockingOperatorNextTest.java rename to src/test/java/rx/internal/operators/BlockingOperatorNextTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/BlockingOperatorToFutureTest.java b/src/test/java/rx/internal/operators/BlockingOperatorToFutureTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/BlockingOperatorToFutureTest.java rename to src/test/java/rx/internal/operators/BlockingOperatorToFutureTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/BlockingOperatorToIteratorTest.java b/src/test/java/rx/internal/operators/BlockingOperatorToIteratorTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/BlockingOperatorToIteratorTest.java rename to src/test/java/rx/internal/operators/BlockingOperatorToIteratorTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/NotificationLiteTest.java b/src/test/java/rx/internal/operators/NotificationLiteTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/NotificationLiteTest.java rename to src/test/java/rx/internal/operators/NotificationLiteTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeAmbTest.java b/src/test/java/rx/internal/operators/OnSubscribeAmbTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeAmbTest.java rename to src/test/java/rx/internal/operators/OnSubscribeAmbTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java b/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeCacheTest.java rename to src/test/java/rx/internal/operators/OnSubscribeCacheTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java b/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java rename to src/test/java/rx/internal/operators/OnSubscribeCombineLatestTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeDeferTest.java b/src/test/java/rx/internal/operators/OnSubscribeDeferTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeDeferTest.java rename to src/test/java/rx/internal/operators/OnSubscribeDeferTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeDelayTest.java b/src/test/java/rx/internal/operators/OnSubscribeDelayTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeDelayTest.java rename to src/test/java/rx/internal/operators/OnSubscribeDelayTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeFromIterableTest.java b/src/test/java/rx/internal/operators/OnSubscribeFromIterableTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeFromIterableTest.java rename to src/test/java/rx/internal/operators/OnSubscribeFromIterableTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeGroupJoinTest.java b/src/test/java/rx/internal/operators/OnSubscribeGroupJoinTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeGroupJoinTest.java rename to src/test/java/rx/internal/operators/OnSubscribeGroupJoinTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeJoinTest.java b/src/test/java/rx/internal/operators/OnSubscribeJoinTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeJoinTest.java rename to src/test/java/rx/internal/operators/OnSubscribeJoinTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeMulticastTest.java b/src/test/java/rx/internal/operators/OnSubscribeMulticastTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeMulticastTest.java rename to src/test/java/rx/internal/operators/OnSubscribeMulticastTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeRangeTest.java b/src/test/java/rx/internal/operators/OnSubscribeRangeTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeRangeTest.java rename to src/test/java/rx/internal/operators/OnSubscribeRangeTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeTimerTest.java b/src/test/java/rx/internal/operators/OnSubscribeTimerTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeTimerTest.java rename to src/test/java/rx/internal/operators/OnSubscribeTimerTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeToObservableFutureTest.java b/src/test/java/rx/internal/operators/OnSubscribeToObservableFutureTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeToObservableFutureTest.java rename to src/test/java/rx/internal/operators/OnSubscribeToObservableFutureTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OnSubscribeUsingTest.java b/src/test/java/rx/internal/operators/OnSubscribeUsingTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OnSubscribeUsingTest.java rename to src/test/java/rx/internal/operators/OnSubscribeUsingTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorAllTest.java b/src/test/java/rx/internal/operators/OperatorAllTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorAllTest.java rename to src/test/java/rx/internal/operators/OperatorAllTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorAnyTest.java b/src/test/java/rx/internal/operators/OperatorAnyTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorAnyTest.java rename to src/test/java/rx/internal/operators/OperatorAnyTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorAsObservableTest.java b/src/test/java/rx/internal/operators/OperatorAsObservableTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorAsObservableTest.java rename to src/test/java/rx/internal/operators/OperatorAsObservableTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorBufferTest.java b/src/test/java/rx/internal/operators/OperatorBufferTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorBufferTest.java rename to src/test/java/rx/internal/operators/OperatorBufferTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorCastTest.java b/src/test/java/rx/internal/operators/OperatorCastTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorCastTest.java rename to src/test/java/rx/internal/operators/OperatorCastTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorConcatTest.java b/src/test/java/rx/internal/operators/OperatorConcatTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorConcatTest.java rename to src/test/java/rx/internal/operators/OperatorConcatTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorDebounceTest.java b/src/test/java/rx/internal/operators/OperatorDebounceTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorDebounceTest.java rename to src/test/java/rx/internal/operators/OperatorDebounceTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorDefaultIfEmptyTest.java b/src/test/java/rx/internal/operators/OperatorDefaultIfEmptyTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorDefaultIfEmptyTest.java rename to src/test/java/rx/internal/operators/OperatorDefaultIfEmptyTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorDematerializeTest.java b/src/test/java/rx/internal/operators/OperatorDematerializeTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorDematerializeTest.java rename to src/test/java/rx/internal/operators/OperatorDematerializeTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorDistinctTest.java b/src/test/java/rx/internal/operators/OperatorDistinctTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorDistinctTest.java rename to src/test/java/rx/internal/operators/OperatorDistinctTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorDistinctUntilChangedTest.java b/src/test/java/rx/internal/operators/OperatorDistinctUntilChangedTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorDistinctUntilChangedTest.java rename to src/test/java/rx/internal/operators/OperatorDistinctUntilChangedTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorDoOnEachTest.java b/src/test/java/rx/internal/operators/OperatorDoOnEachTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorDoOnEachTest.java rename to src/test/java/rx/internal/operators/OperatorDoOnEachTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorDoOnSubscribeTest.java b/src/test/java/rx/internal/operators/OperatorDoOnSubscribeTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorDoOnSubscribeTest.java rename to src/test/java/rx/internal/operators/OperatorDoOnSubscribeTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorDoOnUnsubscribeTest.java b/src/test/java/rx/internal/operators/OperatorDoOnUnsubscribeTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorDoOnUnsubscribeTest.java rename to src/test/java/rx/internal/operators/OperatorDoOnUnsubscribeTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorElementAtTest.java b/src/test/java/rx/internal/operators/OperatorElementAtTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorElementAtTest.java rename to src/test/java/rx/internal/operators/OperatorElementAtTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorFilterTest.java b/src/test/java/rx/internal/operators/OperatorFilterTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorFilterTest.java rename to src/test/java/rx/internal/operators/OperatorFilterTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorFinallyTest.java b/src/test/java/rx/internal/operators/OperatorFinallyTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorFinallyTest.java rename to src/test/java/rx/internal/operators/OperatorFinallyTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorFirstTest.java b/src/test/java/rx/internal/operators/OperatorFirstTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorFirstTest.java rename to src/test/java/rx/internal/operators/OperatorFirstTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorFlatMapTest.java b/src/test/java/rx/internal/operators/OperatorFlatMapTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorFlatMapTest.java rename to src/test/java/rx/internal/operators/OperatorFlatMapTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorGroupByTest.java b/src/test/java/rx/internal/operators/OperatorGroupByTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorGroupByTest.java rename to src/test/java/rx/internal/operators/OperatorGroupByTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorGroupByUntilTest.java b/src/test/java/rx/internal/operators/OperatorGroupByUntilTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorGroupByUntilTest.java rename to src/test/java/rx/internal/operators/OperatorGroupByUntilTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorLastTest.java b/src/test/java/rx/internal/operators/OperatorLastTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorLastTest.java rename to src/test/java/rx/internal/operators/OperatorLastTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorMapTest.java b/src/test/java/rx/internal/operators/OperatorMapTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorMapTest.java rename to src/test/java/rx/internal/operators/OperatorMapTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorMaterializeTest.java b/src/test/java/rx/internal/operators/OperatorMaterializeTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorMaterializeTest.java rename to src/test/java/rx/internal/operators/OperatorMaterializeTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorMergeDelayErrorTest.java b/src/test/java/rx/internal/operators/OperatorMergeDelayErrorTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorMergeDelayErrorTest.java rename to src/test/java/rx/internal/operators/OperatorMergeDelayErrorTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorMergeMaxConcurrentTest.java b/src/test/java/rx/internal/operators/OperatorMergeMaxConcurrentTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorMergeMaxConcurrentTest.java rename to src/test/java/rx/internal/operators/OperatorMergeMaxConcurrentTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorMergeTest.java b/src/test/java/rx/internal/operators/OperatorMergeTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorMergeTest.java rename to src/test/java/rx/internal/operators/OperatorMergeTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorObserveOnTest.java b/src/test/java/rx/internal/operators/OperatorObserveOnTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorObserveOnTest.java rename to src/test/java/rx/internal/operators/OperatorObserveOnTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorOnBackpressureBufferTest.java b/src/test/java/rx/internal/operators/OperatorOnBackpressureBufferTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorOnBackpressureBufferTest.java rename to src/test/java/rx/internal/operators/OperatorOnBackpressureBufferTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorOnBackpressureDropTest.java b/src/test/java/rx/internal/operators/OperatorOnBackpressureDropTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorOnBackpressureDropTest.java rename to src/test/java/rx/internal/operators/OperatorOnBackpressureDropTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunctionTest.java b/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunctionTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunctionTest.java rename to src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaFunctionTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservableTest.java b/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservableTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservableTest.java rename to src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservableTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorOnErrorReturnTest.java b/src/test/java/rx/internal/operators/OperatorOnErrorReturnTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorOnErrorReturnTest.java rename to src/test/java/rx/internal/operators/OperatorOnErrorReturnTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservableTest.java b/src/test/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservableTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservableTest.java rename to src/test/java/rx/internal/operators/OperatorOnExceptionResumeNextViaObservableTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorParallelMergeTest.java b/src/test/java/rx/internal/operators/OperatorParallelMergeTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorParallelMergeTest.java rename to src/test/java/rx/internal/operators/OperatorParallelMergeTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorParallelTest.java b/src/test/java/rx/internal/operators/OperatorParallelTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorParallelTest.java rename to src/test/java/rx/internal/operators/OperatorParallelTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorReduceTest.java b/src/test/java/rx/internal/operators/OperatorReduceTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorReduceTest.java rename to src/test/java/rx/internal/operators/OperatorReduceTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorRepeatTest.java b/src/test/java/rx/internal/operators/OperatorRepeatTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorRepeatTest.java rename to src/test/java/rx/internal/operators/OperatorRepeatTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorReplayTest.java b/src/test/java/rx/internal/operators/OperatorReplayTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorReplayTest.java rename to src/test/java/rx/internal/operators/OperatorReplayTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorRetryTest.java b/src/test/java/rx/internal/operators/OperatorRetryTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorRetryTest.java rename to src/test/java/rx/internal/operators/OperatorRetryTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorRetryWithPredicateTest.java b/src/test/java/rx/internal/operators/OperatorRetryWithPredicateTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorRetryWithPredicateTest.java rename to src/test/java/rx/internal/operators/OperatorRetryWithPredicateTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSampleTest.java b/src/test/java/rx/internal/operators/OperatorSampleTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSampleTest.java rename to src/test/java/rx/internal/operators/OperatorSampleTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorScanTest.java b/src/test/java/rx/internal/operators/OperatorScanTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorScanTest.java rename to src/test/java/rx/internal/operators/OperatorScanTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSequenceEqualTest.java b/src/test/java/rx/internal/operators/OperatorSequenceEqualTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSequenceEqualTest.java rename to src/test/java/rx/internal/operators/OperatorSequenceEqualTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSerializeTest.java b/src/test/java/rx/internal/operators/OperatorSerializeTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSerializeTest.java rename to src/test/java/rx/internal/operators/OperatorSerializeTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSingleTest.java b/src/test/java/rx/internal/operators/OperatorSingleTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSingleTest.java rename to src/test/java/rx/internal/operators/OperatorSingleTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSkipLastTest.java b/src/test/java/rx/internal/operators/OperatorSkipLastTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSkipLastTest.java rename to src/test/java/rx/internal/operators/OperatorSkipLastTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSkipLastTimedTest.java b/src/test/java/rx/internal/operators/OperatorSkipLastTimedTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSkipLastTimedTest.java rename to src/test/java/rx/internal/operators/OperatorSkipLastTimedTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSkipTest.java b/src/test/java/rx/internal/operators/OperatorSkipTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSkipTest.java rename to src/test/java/rx/internal/operators/OperatorSkipTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSkipTimedTest.java b/src/test/java/rx/internal/operators/OperatorSkipTimedTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSkipTimedTest.java rename to src/test/java/rx/internal/operators/OperatorSkipTimedTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSkipUntilTest.java b/src/test/java/rx/internal/operators/OperatorSkipUntilTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSkipUntilTest.java rename to src/test/java/rx/internal/operators/OperatorSkipUntilTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSkipWhileTest.java b/src/test/java/rx/internal/operators/OperatorSkipWhileTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSkipWhileTest.java rename to src/test/java/rx/internal/operators/OperatorSkipWhileTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSubscribeOnTest.java b/src/test/java/rx/internal/operators/OperatorSubscribeOnTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSubscribeOnTest.java rename to src/test/java/rx/internal/operators/OperatorSubscribeOnTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorSwitchTest.java b/src/test/java/rx/internal/operators/OperatorSwitchTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorSwitchTest.java rename to src/test/java/rx/internal/operators/OperatorSwitchTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorTakeLastTest.java b/src/test/java/rx/internal/operators/OperatorTakeLastTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorTakeLastTest.java rename to src/test/java/rx/internal/operators/OperatorTakeLastTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorTakeLastTimedTest.java b/src/test/java/rx/internal/operators/OperatorTakeLastTimedTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorTakeLastTimedTest.java rename to src/test/java/rx/internal/operators/OperatorTakeLastTimedTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorTakeTest.java b/src/test/java/rx/internal/operators/OperatorTakeTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorTakeTest.java rename to src/test/java/rx/internal/operators/OperatorTakeTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorTakeTimedTest.java b/src/test/java/rx/internal/operators/OperatorTakeTimedTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorTakeTimedTest.java rename to src/test/java/rx/internal/operators/OperatorTakeTimedTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorTakeUntilTest.java b/src/test/java/rx/internal/operators/OperatorTakeUntilTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorTakeUntilTest.java rename to src/test/java/rx/internal/operators/OperatorTakeUntilTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorTakeWhileTest.java b/src/test/java/rx/internal/operators/OperatorTakeWhileTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorTakeWhileTest.java rename to src/test/java/rx/internal/operators/OperatorTakeWhileTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorThrottleFirstTest.java b/src/test/java/rx/internal/operators/OperatorThrottleFirstTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorThrottleFirstTest.java rename to src/test/java/rx/internal/operators/OperatorThrottleFirstTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorTimeIntervalTest.java b/src/test/java/rx/internal/operators/OperatorTimeIntervalTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorTimeIntervalTest.java rename to src/test/java/rx/internal/operators/OperatorTimeIntervalTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorTimeoutTests.java b/src/test/java/rx/internal/operators/OperatorTimeoutTests.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorTimeoutTests.java rename to src/test/java/rx/internal/operators/OperatorTimeoutTests.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorTimeoutWithSelectorTest.java b/src/test/java/rx/internal/operators/OperatorTimeoutWithSelectorTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorTimeoutWithSelectorTest.java rename to src/test/java/rx/internal/operators/OperatorTimeoutWithSelectorTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorTimestampTest.java b/src/test/java/rx/internal/operators/OperatorTimestampTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorTimestampTest.java rename to src/test/java/rx/internal/operators/OperatorTimestampTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorToMapTest.java b/src/test/java/rx/internal/operators/OperatorToMapTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorToMapTest.java rename to src/test/java/rx/internal/operators/OperatorToMapTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorToMultimapTest.java b/src/test/java/rx/internal/operators/OperatorToMultimapTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorToMultimapTest.java rename to src/test/java/rx/internal/operators/OperatorToMultimapTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorToObservableListTest.java b/src/test/java/rx/internal/operators/OperatorToObservableListTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorToObservableListTest.java rename to src/test/java/rx/internal/operators/OperatorToObservableListTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorToObservableSortedListTest.java b/src/test/java/rx/internal/operators/OperatorToObservableSortedListTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorToObservableSortedListTest.java rename to src/test/java/rx/internal/operators/OperatorToObservableSortedListTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorUnsubscribeOnTest.java b/src/test/java/rx/internal/operators/OperatorUnsubscribeOnTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorUnsubscribeOnTest.java rename to src/test/java/rx/internal/operators/OperatorUnsubscribeOnTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorWindowTest.java b/src/test/java/rx/internal/operators/OperatorWindowTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorWindowTest.java rename to src/test/java/rx/internal/operators/OperatorWindowTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorZipCompletionTest.java b/src/test/java/rx/internal/operators/OperatorZipCompletionTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorZipCompletionTest.java rename to src/test/java/rx/internal/operators/OperatorZipCompletionTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorZipIterableTest.java b/src/test/java/rx/internal/operators/OperatorZipIterableTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorZipIterableTest.java rename to src/test/java/rx/internal/operators/OperatorZipIterableTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/OperatorZipTest.java b/src/test/java/rx/internal/operators/OperatorZipTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/OperatorZipTest.java rename to src/test/java/rx/internal/operators/OperatorZipTest.java diff --git a/rxjava/src/test/java/rx/internal/operators/SafeSubscriberTest.java b/src/test/java/rx/internal/operators/SafeSubscriberTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/operators/SafeSubscriberTest.java rename to src/test/java/rx/internal/operators/SafeSubscriberTest.java diff --git a/rxjava/src/test/java/rx/internal/util/IndexedRingBufferTest.java b/src/test/java/rx/internal/util/IndexedRingBufferTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/util/IndexedRingBufferTest.java rename to src/test/java/rx/internal/util/IndexedRingBufferTest.java diff --git a/rxjava/src/test/java/rx/internal/util/RxRingBufferBase.java b/src/test/java/rx/internal/util/RxRingBufferBase.java similarity index 100% rename from rxjava/src/test/java/rx/internal/util/RxRingBufferBase.java rename to src/test/java/rx/internal/util/RxRingBufferBase.java diff --git a/rxjava/src/test/java/rx/internal/util/RxRingBufferSpmcTest.java b/src/test/java/rx/internal/util/RxRingBufferSpmcTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/util/RxRingBufferSpmcTest.java rename to src/test/java/rx/internal/util/RxRingBufferSpmcTest.java diff --git a/rxjava/src/test/java/rx/internal/util/RxRingBufferSpscTest.java b/src/test/java/rx/internal/util/RxRingBufferSpscTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/util/RxRingBufferSpscTest.java rename to src/test/java/rx/internal/util/RxRingBufferSpscTest.java diff --git a/rxjava/src/test/java/rx/internal/util/RxRingBufferWithoutUnsafeTest.java b/src/test/java/rx/internal/util/RxRingBufferWithoutUnsafeTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/util/RxRingBufferWithoutUnsafeTest.java rename to src/test/java/rx/internal/util/RxRingBufferWithoutUnsafeTest.java diff --git a/rxjava/src/test/java/rx/internal/util/SubscriptionListTest.java b/src/test/java/rx/internal/util/SubscriptionListTest.java similarity index 100% rename from rxjava/src/test/java/rx/internal/util/SubscriptionListTest.java rename to src/test/java/rx/internal/util/SubscriptionListTest.java diff --git a/rxjava/src/test/java/rx/observables/BlockingObservableTest.java b/src/test/java/rx/observables/BlockingObservableTest.java similarity index 100% rename from rxjava/src/test/java/rx/observables/BlockingObservableTest.java rename to src/test/java/rx/observables/BlockingObservableTest.java diff --git a/rxjava/src/test/java/rx/observers/SafeObserverTest.java b/src/test/java/rx/observers/SafeObserverTest.java similarity index 100% rename from rxjava/src/test/java/rx/observers/SafeObserverTest.java rename to src/test/java/rx/observers/SafeObserverTest.java diff --git a/rxjava/src/test/java/rx/observers/SerializedObserverTest.java b/src/test/java/rx/observers/SerializedObserverTest.java similarity index 100% rename from rxjava/src/test/java/rx/observers/SerializedObserverTest.java rename to src/test/java/rx/observers/SerializedObserverTest.java diff --git a/rxjava/src/test/java/rx/observers/TestObserverTest.java b/src/test/java/rx/observers/TestObserverTest.java similarity index 100% rename from rxjava/src/test/java/rx/observers/TestObserverTest.java rename to src/test/java/rx/observers/TestObserverTest.java diff --git a/rxjava/src/test/java/rx/observers/TestSubscriberTest.java b/src/test/java/rx/observers/TestSubscriberTest.java similarity index 100% rename from rxjava/src/test/java/rx/observers/TestSubscriberTest.java rename to src/test/java/rx/observers/TestSubscriberTest.java diff --git a/rxjava/src/test/java/rx/plugins/RxJavaPluginsTest.java b/src/test/java/rx/plugins/RxJavaPluginsTest.java similarity index 100% rename from rxjava/src/test/java/rx/plugins/RxJavaPluginsTest.java rename to src/test/java/rx/plugins/RxJavaPluginsTest.java diff --git a/rxjava/src/test/java/rx/schedulers/AbstractSchedulerConcurrencyTests.java b/src/test/java/rx/schedulers/AbstractSchedulerConcurrencyTests.java similarity index 100% rename from rxjava/src/test/java/rx/schedulers/AbstractSchedulerConcurrencyTests.java rename to src/test/java/rx/schedulers/AbstractSchedulerConcurrencyTests.java diff --git a/rxjava/src/test/java/rx/schedulers/AbstractSchedulerTests.java b/src/test/java/rx/schedulers/AbstractSchedulerTests.java similarity index 100% rename from rxjava/src/test/java/rx/schedulers/AbstractSchedulerTests.java rename to src/test/java/rx/schedulers/AbstractSchedulerTests.java diff --git a/rxjava/src/test/java/rx/schedulers/CachedThreadSchedulerTest.java b/src/test/java/rx/schedulers/CachedThreadSchedulerTest.java similarity index 100% rename from rxjava/src/test/java/rx/schedulers/CachedThreadSchedulerTest.java rename to src/test/java/rx/schedulers/CachedThreadSchedulerTest.java diff --git a/rxjava/src/test/java/rx/schedulers/ComputationSchedulerTests.java b/src/test/java/rx/schedulers/ComputationSchedulerTests.java similarity index 100% rename from rxjava/src/test/java/rx/schedulers/ComputationSchedulerTests.java rename to src/test/java/rx/schedulers/ComputationSchedulerTests.java diff --git a/rxjava/src/test/java/rx/schedulers/ExecutorSchedulerTest.java b/src/test/java/rx/schedulers/ExecutorSchedulerTest.java similarity index 100% rename from rxjava/src/test/java/rx/schedulers/ExecutorSchedulerTest.java rename to src/test/java/rx/schedulers/ExecutorSchedulerTest.java diff --git a/rxjava/src/test/java/rx/schedulers/ImmediateSchedulerTest.java b/src/test/java/rx/schedulers/ImmediateSchedulerTest.java similarity index 100% rename from rxjava/src/test/java/rx/schedulers/ImmediateSchedulerTest.java rename to src/test/java/rx/schedulers/ImmediateSchedulerTest.java diff --git a/rxjava/src/test/java/rx/schedulers/NewThreadSchedulerTest.java b/src/test/java/rx/schedulers/NewThreadSchedulerTest.java similarity index 100% rename from rxjava/src/test/java/rx/schedulers/NewThreadSchedulerTest.java rename to src/test/java/rx/schedulers/NewThreadSchedulerTest.java diff --git a/rxjava/src/test/java/rx/schedulers/TestSchedulerTest.java b/src/test/java/rx/schedulers/TestSchedulerTest.java similarity index 100% rename from rxjava/src/test/java/rx/schedulers/TestSchedulerTest.java rename to src/test/java/rx/schedulers/TestSchedulerTest.java diff --git a/rxjava/src/test/java/rx/schedulers/TrampolineSchedulerTest.java b/src/test/java/rx/schedulers/TrampolineSchedulerTest.java similarity index 100% rename from rxjava/src/test/java/rx/schedulers/TrampolineSchedulerTest.java rename to src/test/java/rx/schedulers/TrampolineSchedulerTest.java diff --git a/rxjava/src/test/java/rx/subjects/AsyncSubjectTest.java b/src/test/java/rx/subjects/AsyncSubjectTest.java similarity index 100% rename from rxjava/src/test/java/rx/subjects/AsyncSubjectTest.java rename to src/test/java/rx/subjects/AsyncSubjectTest.java diff --git a/rxjava/src/test/java/rx/subjects/BehaviorSubjectTest.java b/src/test/java/rx/subjects/BehaviorSubjectTest.java similarity index 100% rename from rxjava/src/test/java/rx/subjects/BehaviorSubjectTest.java rename to src/test/java/rx/subjects/BehaviorSubjectTest.java diff --git a/rxjava/src/test/java/rx/subjects/PublishSubjectTest.java b/src/test/java/rx/subjects/PublishSubjectTest.java similarity index 100% rename from rxjava/src/test/java/rx/subjects/PublishSubjectTest.java rename to src/test/java/rx/subjects/PublishSubjectTest.java diff --git a/rxjava/src/test/java/rx/subjects/ReplaySubjectBoundedConcurrencyTest.java b/src/test/java/rx/subjects/ReplaySubjectBoundedConcurrencyTest.java similarity index 100% rename from rxjava/src/test/java/rx/subjects/ReplaySubjectBoundedConcurrencyTest.java rename to src/test/java/rx/subjects/ReplaySubjectBoundedConcurrencyTest.java diff --git a/rxjava/src/test/java/rx/subjects/ReplaySubjectConcurrencyTest.java b/src/test/java/rx/subjects/ReplaySubjectConcurrencyTest.java similarity index 100% rename from rxjava/src/test/java/rx/subjects/ReplaySubjectConcurrencyTest.java rename to src/test/java/rx/subjects/ReplaySubjectConcurrencyTest.java diff --git a/rxjava/src/test/java/rx/subjects/ReplaySubjectTest.java b/src/test/java/rx/subjects/ReplaySubjectTest.java similarity index 100% rename from rxjava/src/test/java/rx/subjects/ReplaySubjectTest.java rename to src/test/java/rx/subjects/ReplaySubjectTest.java diff --git a/rxjava/src/test/java/rx/subscriptions/CompositeSubscriptionTest.java b/src/test/java/rx/subscriptions/CompositeSubscriptionTest.java similarity index 100% rename from rxjava/src/test/java/rx/subscriptions/CompositeSubscriptionTest.java rename to src/test/java/rx/subscriptions/CompositeSubscriptionTest.java diff --git a/rxjava/src/test/java/rx/subscriptions/MultipleAssignmentSubscriptionTest.java b/src/test/java/rx/subscriptions/MultipleAssignmentSubscriptionTest.java similarity index 100% rename from rxjava/src/test/java/rx/subscriptions/MultipleAssignmentSubscriptionTest.java rename to src/test/java/rx/subscriptions/MultipleAssignmentSubscriptionTest.java diff --git a/rxjava/src/test/java/rx/subscriptions/RefCountSubscriptionTest.java b/src/test/java/rx/subscriptions/RefCountSubscriptionTest.java similarity index 100% rename from rxjava/src/test/java/rx/subscriptions/RefCountSubscriptionTest.java rename to src/test/java/rx/subscriptions/RefCountSubscriptionTest.java diff --git a/rxjava/src/test/java/rx/subscriptions/SerialSubscriptionTests.java b/src/test/java/rx/subscriptions/SerialSubscriptionTests.java similarity index 100% rename from rxjava/src/test/java/rx/subscriptions/SerialSubscriptionTests.java rename to src/test/java/rx/subscriptions/SerialSubscriptionTests.java diff --git a/rxjava/src/test/java/rx/subscriptions/SubscriptionsTest.java b/src/test/java/rx/subscriptions/SubscriptionsTest.java similarity index 100% rename from rxjava/src/test/java/rx/subscriptions/SubscriptionsTest.java rename to src/test/java/rx/subscriptions/SubscriptionsTest.java diff --git a/rxjava/src/test/java/rx/test/OperatorTester.java b/src/test/java/rx/test/OperatorTester.java similarity index 100% rename from rxjava/src/test/java/rx/test/OperatorTester.java rename to src/test/java/rx/test/OperatorTester.java diff --git a/rxjava/src/test/java/rx/util/AssertObservable.java b/src/test/java/rx/util/AssertObservable.java similarity index 100% rename from rxjava/src/test/java/rx/util/AssertObservable.java rename to src/test/java/rx/util/AssertObservable.java diff --git a/rxjava/src/test/java/rx/util/AssertObservableTest.java b/src/test/java/rx/util/AssertObservableTest.java similarity index 100% rename from rxjava/src/test/java/rx/util/AssertObservableTest.java rename to src/test/java/rx/util/AssertObservableTest.java