@@ -71,17 +71,16 @@ class CompletenessTest extends JUnitSuite {
71
71
" all(Func1[_ >: T, Boolean])" -> " forall(T => Boolean)" ,
72
72
" buffer(Long, Long, TimeUnit)" -> " buffer(Duration, Duration)" ,
73
73
" buffer(Long, Long, TimeUnit, Scheduler)" -> " buffer(Duration, Duration, Scheduler)" ,
74
- " contains(T )" -> " contains(Any )" ,
74
+ " contains(Any )" -> " contains(U )" ,
75
75
" count()" -> " length" ,
76
76
" dematerialize()" -> " dematerialize(<:<[Observable[T], Observable[Notification[U]]])" ,
77
- " elementAt(Int)" -> " [use `.drop(index).first`]" ,
78
- " elementAtOrDefault(Int, T)" -> " [use `.drop(index).firstOrElse(default)`]" ,
77
+ " elementAtOrDefault(Int, T)" -> " elementAtOrDefault(Int, U)" ,
79
78
" first(Func1[_ >: T, Boolean])" -> commentForFirstWithPredicate,
80
79
" firstOrDefault(T)" -> " firstOrElse(=> U)" ,
81
- " firstOrDefault(Func1[_ >: T, Boolean], T )" -> " [use `.filter(condition).firstOrElse(default)`]" ,
80
+ " firstOrDefault(T, Func1[_ >: T, Boolean])" -> " [use `.filter(condition).firstOrElse(default)`]" ,
82
81
" groupBy(Func1[_ >: T, _ <: K], Func1[_ >: T, _ <: R])" -> " [use `groupBy` and `map`]" ,
82
+ " groupByUntil(Func1[_ >: T, _ <: TKey], Func1[_ >: GroupedObservable[TKey, T], _ <: Observable[_ <: TDuration]])" -> " groupByUntil(T => K, (K, Observable[T]) => Observable[Any])" ,
83
83
" lift(Operator[_ <: R, _ >: T])" -> " lift(Subscriber[R] => Subscriber[T])" ,
84
- " mapMany(Func1[_ >: T, _ <: Observable[_ <: R]])" -> " flatMap(T => Observable[R])" ,
85
84
" mapWithIndex(Func2[_ >: T, Integer, _ <: R])" -> " [combine `zipWithIndex` with `map` or with a for comprehension]" ,
86
85
" onErrorResumeNext(Func1[Throwable, _ <: Observable[_ <: T]])" -> " onErrorResumeNext(Throwable => Observable[U])" ,
87
86
" onErrorResumeNext(Observable[_ <: T])" -> " onErrorResumeNext(Observable[U])" ,
@@ -95,6 +94,7 @@ class CompletenessTest extends JUnitSuite {
95
94
" publish(Func1[_ >: Observable[T], _ <: Observable[R]], T)" -> " publish(Observable[U] => Observable[R], U)" ,
96
95
" reduce(Func2[T, T, T])" -> " reduce((U, U) => U)" ,
97
96
" reduce(R, Func2[R, _ >: T, R])" -> " foldLeft(R)((R, T) => R)" ,
97
+ " repeat()" -> " repeat()" ,
98
98
" retry()" -> " retry()" ,
99
99
" scan(Func2[T, T, T])" -> unnecessary,
100
100
" scan(R, Func2[R, _ >: T, R])" -> " scan(R)((R, T) => R)" ,
@@ -113,8 +113,8 @@ class CompletenessTest extends JUnitSuite {
113
113
" skipLast(Int)" -> " dropRight(Int)" ,
114
114
" skipLast(Long, TimeUnit)" -> " dropRight(Duration)" ,
115
115
" skipLast(Long, TimeUnit, Scheduler)" -> " dropRight(Duration, Scheduler)" ,
116
- " takeFirst ()" -> " first " ,
117
- " takeFirst(Func1[_ >: T, Boolean])" -> commentForFirstWithPredicate ,
116
+ " subscribe ()" -> " subscribe() " ,
117
+ " takeFirst(Func1[_ >: T, Boolean])" -> " [use `filter(condition).take(1)`] " ,
118
118
" takeLast(Int)" -> " takeRight(Int)" ,
119
119
" takeWhileWithIndex(Func2[_ >: T, _ >: Integer, Boolean])" -> " [use `.zipWithIndex.takeWhile{case (elem, index) => condition}.map(_._1)`]" ,
120
120
" timeout(Func0[_ <: Observable[U]], Func1[_ >: T, _ <: Observable[V]], Observable[_ <: T])" -> " timeout(() => Observable[U], T => Observable[V], Observable[O])" ,
@@ -126,7 +126,6 @@ class CompletenessTest extends JUnitSuite {
126
126
" toList()" -> " toSeq" ,
127
127
" toSortedList()" -> " [Sorting is already done in Scala's collection library, use `.toSeq.map(_.sorted)`]" ,
128
128
" toSortedList(Func2[_ >: T, _ >: T, Integer])" -> " [Sorting is already done in Scala's collection library, use `.toSeq.map(_.sortWith(f))`]" ,
129
- " where(Func1[_ >: T, Boolean])" -> " filter(T => Boolean)" ,
130
129
" window(Long, Long, TimeUnit)" -> " window(Duration, Duration)" ,
131
130
" window(Long, Long, TimeUnit, Scheduler)" -> " window(Duration, Duration, Scheduler)" ,
132
131
@@ -135,32 +134,28 @@ class CompletenessTest extends JUnitSuite {
135
134
" averageDoubles(Observable[Double])" -> averageProblem,
136
135
" averageFloats(Observable[Float])" -> averageProblem,
137
136
" averageLongs(Observable[Long])" -> averageProblem,
138
- " create(OnSubscribeFunc[T])" -> " apply(Observer[T] => Subscription)" ,
137
+ " create(OnSubscribeFunc[T])" -> " create(Observer[T] => Subscription)" ,
138
+ " create(OnSubscribe[T])" -> " apply(Subscriber[T] => Unit)" ,
139
139
" combineLatest(Observable[_ <: T1], Observable[_ <: T2], Func2[_ >: T1, _ >: T2, _ <: R])" -> " combineLatest(Observable[U])" ,
140
140
" concat(Observable[_ <: Observable[_ <: T]])" -> " concat(<:<[Observable[T], Observable[Observable[U]]])" ,
141
141
" defer(Func0[_ <: Observable[_ <: T]])" -> " defer(=> Observable[T])" ,
142
- " empty()" -> " apply(T*)" ,
143
- " error(Throwable)" -> " apply(Throwable)" ,
144
- " from(Array[T])" -> " apply(T*)" ,
145
- " from(Iterable[_ <: T])" -> " apply(T*)" ,
142
+ " from(Array[T])" -> " [use `items(T*)`]" ,
143
+ " from(Iterable[_ <: T])" -> " from(Iterable[T])" ,
146
144
" from(Future[_ <: T])" -> fromFuture,
147
145
" from(Future[_ <: T], Long, TimeUnit)" -> fromFuture,
148
146
" from(Future[_ <: T], Scheduler)" -> fromFuture,
149
- " just(T)" -> " apply(T*)" ,
147
+ " just(T)" -> " [use `items(T*)`]" ,
148
+ " just(T, Scheduler)" -> " [use `items(T*).subscribeOn(scheduler)`]" ,
150
149
" merge(Observable[_ <: T], Observable[_ <: T])" -> " merge(Observable[U])" ,
151
150
" merge(Observable[_ <: Observable[_ <: T]])" -> " flatten(<:<[Observable[T], Observable[Observable[U]]])" ,
152
151
" mergeDelayError(Observable[_ <: T], Observable[_ <: T])" -> " mergeDelayError(Observable[U])" ,
153
152
" mergeDelayError(Observable[_ <: Observable[_ <: T]])" -> " flattenDelayError(<:<[Observable[T], Observable[Observable[U]]])" ,
154
- " range(Int, Int)" -> " apply(Range)" ,
155
- " repeat()" -> " repeat()" ,
156
- " retry()" -> " retry()" ,
157
- " sequenceEqual(Observable[_ <: T], Observable[_ <: T])" -> " [use `(first zip second) map (p => p._1 == p._2)`]" ,
158
- " sequenceEqual(Observable[_ <: T], Observable[_ <: T], Func2[_ >: T, _ >: T, Boolean])" -> " [use `(first zip second) map (p => equality(p._1, p._2))`]" ,
153
+ " range(Int, Int)" -> " [use `(start until (start + count)).toObservable` instead of `range(start, count)`]" ,
154
+ " range(Int, Int, Scheduler)" -> " [use `(start until (start + count)).toObservable.subscribeOn(scheduler)` instead of `range(start, count, scheduler)`]`]" ,
159
155
" sum(Observable[Integer])" -> " sum(Numeric[U])" ,
160
156
" sumDoubles(Observable[Double])" -> " sum(Numeric[U])" ,
161
157
" sumFloats(Observable[Float])" -> " sum(Numeric[U])" ,
162
158
" sumLongs(Observable[Long])" -> " sum(Numeric[U])" ,
163
- " synchronize(Observable[T])" -> " synchronize" ,
164
159
" switchDo(Observable[_ <: Observable[_ <: T]])" -> deprecated,
165
160
" switchOnNext(Observable[_ <: Observable[_ <: T]])" -> " switch(<:<[Observable[T], Observable[Observable[U]]])" ,
166
161
" zip(Observable[_ <: T1], Observable[_ <: T2], Func2[_ >: T1, _ >: T2, _ <: R])" -> " [use instance method `zip` and `map`]" ,
@@ -174,7 +169,7 @@ class CompletenessTest extends JUnitSuite {
174
169
" concat(" + _ + " )" -> " [unnecessary because we can use `++` instead or `Observable(o1, o2, ...).concat`]"
175
170
).drop(1 ).toMap ++ List .iterate(" T" , 10 )(s => s + " , T" ).map(
176
171
// all 10 overloads of from:
177
- " from(" + _ + " )" -> " apply (T*)"
172
+ " from(" + _ + " )" -> " [use `items (T*)`] "
178
173
).toMap ++ (3 to 9 ).map(i => {
179
174
// zip3-9:
180
175
val obsArgs = (1 to i).map(j => s " Observable[_ <: T $j], " ).mkString(" " )
@@ -216,6 +211,8 @@ class CompletenessTest extends JUnitSuite {
216
211
// TODO how can we filter out instance methods which were put into companion because
217
212
// of extends AnyVal in a way which does not depend on implementation-chosen name '$extension'?
218
213
.filter(! _.contains(" $extension" ))
214
+ // `access$000` is public. How to distinguish it from others without hard-code?
215
+ .filter(! _.contains(" access$000" ))
219
216
}
220
217
221
218
// also applicable for Java types
@@ -373,7 +370,10 @@ class CompletenessTest extends JUnitSuite {
373
370
def escape (s : String ) = s.replaceAllLiterally(" [" , " <" ).replaceAllLiterally(" ]" , " >" )
374
371
375
372
println("""
376
- ## Comparison of Scala Observable and Java Observable
373
+ ---
374
+ layout: comparison
375
+ title: Comparison of Scala Observable and Java Observable
376
+ ---
377
377
378
378
Note:
379
379
* This table contains both static methods and instance methods.
0 commit comments