Skip to content

Commit 94755bc

Browse files
bulk import organize and code formatting
1 parent 95bbf19 commit 94755bc

13 files changed

+413
-240
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 272 additions & 140 deletions
Large diffs are not rendered by default.

rxjava-core/src/main/java/rx/operators/OperationDefer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2013 Netflix, Inc.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,15 +15,16 @@
1515
*/
1616
package rx.operators;
1717

18+
import static org.mockito.Mockito.*;
19+
1820
import org.junit.Test;
21+
1922
import rx.Observable;
2023
import rx.Observer;
2124
import rx.Subscription;
2225
import rx.util.functions.Func0;
2326
import rx.util.functions.Func1;
2427

25-
import static org.mockito.Mockito.*;
26-
2728
public final class OperationDefer {
2829

2930
public static <T> Func1<Observer<T>, Subscription> defer(final Func0<Observable<T>> observableFactory) {

rxjava-core/src/main/java/rx/operators/OperationDematerialize.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2013 Netflix, Inc.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,6 +15,7 @@
1515
*/
1616
package rx.operators;
1717

18+
import static org.mockito.Matchers.*;
1819
import static org.mockito.Mockito.*;
1920

2021
import org.junit.Test;
@@ -33,7 +34,7 @@ public final class OperationDematerialize {
3334

3435
/**
3536
* Dematerializes the explicit notification values of an observable sequence as implicit notifications.
36-
*
37+
*
3738
* @param sequence
3839
* An observable sequence containing explicit notification values which have to be turned into implicit notifications.
3940
* @return An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.
@@ -65,15 +66,15 @@ public void onError(Exception e) {
6566
@Override
6667
public void onNext(Notification<T> value) {
6768
switch (value.getKind()) {
68-
case OnNext:
69-
observer.onNext(value.getValue());
70-
break;
71-
case OnError:
72-
observer.onError(value.getException());
73-
break;
74-
case OnCompleted:
75-
observer.onCompleted();
76-
break;
69+
case OnNext:
70+
observer.onNext(value.getValue());
71+
break;
72+
case OnError:
73+
observer.onError(value.getException());
74+
break;
75+
case OnCompleted:
76+
observer.onCompleted();
77+
break;
7778
}
7879
}
7980
});

rxjava-core/src/main/java/rx/operators/OperationMostRecent.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@
1515
*/
1616
package rx.operators;
1717

18-
import org.junit.Test;
19-
import rx.Observable;
20-
import rx.Observer;
21-
import rx.Subscription;
22-
import rx.util.Exceptions;
18+
import static org.junit.Assert.*;
19+
import static org.mockito.Mockito.*;
2320

2421
import java.util.Iterator;
2522
import java.util.concurrent.atomic.AtomicBoolean;
2623
import java.util.concurrent.atomic.AtomicReference;
2724

28-
import static org.junit.Assert.*;
29-
import static org.mockito.Mockito.mock;
25+
import org.junit.Test;
26+
27+
import rx.Observable;
28+
import rx.Observer;
29+
import rx.Subscription;
30+
import rx.util.Exceptions;
3031

3132
/**
3233
* Samples the most recent value in an observable sequence.
@@ -85,7 +86,6 @@ private MostRecentObserver(T value) {
8586
this.value = new AtomicReference<T>(value);
8687
}
8788

88-
8989
@Override
9090
public void onCompleted() {
9191
completed.set(true);

rxjava-core/src/main/java/rx/operators/OperationTake.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2013 Netflix, Inc.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,31 +37,33 @@ public final class OperationTake {
3737

3838
/**
3939
* Returns a specified number of contiguous values from the start of an observable sequence.
40-
*
40+
*
4141
* @param items
4242
* @param num
4343
* @return
4444
*/
4545
public static <T> Func1<Observer<T>, Subscription> take(final Observable<T> items, final int num) {
46-
return takeWhileWithIndex(items, OperationTake.<T>numPredicate(num));
46+
return takeWhileWithIndex(items, OperationTake.<T> numPredicate(num));
4747
}
4848

4949
/**
5050
* Returns a specified number of contiguous values from the start of an observable sequence.
51-
*
51+
*
5252
* @param items
53-
* @param predicate a function to test each source element for a condition
53+
* @param predicate
54+
* a function to test each source element for a condition
5455
* @return
5556
*/
5657
public static <T> Func1<Observer<T>, Subscription> takeWhile(final Observable<T> items, final Func1<T, Boolean> predicate) {
57-
return takeWhileWithIndex(items, OperationTake.<T>skipIndex(predicate));
58+
return takeWhileWithIndex(items, OperationTake.<T> skipIndex(predicate));
5859
}
5960

6061
/**
6162
* Returns values from an observable sequence as long as a specified condition is true, and then skips the remaining values.
62-
*
63+
*
6364
* @param items
64-
* @param predicate a function to test each element for a condition; the second parameter of the function represents the index of the source element; otherwise, false.
65+
* @param predicate
66+
* a function to test each element for a condition; the second parameter of the function represents the index of the source element; otherwise, false.
6567
* @return
6668
*/
6769
public static <T> Func1<Observer<T>, Subscription> takeWhileWithIndex(final Observable<T> items, final Func2<T, Integer, Boolean> predicate) {
@@ -96,7 +98,6 @@ public Boolean call(T input, Integer index) {
9698
};
9799
}
98100

99-
100101
/**
101102
* This class is NOT thread-safe if invoked and referenced multiple times. In other words, don't subscribe to it multiple times from different threads.
102103
* <p>
@@ -105,7 +106,7 @@ public Boolean call(T input, Integer index) {
105106
* This should all be fine as long as it's kept as a private class and a new instance created from static factory method above.
106107
* <p>
107108
* Note how the take() factory method above protects us from a single instance being exposed with the Observable wrapper handling the subscribe flow.
108-
*
109+
*
109110
* @param <T>
110111
*/
111112
private static class TakeWhile<T> implements Func1<Observer<T>, Subscription> {
@@ -119,7 +120,6 @@ private TakeWhile(Observable<T> items, Func2<T, Integer, Boolean> predicate) {
119120
this.predicate = predicate;
120121
}
121122

122-
123123
@Override
124124
public Subscription call(Observer<T> observer) {
125125
return subscription.wrap(items.subscribe(new ItemObserver(observer)));
@@ -158,8 +158,6 @@ public void onNext(T args) {
158158

159159
public static class UnitTest {
160160

161-
162-
163161
@Test
164162
public void testTakeWhile1() {
165163
Observable<Integer> w = Observable.toObservable(1, 2, 3);

rxjava-core/src/main/java/rx/operators/OperationTakeLast.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2013 Netflix, Inc.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,21 +15,21 @@
1515
*/
1616
package rx.operators;
1717

18+
import static org.mockito.Matchers.*;
19+
import static org.mockito.Mockito.*;
20+
21+
import java.util.Iterator;
22+
import java.util.concurrent.LinkedBlockingDeque;
23+
1824
import org.junit.Test;
1925
import org.mockito.InOrder;
26+
2027
import rx.Observable;
2128
import rx.Observer;
2229
import rx.Subscription;
2330
import rx.util.AtomicObservableSubscription;
2431
import rx.util.functions.Func1;
2532

26-
import java.util.Iterator;
27-
import java.util.concurrent.LinkedBlockingDeque;
28-
import java.util.concurrent.atomic.AtomicInteger;
29-
30-
import static org.mockito.Matchers.any;
31-
import static org.mockito.Mockito.*;
32-
3333
/**
3434
* Returns a specified number of contiguous elements from the end of an observable sequence.
3535
*/

rxjava-core/src/main/java/rx/operators/OperatorGroupBy.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2013 Netflix, Inc.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,19 +15,24 @@
1515
*/
1616
package rx.operators;
1717

18+
import static org.junit.Assert.*;
19+
20+
import java.util.ArrayList;
21+
import java.util.Arrays;
22+
import java.util.HashMap;
23+
import java.util.List;
24+
import java.util.Map;
25+
import java.util.concurrent.ConcurrentHashMap;
26+
1827
import org.junit.Test;
28+
1929
import rx.Observable;
2030
import rx.Observer;
2131
import rx.Subscription;
2232
import rx.observables.GroupedObservable;
2333
import rx.util.functions.Func1;
2434
import rx.util.functions.Functions;
2535

26-
import java.util.*;
27-
import java.util.concurrent.ConcurrentHashMap;
28-
29-
import static org.junit.Assert.*;
30-
3136
public final class OperatorGroupBy {
3237

3338
public static <K, T, R> Func1<Observer<GroupedObservable<K, R>>, Subscription> groupBy(Observable<T> source, final Func1<T, K> keySelector, final Func1<T, R> elementSelector) {
@@ -46,7 +51,7 @@ public KeyValue<K, R> call(T t) {
4651
}
4752

4853
public static <K, T> Func1<Observer<GroupedObservable<K, T>>, Subscription> groupBy(Observable<T> source, final Func1<T, K> keySelector) {
49-
return groupBy(source, keySelector, Functions.<T>identity());
54+
return groupBy(source, keySelector, Functions.<T> identity());
5055
}
5156

5257
private static class GroupBy<K, V> implements Func1<Observer<GroupedObservable<K, V>>, Subscription> {
@@ -57,7 +62,6 @@ private GroupBy(Observable<KeyValue<K, V>> source) {
5762
this.source = source;
5863
}
5964

60-
6165
@Override
6266
public Subscription call(final Observer<GroupedObservable<K, V>> observer) {
6367

rxjava-core/src/main/java/rx/operators/OperatorTakeUntil.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
22
* Copyright 2013 Netflix, Inc.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
1212
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,23 +15,28 @@
1515
*/
1616
package rx.operators;
1717

18+
import static org.mockito.Mockito.*;
19+
1820
import org.junit.Test;
21+
1922
import rx.Observable;
2023
import rx.Observer;
2124
import rx.Subscription;
2225
import rx.util.functions.Func1;
2326

24-
import static org.mockito.Mockito.*;
25-
2627
public class OperatorTakeUntil {
2728

2829
/**
2930
* Returns the values from the source observable sequence until the other observable sequence produces a value.
30-
*
31-
* @param source the source sequence to propagate elements for.
32-
* @param other the observable sequence that terminates propagation of elements of the source sequence.
33-
* @param <T> the type of source.
34-
* @param <E> the other type.
31+
*
32+
* @param source
33+
* the source sequence to propagate elements for.
34+
* @param other
35+
* the observable sequence that terminates propagation of elements of the source sequence.
36+
* @param <T>
37+
* the type of source.
38+
* @param <E>
39+
* the other type.
3540
* @return An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.
3641
*/
3742
public static <T, E> Observable<T> takeUntil(final Observable<T> source, final Observable<E> other) {
@@ -83,7 +88,7 @@ public Subscription call(final Observer<Notification<T>> notificationObserver) {
8388
return sequence.subscribe(new Observer<T>() {
8489
@Override
8590
public void onCompleted() {
86-
notificationObserver.onNext(Notification.<T>halt());
91+
notificationObserver.onNext(Notification.<T> halt());
8792
}
8893

8994
@Override
@@ -121,7 +126,7 @@ public void onError(Exception e) {
121126

122127
@Override
123128
public void onNext(E args) {
124-
notificationObserver.onNext(Notification.<T>halt());
129+
notificationObserver.onNext(Notification.<T> halt());
125130
}
126131
});
127132
}

0 commit comments

Comments
 (0)