diff --git a/language-adaptors/rxjava-clojure/src/main/java/org/rx/lang/clojure/ClojureAdaptor.java b/language-adaptors/rxjava-clojure/src/main/java/rx/lang/clojure/ClojureAdaptor.java similarity index 96% rename from language-adaptors/rxjava-clojure/src/main/java/org/rx/lang/clojure/ClojureAdaptor.java rename to language-adaptors/rxjava-clojure/src/main/java/rx/lang/clojure/ClojureAdaptor.java index 70c9084dc3..55bd8ff443 100644 --- a/language-adaptors/rxjava-clojure/src/main/java/org/rx/lang/clojure/ClojureAdaptor.java +++ b/language-adaptors/rxjava-clojure/src/main/java/rx/lang/clojure/ClojureAdaptor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.lang.clojure; +package rx.lang.clojure; import java.util.Arrays; @@ -21,8 +21,9 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.rx.functions.FunctionLanguageAdaptor; -import org.rx.reactive.Observer; + +import rx.observables.Observer; +import rx.util.FunctionLanguageAdaptor; import clojure.lang.IFn; import clojure.lang.RT; @@ -99,7 +100,7 @@ public void before() { @Test public void testTake() { - runClojureScript("(-> (org.rx.reactive.Observable/toObservable [\"one\" \"two\" \"three\"]) (.take 2) (.subscribe (fn [arg] (println arg))))"); + runClojureScript("(-> (rx.observables.Observable/toObservable [\"one\" \"two\" \"three\"]) (.take 2) (.subscribe (fn [arg] (println arg))))"); } // commented out for now as I can't figure out how to set the var 'a' with the 'assertion' instance when running the code from java diff --git a/language-adaptors/rxjava-groovy/src/main/java/org/rx/lang/groovy/GroovyAdaptor.java b/language-adaptors/rxjava-groovy/src/main/java/rx/lang/groovy/GroovyAdaptor.java similarity index 97% rename from language-adaptors/rxjava-groovy/src/main/java/org/rx/lang/groovy/GroovyAdaptor.java rename to language-adaptors/rxjava-groovy/src/main/java/rx/lang/groovy/GroovyAdaptor.java index bdff61a06a..10b8fdb769 100644 --- a/language-adaptors/rxjava-groovy/src/main/java/org/rx/lang/groovy/GroovyAdaptor.java +++ b/language-adaptors/rxjava-groovy/src/main/java/rx/lang/groovy/GroovyAdaptor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.lang.groovy; +package rx.lang.groovy; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -28,11 +28,12 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.rx.functions.FunctionLanguageAdaptor; -import org.rx.reactive.Notification; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Notification; +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.FunctionLanguageAdaptor; public class GroovyAdaptor implements FunctionLanguageAdaptor { @@ -208,7 +209,7 @@ private void runGroovyScript(String script) { Binding binding = new Binding(); binding.setVariable("mockApiCall", new TestFactory()); binding.setVariable("a", assertion); - binding.setVariable("o", org.rx.reactive.Observable.class); + binding.setVariable("o", rx.observables.Observable.class); /* parse the script and execute it */ InvokerHelper.createScript(loader.parseClass(script), binding).run(); diff --git a/language-adaptors/rxjava-jruby/src/main/java/org/rx/lang/jruby/JRubyAdaptor.java b/language-adaptors/rxjava-jruby/src/main/java/rx/lang/jruby/JRubyAdaptor.java similarity index 96% rename from language-adaptors/rxjava-jruby/src/main/java/org/rx/lang/jruby/JRubyAdaptor.java rename to language-adaptors/rxjava-jruby/src/main/java/rx/lang/jruby/JRubyAdaptor.java index e101c809fb..9a6f704151 100644 --- a/language-adaptors/rxjava-jruby/src/main/java/org/rx/lang/jruby/JRubyAdaptor.java +++ b/language-adaptors/rxjava-jruby/src/main/java/rx/lang/jruby/JRubyAdaptor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.lang.jruby; +package rx.lang.jruby; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -29,11 +29,12 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.rx.functions.FunctionLanguageAdaptor; -import org.rx.reactive.Notification; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Notification; +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.FunctionLanguageAdaptor; public class JRubyAdaptor implements FunctionLanguageAdaptor { @@ -162,7 +163,7 @@ private void runGroovyScript(String script) { StringBuilder b = new StringBuilder(); // force JRuby to always use subscribe(Object) - b.append("import org.rx.reactive.Observable").append("\n"); + b.append("import \"rx.observables.Observable\"").append("\n"); b.append("class Observable").append("\n"); b.append(" java_alias :subscribe, :subscribe, [java.lang.Object]").append("\n"); b.append("end").append("\n"); diff --git a/rxjava-core/src/main/java/org/rx/reactive/package.html b/rxjava-core/src/main/java/org/rx/reactive/package.html deleted file mode 100644 index f94b00cba8..0000000000 --- a/rxjava-core/src/main/java/org/rx/reactive/package.html +++ /dev/null @@ -1,44 +0,0 @@ - - -

A library that enables subscribing to and composing asynchronous events and - callbacks.

-

The Observable/Observer interfaces and associated operators (in - the .operations package) are inspired by and attempt to conform to the - Reactive Rx library in Microsoft .Net.

-

- More information can be found at http://msdn.microsoft.com/en-us/data/gg577609. -

- - -

Compared with the Microsoft implementation: -

-

-

Services which intend on exposing data asynchronously and wish - to allow reactive processing and composition can implement the - Watchable interface which then allows Watchers to subscribe to them - and receive events.

-

Usage examples can be found on the Watchable and Watcher - classes.

- \ No newline at end of file diff --git a/rxjava-core/src/main/java/rx/concurrency/package-info.java b/rxjava-core/src/main/java/rx/concurrency/package-info.java new file mode 100644 index 0000000000..56e3680f1d --- /dev/null +++ b/rxjava-core/src/main/java/rx/concurrency/package-info.java @@ -0,0 +1,19 @@ +/** + * Copyright 2013 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. + */ +/** + * Rx Schedulers + */ +package rx.concurrency; \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/reactive/CompositeException.java b/rxjava-core/src/main/java/rx/observables/CompositeException.java similarity index 98% rename from rxjava-core/src/main/java/org/rx/reactive/CompositeException.java rename to rxjava-core/src/main/java/rx/observables/CompositeException.java index ab07c7df79..53035a3312 100644 --- a/rxjava-core/src/main/java/org/rx/reactive/CompositeException.java +++ b/rxjava-core/src/main/java/rx/observables/CompositeException.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.reactive; +package rx.observables; import java.util.ArrayList; import java.util.Collection; diff --git a/rxjava-core/src/main/java/org/rx/reactive/Notification.java b/rxjava-core/src/main/java/rx/observables/Notification.java similarity index 99% rename from rxjava-core/src/main/java/org/rx/reactive/Notification.java rename to rxjava-core/src/main/java/rx/observables/Notification.java index 397fe0ce11..b8ed2056cf 100644 --- a/rxjava-core/src/main/java/org/rx/reactive/Notification.java +++ b/rxjava-core/src/main/java/rx/observables/Notification.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.reactive; +package rx.observables; /** * An object representing a notification sent to a Observable. diff --git a/rxjava-core/src/main/java/org/rx/reactive/Observable.java b/rxjava-core/src/main/java/rx/observables/Observable.java similarity index 94% rename from rxjava-core/src/main/java/org/rx/reactive/Observable.java rename to rxjava-core/src/main/java/rx/observables/Observable.java index 37b8e3a86f..9d41cef5d6 100644 --- a/rxjava-core/src/main/java/org/rx/reactive/Observable.java +++ b/rxjava-core/src/main/java/rx/observables/Observable.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.reactive; +package rx.observables; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -27,29 +27,32 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.rx.functions.Func1; -import org.rx.functions.Func2; -import org.rx.functions.Func3; -import org.rx.functions.Func4; -import org.rx.functions.Functions; -import org.rx.operations.OperationFilter; -import org.rx.operations.OperationLast; -import org.rx.operations.OperationMap; -import org.rx.operations.OperationMaterialize; -import org.rx.operations.OperationMerge; -import org.rx.operations.OperationMergeDelayError; -import org.rx.operations.OperationOnErrorResumeNextViaFunction; -import org.rx.operations.OperationOnErrorResumeNextViaObservable; -import org.rx.operations.OperationOnErrorReturn; -import org.rx.operations.OperationScan; -import org.rx.operations.OperationSkip; -import org.rx.operations.OperationSynchronize; -import org.rx.operations.OperationTake; -import org.rx.operations.OperationToObservableFunction; -import org.rx.operations.OperationToObservableIterable; -import org.rx.operations.OperationToObservableList; -import org.rx.operations.OperationToObservableSortedList; -import org.rx.operations.OperationZip; + +import rx.observables.operations.OperationFilter; +import rx.observables.operations.OperationLast; +import rx.observables.operations.OperationMap; +import rx.observables.operations.OperationMaterialize; +import rx.observables.operations.OperationMerge; +import rx.observables.operations.OperationMergeDelayError; +import rx.observables.operations.OperationOnErrorResumeNextViaFunction; +import rx.observables.operations.OperationOnErrorResumeNextViaObservable; +import rx.observables.operations.OperationOnErrorReturn; +import rx.observables.operations.OperationScan; +import rx.observables.operations.OperationSkip; +import rx.observables.operations.OperationSynchronize; +import rx.observables.operations.OperationTake; +import rx.observables.operations.OperationToObservableFunction; +import rx.observables.operations.OperationToObservableIterable; +import rx.observables.operations.OperationToObservableList; +import rx.observables.operations.OperationToObservableSortedList; +import rx.observables.operations.OperationZip; +import rx.util.Action0; +import rx.util.Action1; +import rx.util.Func1; +import rx.util.Func2; +import rx.util.Func3; +import rx.util.Func4; +import rx.util.Functions; /** * The Observable interface that implements the Reactive Pattern. @@ -132,6 +135,7 @@ public Subscription subscribe(final Object o) { // in case a dynamic language is not correctly handling the overloaded methods and we receive an Observer just forward to the correct method. return subscribe((Observer) o); } + return subscribe(new Observer() { public void onCompleted() { @@ -153,6 +157,29 @@ public void onNext(Object args) { }); } + public Subscription subscribe(final Action1 onNext) { + + return subscribe(new Observer() { + + public void onCompleted() { + // do nothing + } + + public void onError(Exception e) { + handleError(e); + // no callback defined + } + + public void onNext(T args) { + if (onNext == null) { + throw new RuntimeException("onNext must be implemented"); + } + onNext.call(args); + } + + }); + } + @SuppressWarnings({ "rawtypes", "unchecked" }) public Subscription subscribe(final Object onNext, final Object onError) { return subscribe(new Observer() { @@ -178,6 +205,31 @@ public void onNext(Object args) { }); } + public Subscription subscribe(final Action1 onNext, final Action1 onError) { + + return subscribe(new Observer() { + + public void onCompleted() { + // do nothing + } + + public void onError(Exception e) { + handleError(e); + if (onError != null) { + onError.call(e); + } + } + + public void onNext(T args) { + if (onNext == null) { + throw new RuntimeException("onNext must be implemented"); + } + onNext.call(args); + } + + }); + } + @SuppressWarnings({ "rawtypes", "unchecked" }) public Subscription subscribe(final Object onNext, final Object onError, final Object onComplete) { return subscribe(new Observer() { @@ -205,6 +257,31 @@ public void onNext(Object args) { }); } + public Subscription subscribe(final Action1 onNext, final Action1 onError, final Action0 onComplete) { + + return subscribe(new Observer() { + + public void onCompleted() { + onComplete.call(); + } + + public void onError(Exception e) { + handleError(e); + if (onError != null) { + onError.call(e); + } + } + + public void onNext(T args) { + if (onNext == null) { + throw new RuntimeException("onNext must be implemented"); + } + onNext.call(args); + } + + }); + } + /** * When an error occurs in any Observer we will invoke this to allow it to be handled by the global APIObservableErrorHandler * @@ -294,7 +371,7 @@ public Subscription subscribe(Observer observer) { * cancelling the subscription (if applicable) * @return a Observable that, when a Observer subscribes to it, will execute the given function */ - public static Observable create(Func1> func) { + public static Observable create(Func1, Subscription> func) { return OperationToObservableFunction.toObservableFunction(func); } @@ -318,7 +395,7 @@ public static Observable create(Func1> func) { * @return a Observable that, when a Observer subscribes to it, will execute the given function */ public static Observable create(final Object callback) { - return create(new Func1>() { + return create(new Func1, Subscription>() { @Override public Subscription call(Observer t1) { @@ -374,7 +451,7 @@ public static Observable error(Exception exception) { * @return a Observable that emits only those items in the original Observable that the filter * evaluates as true */ - public static Observable filter(Observable that, Func1 predicate) { + public static Observable filter(Observable that, Func1 predicate) { return OperationFilter.filter(that, predicate); } @@ -392,7 +469,7 @@ public static Observable filter(Observable that, Func1 pre * evaluates as true */ public static Observable filter(Observable that, final Object function) { - return filter(that, new Func1() { + return filter(that, new Func1() { @Override public Boolean call(T t1) { @@ -403,6 +480,36 @@ public Boolean call(T t1) { }); } + /** + * Converts an Iterable sequence to a Observable sequence. + * + * @param iterable + * the source Iterable sequence + * @param + * the type of items in the iterable sequence and the type emitted by the resulting + * Observable + * @return a Observable that emits each item in the source Iterable sequence + * @see {@link #toObservable(Iterable)} + */ + public static Observable from(Iterable iterable) { + return toObservable(iterable); + } + + /** + * Converts an Array sequence to a Observable sequence. + * + * @param iterable + * the source Array + * @param + * the type of items in the Array, and the type of items emitted by the resulting + * Observable + * @return a Observable that emits each item in the source Array + * @see {@link #toObservable(Object...)} + */ + public static Observable from(T... items) { + return toObservable(items); + } + /** * Returns a Observable that notifies an observer of a single value and then completes. *

@@ -467,7 +574,7 @@ public static Observable last(final Observable that) { * @return a Observable that is the result of applying the transformation function to each item * in the sequence emitted by the source Observable */ - public static Observable map(Observable sequence, Func1 func) { + public static Observable map(Observable sequence, Func1 func) { return OperationMap.map(sequence, func); } @@ -490,7 +597,7 @@ public static Observable map(Observable sequence, Func1 func) * in the sequence emitted by the source Observable */ public static Observable map(Observable sequence, final Object function) { - return map(sequence, new Func1() { + return map(sequence, new Func1() { @Override public R call(T t1) { @@ -522,7 +629,7 @@ public R call(T t1) { * function to each item emitted by the source Observable and merging the results of * the Observables obtained from this transformation */ - public static Observable mapMany(Observable sequence, Func1, T> func) { + public static Observable mapMany(Observable sequence, Func1> func) { return OperationMap.mapMany(sequence, func); } @@ -549,7 +656,7 @@ public static Observable mapMany(Observable sequence, Func1 Observable mapMany(Observable sequence, final Object function) { - return mapMany(sequence, new Func1() { + return mapMany(sequence, new Func1() { @Override public R call(T t1) { @@ -739,7 +846,7 @@ public static Subscription noOpSubscription() { * encounters an error * @return the source Observable, with its behavior modified as described */ - public static Observable onErrorResumeNext(final Observable that, final Func1, Exception> resumeFunction) { + public static Observable onErrorResumeNext(final Observable that, final Func1> resumeFunction) { return OperationOnErrorResumeNextViaFunction.onErrorResumeNextViaFunction(that, resumeFunction); } @@ -769,7 +876,7 @@ public static Observable onErrorResumeNext(final Observable that, fina * @return the source Observable, with its behavior modified as described */ public static Observable onErrorResumeNext(final Observable that, final Object resumeFunction) { - return onErrorResumeNext(that, new Func1, Exception>() { + return onErrorResumeNext(that, new Func1>() { @Override public Observable call(Exception e) { @@ -829,7 +936,7 @@ public static Observable onErrorResumeNext(final Observable that, fina * otherwise cause it to call onError * @return the source Observable, with its behavior modified as described */ - public static Observable onErrorReturn(final Observable that, Func1 resumeFunction) { + public static Observable onErrorReturn(final Observable that, Func1 resumeFunction) { return OperationOnErrorReturn.onErrorReturn(that, resumeFunction); } @@ -1237,7 +1344,7 @@ public static Observable> toSortedList(Observable sequence) { * @param sortFunction * @return */ - public static Observable> toSortedList(Observable sequence, Func2 sortFunction) { + public static Observable> toSortedList(Observable sequence, Func2 sortFunction) { return OperationToObservableSortedList.toSortedList(sequence, sortFunction); } @@ -1252,7 +1359,7 @@ public static Observable> toSortedList(Observable sequence, Func2 * @return */ public static Observable> toSortedList(Observable sequence, final Object sortFunction) { - return OperationToObservableSortedList.toSortedList(sequence, new Func2() { + return OperationToObservableSortedList.toSortedList(sequence, new Func2() { @Override public Integer call(T t1, T t2) { @@ -1286,7 +1393,7 @@ public Integer call(T t1, T t2) { * results in a value that will be emitted by the resulting Observable * @return a Observable that emits the zipped results */ - public static Observable zip(Observable w0, Observable w1, Func2 reduceFunction) { + public static Observable zip(Observable w0, Observable w1, Func2 reduceFunction) { return OperationZip.zip(w0, w1, reduceFunction); } @@ -1315,7 +1422,7 @@ public static Observable zip(Observable w0, Observable w1 * @return a Observable that emits the zipped results */ public static Observable zip(Observable w0, Observable w1, final Object function) { - return zip(w0, w1, new Func2() { + return zip(w0, w1, new Func2() { @Override public R call(T0 t0, T1 t1) { @@ -1353,7 +1460,7 @@ public R call(T0 t0, T1 t1) { * results in a value that will be emitted by the resulting Observable * @return a Observable that emits the zipped results */ - public static Observable zip(Observable w0, Observable w1, Observable w2, Func3 function) { + public static Observable zip(Observable w0, Observable w1, Observable w2, Func3 function) { return OperationZip.zip(w0, w1, w2, function); } @@ -1386,7 +1493,7 @@ public static Observable zip(Observable w0, Observable Observable zip(Observable w0, Observable w1, Observable w2, final Object function) { - return zip(w0, w1, w2, new Func3() { + return zip(w0, w1, w2, new Func3() { @Override public R call(T0 t0, T1 t1, T2 t2) { @@ -1425,7 +1532,7 @@ public R call(T0 t0, T1 t1, T2 t2) { * results in a value that will be emitted by the resulting Observable * @return a Observable that emits the zipped results */ - public static Observable zip(Observable w0, Observable w1, Observable w2, Observable w3, Func4 reduceFunction) { + public static Observable zip(Observable w0, Observable w1, Observable w2, Observable w3, Func4 reduceFunction) { return OperationZip.zip(w0, w1, w2, w3, reduceFunction); } @@ -1459,7 +1566,7 @@ public static Observable zip(Observable w0, Observabl * @return a Observable that emits the zipped results */ public static Observable zip(Observable w0, Observable w1, Observable w2, Observable w3, final Object function) { - return zip(w0, w1, w2, w3, new Func4() { + return zip(w0, w1, w2, w3, new Func4() { @Override public R call(T0 t0, T1 t1, T2 t2, T3 t3) { @@ -1498,7 +1605,7 @@ public Observable filter(Func1 predicate) { * evaluates as "true" */ public Observable filter(final Object callback) { - return filter(this, new Func1() { + return filter(this, new Func1() { public Boolean call(T t1) { return Functions.execute(callback, t1); @@ -1548,7 +1655,7 @@ public Observable map(Func1 func) { * closure to each item in the sequence emitted by the input Observable. */ public Observable map(final Object callback) { - return map(this, new Func1() { + return map(this, new Func1() { public R call(T t1) { return Functions.execute(callback, t1); @@ -1571,7 +1678,7 @@ public R call(T t1) { * function to each item in the input sequence and merging the results of the * Observables obtained from this transformation. */ - public Observable mapMany(Func1, T> func) { + public Observable mapMany(Func1> func) { return mapMany(this, func); } @@ -1591,7 +1698,7 @@ public Observable mapMany(Func1, T> func) { * Observables obtained from this transformation. */ public Observable mapMany(final Object callback) { - return mapMany(this, new Func1, T>() { + return mapMany(this, new Func1>() { public Observable call(T t1) { return Functions.execute(callback, t1); @@ -1635,7 +1742,7 @@ public Observable> materialize() { * @param resumeFunction * @return the original Observable, with appropriately modified behavior */ - public Observable onErrorResumeNext(final Func1, Exception> resumeFunction) { + public Observable onErrorResumeNext(final Func1> resumeFunction) { return onErrorResumeNext(this, resumeFunction); } @@ -1664,7 +1771,7 @@ public Observable onErrorResumeNext(final Func1, Exception> res * @return the original Observable with appropriately modified behavior */ public Observable onErrorResumeNext(final Object resumeFunction) { - return onErrorResumeNext(this, new Func1, Exception>() { + return onErrorResumeNext(this, new Func1>() { public Observable call(Exception e) { return Functions.execute(resumeFunction, e); @@ -1722,7 +1829,7 @@ public Observable onErrorResumeNext(final Observable resumeSequence) { * @param resumeFunction * @return the original Observable with appropriately modified behavior */ - public Observable onErrorReturn(Func1 resumeFunction) { + public Observable onErrorReturn(Func1 resumeFunction) { return onErrorReturn(this, resumeFunction); } @@ -1750,7 +1857,7 @@ public Observable onErrorReturn(Func1 resumeFunction) { * @return the original Observable with appropriately modified behavior */ public Observable onErrorReturn(final Object resumeFunction) { - return onErrorReturn(this, new Func1() { + return onErrorReturn(this, new Func1() { public T call(Exception e) { return Functions.execute(resumeFunction, e); @@ -2047,7 +2154,7 @@ public Observable> toSortedList() { * @param sortFunction * @return */ - public Observable> toSortedList(Func2 sortFunction) { + public Observable> toSortedList(Func2 sortFunction) { return toSortedList(this, sortFunction); } diff --git a/rxjava-core/src/main/java/org/rx/reactive/Observer.java b/rxjava-core/src/main/java/rx/observables/Observer.java similarity index 99% rename from rxjava-core/src/main/java/org/rx/reactive/Observer.java rename to rxjava-core/src/main/java/rx/observables/Observer.java index 3d14d88a1f..6cd9250f3c 100644 --- a/rxjava-core/src/main/java/org/rx/reactive/Observer.java +++ b/rxjava-core/src/main/java/rx/observables/Observer.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.reactive; +package rx.observables; /** * Provides a mechanism for receiving push-based notifications. diff --git a/rxjava-core/src/main/java/org/rx/reactive/Subscription.java b/rxjava-core/src/main/java/rx/observables/Subscription.java similarity index 97% rename from rxjava-core/src/main/java/org/rx/reactive/Subscription.java rename to rxjava-core/src/main/java/rx/observables/Subscription.java index 315d6e1f94..9e4955ee8f 100644 --- a/rxjava-core/src/main/java/org/rx/reactive/Subscription.java +++ b/rxjava-core/src/main/java/rx/observables/Subscription.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.reactive; +package rx.observables; public interface Subscription { diff --git a/rxjava-core/src/main/java/org/rx/operations/AtomicObservableSubscription.java b/rxjava-core/src/main/java/rx/observables/operations/AtomicObservableSubscription.java similarity index 97% rename from rxjava-core/src/main/java/org/rx/operations/AtomicObservableSubscription.java rename to rxjava-core/src/main/java/rx/observables/operations/AtomicObservableSubscription.java index 2e73d754da..d297f5a8e6 100644 --- a/rxjava-core/src/main/java/org/rx/operations/AtomicObservableSubscription.java +++ b/rxjava-core/src/main/java/rx/observables/operations/AtomicObservableSubscription.java @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import javax.annotation.concurrent.ThreadSafe; -import org.rx.reactive.Subscription; +import rx.observables.Subscription; /** * Thread-safe wrapper around ObservableSubscription that ensures unsubscribe can be called only once. diff --git a/rxjava-core/src/main/java/org/rx/operations/AtomicObserver.java b/rxjava-core/src/main/java/rx/observables/operations/AtomicObserver.java similarity index 97% rename from rxjava-core/src/main/java/org/rx/operations/AtomicObserver.java rename to rxjava-core/src/main/java/rx/observables/operations/AtomicObserver.java index e8a8b9f3ea..40ec4f09ae 100644 --- a/rxjava-core/src/main/java/org/rx/operations/AtomicObserver.java +++ b/rxjava-core/src/main/java/rx/observables/operations/AtomicObserver.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import javax.annotation.concurrent.ThreadSafe; -import org.rx.reactive.Observer; +import rx.observables.Observer; /** * A thread-safe Observer for transitioning states in operators. diff --git a/rxjava-core/src/main/java/org/rx/operations/AtomicObserverMultiThreaded.java b/rxjava-core/src/main/java/rx/observables/operations/AtomicObserverMultiThreaded.java similarity index 99% rename from rxjava-core/src/main/java/org/rx/operations/AtomicObserverMultiThreaded.java rename to rxjava-core/src/main/java/rx/observables/operations/AtomicObserverMultiThreaded.java index 7d20ba1471..44a474af5e 100644 --- a/rxjava-core/src/main/java/org/rx/operations/AtomicObserverMultiThreaded.java +++ b/rxjava-core/src/main/java/rx/observables/operations/AtomicObserverMultiThreaded.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.junit.Assert.*; import static org.mockito.Matchers.*; @@ -33,9 +33,10 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; /** * A thread-safe Observer for transitioning states in operators. diff --git a/rxjava-core/src/main/java/org/rx/operations/AtomicObserverSingleThreaded.java b/rxjava-core/src/main/java/rx/observables/operations/AtomicObserverSingleThreaded.java similarity index 99% rename from rxjava-core/src/main/java/org/rx/operations/AtomicObserverSingleThreaded.java rename to rxjava-core/src/main/java/rx/observables/operations/AtomicObserverSingleThreaded.java index ca139e658d..16c30ac1d2 100644 --- a/rxjava-core/src/main/java/org/rx/operations/AtomicObserverSingleThreaded.java +++ b/rxjava-core/src/main/java/rx/observables/operations/AtomicObserverSingleThreaded.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.junit.Assert.*; import static org.mockito.Matchers.*; @@ -32,9 +32,10 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; /** * A thread-safe Observer for transitioning states in operators. diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationCombineLatest.java b/rxjava-core/src/main/java/rx/observables/operations/OperationCombineLatest.java similarity index 96% rename from rxjava-core/src/main/java/org/rx/operations/OperationCombineLatest.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationCombineLatest.java index ccba74236d..1d979407a1 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationCombineLatest.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationCombineLatest.java @@ -1,19 +1,19 @@ /** * Copyright 2013 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 - * + * + * 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 org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -28,25 +28,26 @@ import org.junit.Test; import org.mockito.InOrder; -import org.rx.functions.Func2; -import org.rx.functions.Func3; -import org.rx.functions.Func4; -import org.rx.functions.FuncN; -import org.rx.functions.Functions; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.Func2; +import rx.util.Func3; +import rx.util.Func4; +import rx.util.FuncN; +import rx.util.Functions; public class OperationCombineLatest { - public static Observable combineLatest(Observable w0, Observable w1, Func2 combineLatestFunction) { + public static Observable combineLatest(Observable w0, Observable w1, Func2 combineLatestFunction) { Aggregator a = new Aggregator(Functions.fromFunc(combineLatestFunction)); a.addObserver(new CombineObserver(a, w0)); a.addObserver(new CombineObserver(a, w1)); return a; } - public static Observable combineLatest(Observable w0, Observable w1, Observable w2, Func3 combineLatestFunction) { + public static Observable combineLatest(Observable w0, Observable w1, Observable w2, Func3 combineLatestFunction) { Aggregator a = new Aggregator(Functions.fromFunc(combineLatestFunction)); a.addObserver(new CombineObserver(a, w0)); a.addObserver(new CombineObserver(a, w1)); @@ -54,7 +55,7 @@ public static Observable combineLatest(Observable w0, Obs return a; } - public static Observable combineLatest(Observable w0, Observable w1, Observable w2, Observable w3, Func4 combineLatestFunction) { + public static Observable combineLatest(Observable w0, Observable w1, Observable w2, Observable w3, Func4 combineLatestFunction) { Aggregator a = new Aggregator(Functions.fromFunc(combineLatestFunction)); a.addObserver(new CombineObserver(a, w0)); a.addObserver(new CombineObserver(a, w1)); @@ -662,7 +663,7 @@ public void testAggregatorEarlyCompletion() { /* mock calls don't do generics */ @Test public void testCombineLatest2Types() { - Func2 combineLatestFunction = getConcatStringIntegerCombineLatestFunction(); + Func2 combineLatestFunction = getConcatStringIntegerCombineLatestFunction(); /* define a Observer to receive aggregated events */ Observer aObserver = mock(Observer.class); @@ -681,7 +682,7 @@ public void testCombineLatest2Types() { /* mock calls don't do generics */ @Test public void testCombineLatest3TypesA() { - Func3 combineLatestFunction = getConcatStringIntegerIntArrayCombineLatestFunction(); + Func3 combineLatestFunction = getConcatStringIntegerIntArrayCombineLatestFunction(); /* define a Observer to receive aggregated events */ Observer aObserver = mock(Observer.class); @@ -698,7 +699,7 @@ public void testCombineLatest3TypesA() { /* mock calls don't do generics */ @Test public void testCombineLatest3TypesB() { - Func3 combineLatestFunction = getConcatStringIntegerIntArrayCombineLatestFunction(); + Func3 combineLatestFunction = getConcatStringIntegerIntArrayCombineLatestFunction(); /* define a Observer to receive aggregated events */ Observer aObserver = mock(Observer.class); @@ -752,8 +753,8 @@ public String call(Object... args) { return combineLatestFunction; } - private Func2 getConcatStringIntegerCombineLatestFunction() { - Func2 combineLatestFunction = new Func2() { + private Func2 getConcatStringIntegerCombineLatestFunction() { + Func2 combineLatestFunction = new Func2() { @Override public String call(String s, Integer i) { @@ -764,8 +765,8 @@ public String call(String s, Integer i) { return combineLatestFunction; } - private Func3 getConcatStringIntegerIntArrayCombineLatestFunction() { - Func3 combineLatestFunction = new Func3() { + private Func3 getConcatStringIntegerIntArrayCombineLatestFunction() { + Func3 combineLatestFunction = new Func3() { @Override public String call(String s, Integer i, int[] iArray) { diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationFilter.java b/rxjava-core/src/main/java/rx/observables/operations/OperationFilter.java similarity index 88% rename from rxjava-core/src/main/java/org/rx/operations/OperationFilter.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationFilter.java index a55624aadb..4917dfa00e 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationFilter.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationFilter.java @@ -1,42 +1,43 @@ /** * Copyright 2013 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 - * + * + * 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 org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import org.junit.Test; import org.mockito.Mockito; -import org.rx.functions.Func1; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.Func1; public final class OperationFilter { - public static Observable filter(Observable that, Func1 predicate) { + public static Observable filter(Observable that, Func1 predicate) { return new Filter(that, predicate); } private static class Filter extends Observable { private final Observable that; - private final Func1 predicate; + private final Func1 predicate; - public Filter(Observable that, Func1 predicate) { + public Filter(Observable that, Func1 predicate) { this.that = that; this.predicate = predicate; } @@ -75,7 +76,7 @@ public static class UnitTest { @Test public void testFilter() { Observable w = Observable.toObservable("one", "two", "three"); - Observable Observable = filter(w, new Func1() { + Observable Observable = filter(w, new Func1() { @Override public Boolean call(String t1) { diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationLast.java b/rxjava-core/src/main/java/rx/observables/operations/OperationLast.java similarity index 95% rename from rxjava-core/src/main/java/org/rx/operations/OperationLast.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationLast.java index fee302c88e..47f1e81987 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationLast.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationLast.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -23,9 +23,10 @@ import org.junit.Test; import org.mockito.Mockito; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; /** * Returns the last element of an observable sequence. diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationMap.java b/rxjava-core/src/main/java/rx/observables/operations/OperationMap.java similarity index 90% rename from rxjava-core/src/main/java/org/rx/operations/OperationMap.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationMap.java index 896e87c3c9..d6afeca9ca 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationMap.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationMap.java @@ -1,19 +1,19 @@ /** * Copyright 2013 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 - * + * + * 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 org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -25,10 +25,11 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.rx.functions.Func1; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.Func1; public final class OperationMap { @@ -46,7 +47,7 @@ public final class OperationMap { * the type of the output sequence. * @return a sequence that is the result of applying the transformation function to each item in the input sequence. */ - public static Observable map(Observable sequence, Func1 func) { + public static Observable map(Observable sequence, Func1 func) { return new MapObservable(sequence, func); } @@ -66,7 +67,7 @@ public static Observable map(Observable sequence, Func1 func) * the type of the output sequence. * @return a sequence that is the result of applying the transformation function to each item in the input sequence. */ - public static Observable mapMany(Observable sequence, Func1, T> func) { + public static Observable mapMany(Observable sequence, Func1> func) { return OperationMerge.merge(map(sequence, func)); } @@ -79,14 +80,14 @@ public static Observable mapMany(Observable sequence, Func1 extends Observable { - public MapObservable(Observable sequence, Func1 func) { + public MapObservable(Observable sequence, Func1 func) { this.sequence = sequence; this.func = func; } private Observable sequence; - private Func1 func; + private Func1 func; public Subscription subscribe(Observer Observer) { final AtomicObservableSubscription subscription = new AtomicObservableSubscription(); @@ -105,14 +106,14 @@ public Subscription subscribe(Observer Observer) { * the type of the inner observer items. */ private static class MapObserver implements Observer { - public MapObserver(Observer observer, Func1 func) { + public MapObserver(Observer observer, Func1 func) { this.observer = observer; this.func = func; } Observer observer; - Func1 func; + Func1 func; public void onNext(T value) { try { @@ -147,7 +148,7 @@ public void testMap() { @SuppressWarnings("unchecked") Observable> observable = Observable.toObservable(m1, m2); - Observable m = map(observable, new Func1>() { + Observable m = map(observable, new Func1, String>() { @Override public String call(Map map) { @@ -170,7 +171,7 @@ public void testMapMany() { Observable ids = Observable.toObservable(1, 2); /* now simulate the behavior to take those IDs and perform nested async calls based on them */ - Observable m = mapMany(ids, new Func1, Integer>() { + Observable m = mapMany(ids, new Func1>() { @SuppressWarnings("unchecked") @Override @@ -188,7 +189,7 @@ public Observable call(Integer id) { } /* simulate kicking off the async call and performing a select on it to transform the data */ - return map(subObservable, new Func1>() { + return map(subObservable, new Func1, String>() { @Override public String call(Map map) { return map.get("firstName"); @@ -222,11 +223,11 @@ public void testMapMany2() { @SuppressWarnings("unchecked") Observable>> observable = Observable.toObservable(observable1, observable2); - Observable m = mapMany(observable, new Func1, Observable>>() { + Observable m = mapMany(observable, new Func1>, Observable>() { @Override public Observable call(Observable> o) { - return map(o, new Func1>() { + return map(o, new Func1, String>() { @Override public String call(Map map) { diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationMaterialize.java b/rxjava-core/src/main/java/rx/observables/operations/OperationMaterialize.java similarity index 97% rename from rxjava-core/src/main/java/org/rx/operations/OperationMaterialize.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationMaterialize.java index 0254a0a29a..f26ca13087 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationMaterialize.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationMaterialize.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.junit.Assert.*; @@ -21,10 +21,11 @@ import java.util.Vector; import org.junit.Test; -import org.rx.reactive.Notification; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Notification; +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; /** * Materializes the implicit notifications of an observable sequence as explicit notification values. diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationMerge.java b/rxjava-core/src/main/java/rx/observables/operations/OperationMerge.java similarity index 99% rename from rxjava-core/src/main/java/org/rx/operations/OperationMerge.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationMerge.java index 291f5a4a36..b038fa8164 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationMerge.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationMerge.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.junit.Assert.*; import static org.mockito.Matchers.*; @@ -28,9 +28,10 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; public final class OperationMerge { diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationMergeDelayError.java b/rxjava-core/src/main/java/rx/observables/operations/OperationMergeDelayError.java similarity index 99% rename from rxjava-core/src/main/java/org/rx/operations/OperationMergeDelayError.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationMergeDelayError.java index 8ddd3bff46..e295a11537 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationMergeDelayError.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationMergeDelayError.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.junit.Assert.*; import static org.mockito.Matchers.*; @@ -29,10 +29,11 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.rx.reactive.CompositeException; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.CompositeException; +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; /** * Same functionality as OperationMerge except that onError events will be skipped so that all onNext calls are passed on until all sequences finish with onComplete or onError, and then the first diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationOnErrorResumeNextViaFunction.java b/rxjava-core/src/main/java/rx/observables/operations/OperationOnErrorResumeNextViaFunction.java similarity index 93% rename from rxjava-core/src/main/java/org/rx/operations/OperationOnErrorResumeNextViaFunction.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationOnErrorResumeNextViaFunction.java index deeae45435..8d3e2b2cdd 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationOnErrorResumeNextViaFunction.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationOnErrorResumeNextViaFunction.java @@ -1,19 +1,19 @@ /** * Copyright 2013 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 - * + * + * 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 org.rx.operations; +package rx.observables.operations; import static org.junit.Assert.*; import static org.mockito.Matchers.*; @@ -24,24 +24,25 @@ import org.junit.Test; import org.mockito.Mockito; -import org.rx.functions.Func1; -import org.rx.reactive.CompositeException; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.CompositeException; +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.Func1; public final class OperationOnErrorResumeNextViaFunction { - public static Observable onErrorResumeNextViaFunction(Observable originalSequence, Func1, Exception> resumeFunction) { + public static Observable onErrorResumeNextViaFunction(Observable originalSequence, Func1> resumeFunction) { return new OnErrorResumeNextViaFunction(originalSequence, resumeFunction); } private static class OnErrorResumeNextViaFunction extends Observable { - private final Func1, Exception> resumeFunction; + private final Func1> resumeFunction; private final Observable originalSequence; - public OnErrorResumeNextViaFunction(Observable originalSequence, Func1, Exception> resumeFunction) { + public OnErrorResumeNextViaFunction(Observable originalSequence, Func1> resumeFunction) { this.resumeFunction = resumeFunction; this.originalSequence = originalSequence; } @@ -111,7 +112,7 @@ public void testResumeNext() { final AtomicReference receivedException = new AtomicReference(); Subscription s = mock(Subscription.class); TestObservable w = new TestObservable(s, "one"); - Func1, Exception> resume = new Func1, Exception>() { + Func1> resume = new Func1>() { @Override public Observable call(Exception t1) { @@ -149,7 +150,7 @@ public Observable call(Exception t1) { public void testFunctionThrowsError() { Subscription s = mock(Subscription.class); TestObservable w = new TestObservable(s, "one"); - Func1, Exception> resume = new Func1, Exception>() { + Func1> resume = new Func1>() { @Override public Observable call(Exception t1) { diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationOnErrorResumeNextViaObservable.java b/rxjava-core/src/main/java/rx/observables/operations/OperationOnErrorResumeNextViaObservable.java similarity index 98% rename from rxjava-core/src/main/java/org/rx/operations/OperationOnErrorResumeNextViaObservable.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationOnErrorResumeNextViaObservable.java index df7f8de7f2..7df897018a 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationOnErrorResumeNextViaObservable.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationOnErrorResumeNextViaObservable.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.junit.Assert.*; import static org.mockito.Matchers.*; @@ -23,9 +23,10 @@ import org.junit.Test; import org.mockito.Mockito; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; public final class OperationOnErrorResumeNextViaObservable { diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationOnErrorReturn.java b/rxjava-core/src/main/java/rx/observables/operations/OperationOnErrorReturn.java similarity index 94% rename from rxjava-core/src/main/java/org/rx/operations/OperationOnErrorReturn.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationOnErrorReturn.java index 06be1f61eb..8a546f96a7 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationOnErrorReturn.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationOnErrorReturn.java @@ -1,19 +1,19 @@ /** * Copyright 2013 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 - * + * + * 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 org.rx.operations; +package rx.observables.operations; import static org.junit.Assert.*; import static org.mockito.Matchers.*; @@ -24,26 +24,27 @@ import org.junit.Test; import org.mockito.Mockito; -import org.rx.functions.Func1; -import org.rx.reactive.CompositeException; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.CompositeException; +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.Func1; /** * When an onError occurs the resumeFunction will be executed and it's response passed to onNext instead of calling onError. */ public final class OperationOnErrorReturn { - public static Observable onErrorReturn(Observable originalSequence, Func1 resumeFunction) { + public static Observable onErrorReturn(Observable originalSequence, Func1 resumeFunction) { return new OnErrorReturn(originalSequence, resumeFunction); } private static class OnErrorReturn extends Observable { - private final Func1 resumeFunction; + private final Func1 resumeFunction; private final Observable originalSequence; - public OnErrorReturn(Observable originalSequence, Func1 resumeFunction) { + public OnErrorReturn(Observable originalSequence, Func1 resumeFunction) { this.resumeFunction = resumeFunction; this.originalSequence = originalSequence; } @@ -119,7 +120,7 @@ public void testResumeNext() { TestObservable w = new TestObservable(s, "one"); final AtomicReference capturedException = new AtomicReference(); - Observable Observable = onErrorReturn(w, new Func1() { + Observable Observable = onErrorReturn(w, new Func1() { @Override public String call(Exception e) { @@ -155,7 +156,7 @@ public void testFunctionThrowsError() { TestObservable w = new TestObservable(s, "one"); final AtomicReference capturedException = new AtomicReference(); - Observable Observable = onErrorReturn(w, new Func1() { + Observable Observable = onErrorReturn(w, new Func1() { @Override public String call(Exception e) { diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationScan.java b/rxjava-core/src/main/java/rx/observables/operations/OperationScan.java similarity index 98% rename from rxjava-core/src/main/java/org/rx/operations/OperationScan.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationScan.java index 8bf76140b2..fa87bf9e41 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationScan.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationScan.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -21,10 +21,11 @@ import org.junit.Before; import org.junit.Test; import org.mockito.MockitoAnnotations; -import org.rx.functions.Func2; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.Func2; public final class OperationScan { /** diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationSkip.java b/rxjava-core/src/main/java/rx/observables/operations/OperationSkip.java similarity index 97% rename from rxjava-core/src/main/java/org/rx/operations/OperationSkip.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationSkip.java index c7738efb0c..8c295abeaf 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationSkip.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationSkip.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -21,9 +21,10 @@ import java.util.concurrent.atomic.AtomicInteger; import org.junit.Test; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; /** * Skips a specified number of contiguous values from the start of a Observable sequence and then returns the remaining values. diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationSynchronize.java b/rxjava-core/src/main/java/rx/observables/operations/OperationSynchronize.java similarity index 98% rename from rxjava-core/src/main/java/org/rx/operations/OperationSynchronize.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationSynchronize.java index a2d73db469..2cc7fe5425 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationSynchronize.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationSynchronize.java @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import org.junit.Test; import org.mockito.Mockito; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; /** * An observable that wraps an observable of the same type and then enforces the semantics diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationTake.java b/rxjava-core/src/main/java/rx/observables/operations/OperationTake.java similarity index 98% rename from rxjava-core/src/main/java/org/rx/operations/OperationTake.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationTake.java index 1bd404115d..fd4ae39c32 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationTake.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationTake.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.junit.Assert.*; import static org.mockito.Matchers.*; @@ -22,9 +22,10 @@ import java.util.concurrent.atomic.AtomicInteger; import org.junit.Test; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; /** * Returns a specified number of contiguous values from the start of an observable sequence. diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationToObservableFunction.java b/rxjava-core/src/main/java/rx/observables/operations/OperationToObservableFunction.java similarity index 85% rename from rxjava-core/src/main/java/org/rx/operations/OperationToObservableFunction.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationToObservableFunction.java index 33f4048e4f..bd8f4a7cf0 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationToObservableFunction.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationToObservableFunction.java @@ -1,29 +1,30 @@ /** * Copyright 2013 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 - * + * + * 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 org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; import org.junit.Test; import org.mockito.Mockito; -import org.rx.functions.Func1; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.Func1; /** * Accepts a Function and makes it into a Observable. @@ -36,14 +37,14 @@ */ public final class OperationToObservableFunction { - public static Observable toObservableFunction(Func1> func) { + public static Observable toObservableFunction(Func1, Subscription> func) { return new ToObservableFunction(func); } private static class ToObservableFunction extends Observable { - private final Func1> func; + private final Func1, Subscription> func; - public ToObservableFunction(Func1> func) { + public ToObservableFunction(Func1, Subscription> func) { this.func = func; } @@ -66,7 +67,7 @@ public static class UnitTest { @Test public void testCreate() { - Observable observable = toObservableFunction(new Func1>() { + Observable observable = toObservableFunction(new Func1, Subscription>() { @Override public Subscription call(Observer Observer) { diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationToObservableIterable.java b/rxjava-core/src/main/java/rx/observables/operations/OperationToObservableIterable.java similarity index 94% rename from rxjava-core/src/main/java/org/rx/operations/OperationToObservableIterable.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationToObservableIterable.java index 1338b59a4f..f621744fa0 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationToObservableIterable.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationToObservableIterable.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -22,9 +22,10 @@ import org.junit.Test; import org.mockito.Mockito; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; /** * Accepts an Iterable object and exposes it as an Observable. diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationToObservableList.java b/rxjava-core/src/main/java/rx/observables/operations/OperationToObservableList.java similarity index 96% rename from rxjava-core/src/main/java/org/rx/operations/OperationToObservableList.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationToObservableList.java index 14977f04a8..468d7a689d 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationToObservableList.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationToObservableList.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -25,9 +25,10 @@ import org.junit.Test; import org.mockito.Mockito; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; public final class OperationToObservableList { diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationToObservableSortedList.java b/rxjava-core/src/main/java/rx/observables/operations/OperationToObservableSortedList.java similarity index 93% rename from rxjava-core/src/main/java/org/rx/operations/OperationToObservableSortedList.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationToObservableSortedList.java index f6afd9bf7e..276e39ce61 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationToObservableSortedList.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationToObservableSortedList.java @@ -1,19 +1,19 @@ /** * Copyright 2013 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 - * + * + * 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 org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -27,10 +27,11 @@ import org.junit.Test; import org.mockito.Mockito; -import org.rx.functions.Func2; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.Func2; /** * Similar to toList in that it converts a sequence into a List except that it accepts a Function that will provide an implementation of Comparator. @@ -58,7 +59,7 @@ public static Observable> toSortedList(Observable sequence) { * @param sortFunction * @return */ - public static Observable> toSortedList(Observable sequence, Func2 sortFunction) { + public static Observable> toSortedList(Observable sequence, Func2 sortFunction) { return new ToObservableSortedList(sequence, sortFunction); } @@ -66,7 +67,7 @@ private static class ToObservableSortedList extends Observable> { private final Observable that; private final ConcurrentLinkedQueue list = new ConcurrentLinkedQueue(); - private final Func2 sortFunction; + private final Func2 sortFunction; // unchecked as we're support Object for the default @SuppressWarnings("unchecked") @@ -74,7 +75,7 @@ private ToObservableSortedList(Observable that) { this(that, defaultSortFunction); } - private ToObservableSortedList(Observable that, Func2 sortFunction) { + private ToObservableSortedList(Observable that, Func2 sortFunction) { this.that = that; this.sortFunction = sortFunction; } @@ -126,7 +127,7 @@ public int compare(T o1, T o2) { @SuppressWarnings("rawtypes") private static Func2 defaultSortFunction = new DefaultComparableFunction(); - private static class DefaultComparableFunction implements Func2 { + private static class DefaultComparableFunction implements Func2 { // unchecked because we want to support Object for this default @SuppressWarnings("unchecked") diff --git a/rxjava-core/src/main/java/org/rx/operations/OperationZip.java b/rxjava-core/src/main/java/rx/observables/operations/OperationZip.java similarity index 96% rename from rxjava-core/src/main/java/org/rx/operations/OperationZip.java rename to rxjava-core/src/main/java/rx/observables/operations/OperationZip.java index f7b4efdee7..824ce504f6 100644 --- a/rxjava-core/src/main/java/org/rx/operations/OperationZip.java +++ b/rxjava-core/src/main/java/rx/observables/operations/OperationZip.java @@ -1,19 +1,19 @@ /** * Copyright 2013 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 - * + * + * 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 org.rx.operations; +package rx.observables.operations; import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; @@ -28,25 +28,26 @@ import org.junit.Test; import org.mockito.InOrder; -import org.rx.functions.Func2; -import org.rx.functions.Func3; -import org.rx.functions.Func4; -import org.rx.functions.FuncN; -import org.rx.functions.Functions; -import org.rx.reactive.Observable; -import org.rx.reactive.Observer; -import org.rx.reactive.Subscription; + +import rx.observables.Observable; +import rx.observables.Observer; +import rx.observables.Subscription; +import rx.util.Func2; +import rx.util.Func3; +import rx.util.Func4; +import rx.util.FuncN; +import rx.util.Functions; public final class OperationZip { - public static Observable zip(Observable w0, Observable w1, Func2 zipFunction) { + public static Observable zip(Observable w0, Observable w1, Func2 zipFunction) { Aggregator a = new Aggregator(Functions.fromFunc(zipFunction)); a.addObserver(new ZipObserver(a, w0)); a.addObserver(new ZipObserver(a, w1)); return a; } - public static Observable zip(Observable w0, Observable w1, Observable w2, Func3 zipFunction) { + public static Observable zip(Observable w0, Observable w1, Observable w2, Func3 zipFunction) { Aggregator a = new Aggregator(Functions.fromFunc(zipFunction)); a.addObserver(new ZipObserver(a, w0)); a.addObserver(new ZipObserver(a, w1)); @@ -54,7 +55,7 @@ public static Observable zip(Observable w0, Observable Observable zip(Observable w0, Observable w1, Observable w2, Observable w3, Func4 zipFunction) { + public static Observable zip(Observable w0, Observable w1, Observable w2, Observable w3, Func4 zipFunction) { Aggregator a = new Aggregator(Functions.fromFunc(zipFunction)); a.addObserver(new ZipObserver(a, w0)); a.addObserver(new ZipObserver(a, w1)); @@ -659,7 +660,7 @@ public void testAggregatorEarlyCompletion() { /* mock calls don't do generics */ @Test public void testZip2Types() { - Func2 zipr = getConcatStringIntegerZipr(); + Func2 zipr = getConcatStringIntegerZipr(); /* define a Observer to receive aggregated events */ Observer aObserver = mock(Observer.class); @@ -678,7 +679,7 @@ public void testZip2Types() { /* mock calls don't do generics */ @Test public void testZip3Types() { - Func3 zipr = getConcatStringIntegerIntArrayZipr(); + Func3 zipr = getConcatStringIntegerIntArrayZipr(); /* define a Observer to receive aggregated events */ Observer aObserver = mock(Observer.class); @@ -757,8 +758,8 @@ public String call(Object... args) { return zipr; } - private Func2 getConcatStringIntegerZipr() { - Func2 zipr = new Func2() { + private Func2 getConcatStringIntegerZipr() { + Func2 zipr = new Func2() { @Override public String call(String s, Integer i) { @@ -769,8 +770,8 @@ public String call(String s, Integer i) { return zipr; } - private Func3 getConcatStringIntegerIntArrayZipr() { - Func3 zipr = new Func3() { + private Func3 getConcatStringIntegerIntArrayZipr() { + Func3 zipr = new Func3() { @Override public String call(String s, Integer i, int[] iArray) { diff --git a/rxjava-core/src/main/java/org/rx/operations/package.html b/rxjava-core/src/main/java/rx/observables/operations/package.html similarity index 100% rename from rxjava-core/src/main/java/org/rx/operations/package.html rename to rxjava-core/src/main/java/rx/observables/operations/package.html diff --git a/rxjava-core/src/main/java/rx/observables/package-info.java b/rxjava-core/src/main/java/rx/observables/package-info.java new file mode 100644 index 0000000000..73f66e85c1 --- /dev/null +++ b/rxjava-core/src/main/java/rx/observables/package-info.java @@ -0,0 +1,45 @@ +/** + * Copyright 2013 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. + */ +/** + *

Rx Observables

+ * + *

A library that enables subscribing to and composing asynchronous events and + * callbacks.

+ *

The Observable/Observer interfaces and associated operators (in + * the .operations package) are inspired by and attempt to conform to the + * Reactive Rx library in Microsoft .Net.

+ *

+ * More information can be found at http://msdn.microsoft.com/en-us/data/gg577609. + *

+ * + * + *

Compared with the Microsoft implementation: + *

    + *
  • Observable == IObservable
  • + *
  • Observer == IObserver
  • + *
  • Subscription == IDisposable
  • + *
  • ObservableExtensions == Observable
  • + *
+ *

+ *

Services which intend on exposing data asynchronously and wish + * to allow reactive processing and composition can implement the + * Watchable interface which then allows Watchers to subscribe to them + * and receive events.

+ *

Usage examples can be found on the Watchable and Watcher + * classes.

+ */ +package rx.observables; \ No newline at end of file diff --git a/rxjava-core/src/main/java/rx/util/Action0.java b/rxjava-core/src/main/java/rx/util/Action0.java new file mode 100644 index 0000000000..b8cc6d9c99 --- /dev/null +++ b/rxjava-core/src/main/java/rx/util/Action0.java @@ -0,0 +1,20 @@ +/** + * Copyright 2013 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; + +public interface Action0 { + public void call(); +} \ No newline at end of file diff --git a/rxjava-core/src/main/java/rx/util/Action1.java b/rxjava-core/src/main/java/rx/util/Action1.java new file mode 100644 index 0000000000..efdc4daa44 --- /dev/null +++ b/rxjava-core/src/main/java/rx/util/Action1.java @@ -0,0 +1,20 @@ +/** + * Copyright 2013 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; + +public interface Action1 { + public void call(T1 t1); +} \ No newline at end of file diff --git a/rxjava-core/src/main/java/rx/util/Action2.java b/rxjava-core/src/main/java/rx/util/Action2.java new file mode 100644 index 0000000000..21461f7cb5 --- /dev/null +++ b/rxjava-core/src/main/java/rx/util/Action2.java @@ -0,0 +1,20 @@ +/** + * Copyright 2013 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; + +public interface Action2 { + public void call(T1 t1, T2 t2); +} \ No newline at end of file diff --git a/rxjava-core/src/main/java/rx/util/Action3.java b/rxjava-core/src/main/java/rx/util/Action3.java new file mode 100644 index 0000000000..6630b124ba --- /dev/null +++ b/rxjava-core/src/main/java/rx/util/Action3.java @@ -0,0 +1,20 @@ +/** + * Copyright 2013 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; + +public interface Action3 { + public void call(T1 t1, T2 t2, T3 t3); +} \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/functions/Func0.java b/rxjava-core/src/main/java/rx/util/Func0.java similarity index 96% rename from rxjava-core/src/main/java/org/rx/functions/Func0.java rename to rxjava-core/src/main/java/rx/util/Func0.java index c02326a138..1934902c91 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Func0.java +++ b/rxjava-core/src/main/java/rx/util/Func0.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; public interface Func0 { public R call(); diff --git a/rxjava-core/src/main/java/org/rx/functions/Func1.java b/rxjava-core/src/main/java/rx/util/Func1.java similarity index 91% rename from rxjava-core/src/main/java/org/rx/functions/Func1.java rename to rxjava-core/src/main/java/rx/util/Func1.java index 76203e83c5..ae67de59c5 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Func1.java +++ b/rxjava-core/src/main/java/rx/util/Func1.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; -public interface Func1 { +public interface Func1 { public R call(T1 t1); } \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/functions/Func2.java b/rxjava-core/src/main/java/rx/util/Func2.java similarity index 91% rename from rxjava-core/src/main/java/org/rx/functions/Func2.java rename to rxjava-core/src/main/java/rx/util/Func2.java index 312dc983b8..5c9fa7936d 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Func2.java +++ b/rxjava-core/src/main/java/rx/util/Func2.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; -public interface Func2 { +public interface Func2 { public R call(T1 t1, T2 t2); } \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/functions/Func3.java b/rxjava-core/src/main/java/rx/util/Func3.java similarity index 90% rename from rxjava-core/src/main/java/org/rx/functions/Func3.java rename to rxjava-core/src/main/java/rx/util/Func3.java index 9beeb07e75..8147d35706 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Func3.java +++ b/rxjava-core/src/main/java/rx/util/Func3.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; -public interface Func3 { +public interface Func3 { public R call(T1 t1, T2 t2, T3 t3); } \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/functions/Func4.java b/rxjava-core/src/main/java/rx/util/Func4.java similarity index 90% rename from rxjava-core/src/main/java/org/rx/functions/Func4.java rename to rxjava-core/src/main/java/rx/util/Func4.java index c23848003d..2a4df7212b 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Func4.java +++ b/rxjava-core/src/main/java/rx/util/Func4.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; -public interface Func4 { +public interface Func4 { public R call(T1 t1, T2 t2, T3 t3, T4 t4); } \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/functions/Func5.java b/rxjava-core/src/main/java/rx/util/Func5.java similarity index 89% rename from rxjava-core/src/main/java/org/rx/functions/Func5.java rename to rxjava-core/src/main/java/rx/util/Func5.java index 1bc9857e76..888334f4be 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Func5.java +++ b/rxjava-core/src/main/java/rx/util/Func5.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; -public interface Func5 { +public interface Func5 { public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5); } \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/functions/Func6.java b/rxjava-core/src/main/java/rx/util/Func6.java similarity index 89% rename from rxjava-core/src/main/java/org/rx/functions/Func6.java rename to rxjava-core/src/main/java/rx/util/Func6.java index 7286728aac..1e036a5aff 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Func6.java +++ b/rxjava-core/src/main/java/rx/util/Func6.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; -public interface Func6 { +public interface Func6 { public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6); } \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/functions/Func7.java b/rxjava-core/src/main/java/rx/util/Func7.java similarity index 89% rename from rxjava-core/src/main/java/org/rx/functions/Func7.java rename to rxjava-core/src/main/java/rx/util/Func7.java index 68a5a63010..6c6559013a 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Func7.java +++ b/rxjava-core/src/main/java/rx/util/Func7.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; -public interface Func7 { +public interface Func7 { public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7); } \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/functions/Func8.java b/rxjava-core/src/main/java/rx/util/Func8.java similarity index 88% rename from rxjava-core/src/main/java/org/rx/functions/Func8.java rename to rxjava-core/src/main/java/rx/util/Func8.java index fc5fd5ed93..2263823a7b 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Func8.java +++ b/rxjava-core/src/main/java/rx/util/Func8.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; -public interface Func8 { +public interface Func8 { public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8); } \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/functions/Func9.java b/rxjava-core/src/main/java/rx/util/Func9.java similarity index 88% rename from rxjava-core/src/main/java/org/rx/functions/Func9.java rename to rxjava-core/src/main/java/rx/util/Func9.java index 933fbc5376..2de318b122 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Func9.java +++ b/rxjava-core/src/main/java/rx/util/Func9.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; -public interface Func9 { +public interface Func9 { public R call(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9); } \ No newline at end of file diff --git a/rxjava-core/src/main/java/org/rx/functions/FuncN.java b/rxjava-core/src/main/java/rx/util/FuncN.java similarity index 96% rename from rxjava-core/src/main/java/org/rx/functions/FuncN.java rename to rxjava-core/src/main/java/rx/util/FuncN.java index cbbb3dd920..b1cedff38e 100644 --- a/rxjava-core/src/main/java/org/rx/functions/FuncN.java +++ b/rxjava-core/src/main/java/rx/util/FuncN.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; public interface FuncN { public R call(Object... args); diff --git a/rxjava-core/src/main/java/org/rx/functions/FunctionLanguageAdaptor.java b/rxjava-core/src/main/java/rx/util/FunctionLanguageAdaptor.java similarity index 97% rename from rxjava-core/src/main/java/org/rx/functions/FunctionLanguageAdaptor.java rename to rxjava-core/src/main/java/rx/util/FunctionLanguageAdaptor.java index dfbd735b24..129a94e18d 100644 --- a/rxjava-core/src/main/java/org/rx/functions/FunctionLanguageAdaptor.java +++ b/rxjava-core/src/main/java/rx/util/FunctionLanguageAdaptor.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; public interface FunctionLanguageAdaptor { diff --git a/rxjava-core/src/main/java/org/rx/functions/Functions.java b/rxjava-core/src/main/java/rx/util/Functions.java similarity index 92% rename from rxjava-core/src/main/java/org/rx/functions/Functions.java rename to rxjava-core/src/main/java/rx/util/Functions.java index 6afaef4059..33c89dc350 100644 --- a/rxjava-core/src/main/java/org/rx/functions/Functions.java +++ b/rxjava-core/src/main/java/rx/util/Functions.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.rx.functions; +package rx.util; import java.util.Collection; import java.util.concurrent.ConcurrentHashMap; @@ -44,7 +44,7 @@ public class Functions { } private static void loadLanguageAdaptor(String name) { - String className = "org.rx.lang." + name.toLowerCase() + "." + name + "Adaptor"; + String className = "rx.lang." + name.toLowerCase() + "." + name + "Adaptor"; try { Class c = Class.forName(className); FunctionLanguageAdaptor a = (FunctionLanguageAdaptor) c.newInstance(); @@ -121,25 +121,25 @@ public static R execute(Object function, Object... args) { } return (R) f.call(); } else if (function instanceof Func1) { - Func1 f = (Func1) function; + Func1 f = (Func1) function; if (args.length != 1) { throw new RuntimeException("The closure was Func1 and expected 1 argument, but we received: " + args.length); } return f.call(args[0]); } else if (function instanceof Func2) { - Func2 f = (Func2) function; + Func2 f = (Func2) function; if (args.length != 2) { throw new RuntimeException("The closure was Func2 and expected 2 arguments, but we received: " + args.length); } return f.call(args[0], args[1]); } else if (function instanceof Func3) { - Func3 f = (Func3) function; + Func3 f = (Func3) function; if (args.length != 3) { throw new RuntimeException("The closure was Func3 and expected 3 arguments, but we received: " + args.length); } return (R) f.call(args[0], args[1], args[2]); } else if (function instanceof Func4) { - Func4 f = (Func4) function; + Func4 f = (Func4) function; if (args.length != 1) { throw new RuntimeException("The closure was Func4 and expected 4 arguments, but we received: " + args.length); } @@ -163,7 +163,7 @@ public static R execute(Object function, Object... args) { } } - public static FuncN fromFunc(final Func1 f) { + public static FuncN fromFunc(final Func1 f) { return new FuncN() { /** @@ -184,7 +184,7 @@ public R call(Object... args) { }; } - public static FuncN fromFunc(final Func2 f) { + public static FuncN fromFunc(final Func2 f) { return new FuncN() { /** @@ -204,7 +204,7 @@ public R call(Object... args) { }; } - public static FuncN fromFunc(final Func3 f) { + public static FuncN fromFunc(final Func3 f) { return new FuncN() { /** @@ -224,7 +224,7 @@ public R call(Object... args) { }; } - public static FuncN fromFunc(final Func4 f) { + public static FuncN fromFunc(final Func4 f) { return new FuncN() { /**