Skip to content

Commit 6bb6a00

Browse files
committed
Simplify MakesStepper design
1 parent 315c6ad commit 6bb6a00

16 files changed

+106
-235
lines changed

src/main/scala/scala/compat/java8/StreamConverters.scala

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,104 +16,104 @@ trait PrimitiveStreamUnboxer[A, S] {
1616

1717
trait Priority5StreamConverters {
1818
// Note--conversion is only to make sure implicit conversion priority is lower than alternatives.
19-
implicit class EnrichScalaCollectionWithSeqStream[A, CC](cc: CC)(implicit steppize: CC => MakesAnySeqStepper[A])
19+
implicit class EnrichScalaCollectionWithSeqStream[A, CC](cc: CC)(implicit steppize: CC => MakesStepper[AnyStepper[A]])
2020
extends MakesSequentialStream[A, Stream[A]] {
2121
def seqStream: Stream[A] = StreamSupport.stream(steppize(cc).stepper, false)
2222
}
23-
implicit class EnrichScalaCollectionWithKeySeqStream[K, CC](cc: CC)(implicit steppize: CC => MakesAnyKeySeqStepper[K]) {
23+
implicit class EnrichScalaCollectionWithKeySeqStream[K, CC](cc: CC)(implicit steppize: CC => MakesKeyStepper[AnyStepper[K]]) {
2424
def seqKeyStream: Stream[K] = StreamSupport.stream(steppize(cc).keyStepper, false)
2525
}
26-
implicit class EnrichScalaCollectionWithValueSeqStream[V, CC](cc: CC)(implicit steppize: CC => MakesAnyValueSeqStepper[V]) {
26+
implicit class EnrichScalaCollectionWithValueSeqStream[V, CC](cc: CC)(implicit steppize: CC => MakesValueStepper[AnyStepper[V]]) {
2727
def seqValueStream: Stream[V] = StreamSupport.stream(steppize(cc).valueStepper, false)
2828
}
2929
}
3030

3131
trait Priority4StreamConverters extends Priority5StreamConverters {
32-
implicit class EnrichScalaCollectionWithSeqDoubleStream[CC](cc: CC)(implicit steppize: CC => MakesDoubleSeqStepper)
32+
implicit class EnrichScalaCollectionWithSeqDoubleStream[CC](cc: CC)(implicit steppize: CC => MakesStepper[DoubleStepper])
3333
extends MakesSequentialStream[java.lang.Double, DoubleStream] {
3434
def seqStream: DoubleStream = StreamSupport.doubleStream(steppize(cc).stepper, false)
3535
}
36-
implicit class EnrichScalaCollectionWithSeqIntStream[CC](cc: CC)(implicit steppize: CC => MakesIntSeqStepper)
36+
implicit class EnrichScalaCollectionWithSeqIntStream[CC](cc: CC)(implicit steppize: CC => MakesStepper[IntStepper])
3737
extends MakesSequentialStream[java.lang.Integer, IntStream] {
3838
def seqStream: IntStream = StreamSupport.intStream(steppize(cc).stepper, false)
3939
}
40-
implicit class EnrichScalaCollectionWithSeqLongStream[CC](cc: CC)(implicit steppize: CC => MakesLongSeqStepper)
40+
implicit class EnrichScalaCollectionWithSeqLongStream[CC](cc: CC)(implicit steppize: CC => MakesStepper[LongStepper])
4141
extends MakesSequentialStream[java.lang.Long, LongStream] {
4242
def seqStream: LongStream = StreamSupport.longStream(steppize(cc).stepper, false)
4343
}
44-
implicit class EnrichScalaCollectionWithSeqDoubleKeyStream[CC](cc: CC)(implicit steppize: CC => MakesDoubleKeySeqStepper) {
44+
implicit class EnrichScalaCollectionWithSeqDoubleKeyStream[CC](cc: CC)(implicit steppize: CC => MakesKeyStepper[DoubleStepper]) {
4545
def seqKeyStream: DoubleStream = StreamSupport.doubleStream(steppize(cc).keyStepper, false)
4646
}
47-
implicit class EnrichScalaCollectionWithSeqIntKeyStream[CC](cc: CC)(implicit steppize: CC => MakesIntKeySeqStepper) {
47+
implicit class EnrichScalaCollectionWithSeqIntKeyStream[CC](cc: CC)(implicit steppize: CC => MakesKeyStepper[IntStepper]) {
4848
def seqKeyStream: IntStream = StreamSupport.intStream(steppize(cc).keyStepper, false)
4949
}
50-
implicit class EnrichScalaCollectionWithSeqLongKeyStream[CC](cc: CC)(implicit steppize: CC => MakesLongKeySeqStepper) {
50+
implicit class EnrichScalaCollectionWithSeqLongKeyStream[CC](cc: CC)(implicit steppize: CC => MakesKeyStepper[LongStepper]) {
5151
def seqKeyStream: LongStream = StreamSupport.longStream(steppize(cc).keyStepper, false)
5252
}
53-
implicit class EnrichScalaCollectionWithSeqDoubleValueStream[CC](cc: CC)(implicit steppize: CC => MakesDoubleValueSeqStepper) {
53+
implicit class EnrichScalaCollectionWithSeqDoubleValueStream[CC](cc: CC)(implicit steppize: CC => MakesValueStepper[DoubleStepper]) {
5454
def seqValueStream: DoubleStream = StreamSupport.doubleStream(steppize(cc).valueStepper, false)
5555
}
56-
implicit class EnrichScalaCollectionWithSeqIntValueStream[CC](cc: CC)(implicit steppize: CC => MakesIntValueSeqStepper) {
56+
implicit class EnrichScalaCollectionWithSeqIntValueStream[CC](cc: CC)(implicit steppize: CC => MakesValueStepper[IntStepper]) {
5757
def seqValueStream: IntStream = StreamSupport.intStream(steppize(cc).valueStepper, false)
5858
}
59-
implicit class EnrichScalaCollectionWithSeqLongValueStream[CC](cc: CC)(implicit steppize: CC => MakesLongValueSeqStepper) {
59+
implicit class EnrichScalaCollectionWithSeqLongValueStream[CC](cc: CC)(implicit steppize: CC => MakesValueStepper[LongStepper]) {
6060
def seqValueStream: LongStream = StreamSupport.longStream(steppize(cc).valueStepper, false)
6161
}
6262
}
6363

6464
trait Priority3StreamConverters extends Priority4StreamConverters {
65-
implicit class EnrichAnySteppableWithStream[A, CC](cc: CC)(implicit steppize: CC => MakesAnyStepper[A])
65+
implicit class EnrichAnySteppableWithStream[A, CC](cc: CC)(implicit steppize: CC => MakesStepper[AnyStepper[A] with EfficientSubstep])
6666
extends MakesSequentialStream[A, Stream[A]] with MakesParallelStream[A, Stream[A]] {
6767
def seqStream: Stream[A] = StreamSupport.stream(steppize(cc).stepper, false)
6868
def parStream: Stream[A] = StreamSupport.stream(steppize(cc).stepper.anticipateParallelism, true)
6969
}
70-
implicit class EnrichAnyKeySteppableWithStream[K, CC](cc: CC)(implicit steppize: CC => MakesAnyKeyStepper[K]) {
70+
implicit class EnrichAnyKeySteppableWithStream[K, CC](cc: CC)(implicit steppize: CC => MakesKeyStepper[AnyStepper[K] with EfficientSubstep]) {
7171
def seqKeyStream: Stream[K] = StreamSupport.stream(steppize(cc).keyStepper, false)
7272
def parKeyStream: Stream[K] = StreamSupport.stream(steppize(cc).keyStepper.anticipateParallelism, true)
7373
}
74-
implicit class EnrichAnyValueSteppableWithStream[V, CC](cc: CC)(implicit steppize: CC => MakesAnyValueStepper[V]) {
74+
implicit class EnrichAnyValueSteppableWithStream[V, CC](cc: CC)(implicit steppize: CC => MakesValueStepper[AnyStepper[V] with EfficientSubstep]) {
7575
def seqValueStream: Stream[V] = StreamSupport.stream(steppize(cc).valueStepper, false)
7676
def parValueStream: Stream[V] = StreamSupport.stream(steppize(cc).valueStepper.anticipateParallelism, true)
7777
}
7878
}
7979

8080
trait Priority2StreamConverters extends Priority3StreamConverters {
81-
implicit class EnrichDoubleSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesDoubleStepper)
81+
implicit class EnrichDoubleSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesStepper[DoubleStepper with EfficientSubstep])
8282
extends MakesSequentialStream[java.lang.Double, DoubleStream] with MakesParallelStream[java.lang.Double, DoubleStream] {
8383
def seqStream: DoubleStream = StreamSupport.doubleStream(steppize(cc).stepper, false)
8484
def parStream: DoubleStream = StreamSupport.doubleStream(steppize(cc).stepper.anticipateParallelism, true)
8585
}
86-
implicit class EnrichDoubleKeySteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesDoubleKeyStepper) {
86+
implicit class EnrichDoubleKeySteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesKeyStepper[DoubleStepper with EfficientSubstep]) {
8787
def seqKeyStream: DoubleStream = StreamSupport.doubleStream(steppize(cc).keyStepper, false)
8888
def parKeyStream: DoubleStream = StreamSupport.doubleStream(steppize(cc).keyStepper.anticipateParallelism, true)
8989
}
90-
implicit class EnrichDoubleValueSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesDoubleValueStepper) {
90+
implicit class EnrichDoubleValueSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesValueStepper[DoubleStepper with EfficientSubstep]) {
9191
def seqValueStream: DoubleStream = StreamSupport.doubleStream(steppize(cc).valueStepper, false)
9292
def parValueStream: DoubleStream = StreamSupport.doubleStream(steppize(cc).valueStepper.anticipateParallelism, true)
9393
}
94-
implicit class EnrichIntSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesIntStepper)
94+
implicit class EnrichIntSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesStepper[IntStepper with EfficientSubstep])
9595
extends MakesSequentialStream[java.lang.Integer, IntStream] with MakesParallelStream[java.lang.Integer, IntStream] {
9696
def seqStream: IntStream = StreamSupport.intStream(steppize(cc).stepper, false)
9797
def parStream: IntStream = StreamSupport.intStream(steppize(cc).stepper.anticipateParallelism, true)
9898
}
99-
implicit class EnrichIntKeySteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesIntKeyStepper) {
99+
implicit class EnrichIntKeySteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesKeyStepper[IntStepper with EfficientSubstep]) {
100100
def seqKeyStream: IntStream = StreamSupport.intStream(steppize(cc).keyStepper, false)
101101
def parKeyStream: IntStream = StreamSupport.intStream(steppize(cc).keyStepper.anticipateParallelism, true)
102102
}
103-
implicit class EnrichIntValueSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesIntValueStepper) {
103+
implicit class EnrichIntValueSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesValueStepper[IntStepper with EfficientSubstep]) {
104104
def seqValueStream: IntStream = StreamSupport.intStream(steppize(cc).valueStepper, false)
105105
def parValueStream: IntStream = StreamSupport.intStream(steppize(cc).valueStepper.anticipateParallelism, true)
106106
}
107-
implicit class EnrichLongSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesLongStepper)
107+
implicit class EnrichLongSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesStepper[LongStepper with EfficientSubstep])
108108
extends MakesSequentialStream[java.lang.Long, LongStream] with MakesParallelStream[java.lang.Long, LongStream] {
109109
def seqStream: LongStream = StreamSupport.longStream(steppize(cc).stepper, false)
110110
def parStream: LongStream = StreamSupport.longStream(steppize(cc).stepper.anticipateParallelism, true)
111111
}
112-
implicit class EnrichLongKeySteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesLongKeyStepper) {
112+
implicit class EnrichLongKeySteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesKeyStepper[LongStepper with EfficientSubstep]) {
113113
def seqKeyStream: LongStream = StreamSupport.longStream(steppize(cc).keyStepper, false)
114114
def parKeyStream: LongStream = StreamSupport.longStream(steppize(cc).keyStepper.anticipateParallelism, true)
115115
}
116-
implicit class EnrichLongValueSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesLongValueStepper) {
116+
implicit class EnrichLongValueSteppableWithStream[CC](cc: CC)(implicit steppize: CC => MakesValueStepper[LongStepper with EfficientSubstep]) {
117117
def seqValueStream: LongStream = StreamSupport.longStream(steppize(cc).valueStepper, false)
118118
def parValueStream: LongStream = StreamSupport.longStream(steppize(cc).valueStepper.anticipateParallelism, true)
119119
}

src/main/scala/scala/compat/java8/converterImpl/MakesSteppers.scala

Lines changed: 9 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -15,146 +15,17 @@ trait MakesParallelStream[A, SS <: java.util.stream.BaseStream[A, SS]] extends A
1515
def parStream: SS
1616
}
1717

18-
/** Classes or objects implementing this trait create generic steppers suitable for sequential use. */
19-
trait MakesAnySeqStepper[A] extends Any {
20-
/** Generates a fresh stepper over `A`s suitable for sequential use */
21-
def stepper: AnyStepper[A]
18+
trait MakesStepper[T <: Stepper[_]] extends Any {
19+
/** Generates a fresh stepper of type `T` */
20+
def stepper: T
2221
}
2322

24-
/** Classes or objects implementing this trait create generic steppers for map keys suitable for sequential use. */
25-
trait MakesAnyKeySeqStepper[A] extends Any {
26-
/** Generates a fresh stepper over map keys of type `A` suitable for sequential use */
27-
def keyStepper: AnyStepper[A]
23+
trait MakesKeyStepper[T <: Stepper[_]] extends Any {
24+
/** Generates a fresh stepper of type `T` over map keys */
25+
def keyStepper: T
2826
}
2927

30-
/** Classes or objects implementing this trait create generic steppers for map values suitable for sequential use. */
31-
trait MakesAnyValueSeqStepper[A] extends Any {
32-
/** Generates a fresh stepper over map values of type `A` suitable for sequential use */
33-
def valueStepper: AnyStepper[A]
34-
}
35-
36-
/** Classes or objects implementing this trait create `Double` steppers suitable for sequential use. */
37-
trait MakesDoubleSeqStepper extends Any {
38-
/** Generates a fresh stepper over `Double`s suitable for sequential use */
39-
def stepper: DoubleStepper
40-
}
41-
42-
/** Classes or objects implementing this trait create `Double` steppers for map keys suitable for sequential use. */
43-
trait MakesDoubleKeySeqStepper extends Any {
44-
/** Generates a fresh stepper over map keys of type `Double` suitable for sequential use */
45-
def keyStepper: DoubleStepper
46-
}
47-
48-
/** Classes or objects implementing this trait create `Double` steppers for map values suitable for sequential use. */
49-
trait MakesDoubleValueSeqStepper extends Any {
50-
/** Generates a fresh stepper over map values of type `Double` suitable for sequential use */
51-
def valueStepper: DoubleStepper
52-
}
53-
54-
/** Classes or objects implementing this trait create `Int` steppers suitable for sequential use. */
55-
trait MakesIntSeqStepper extends Any {
56-
/** Generates a fresh stepper over `Int`s suitable for sequential use */
57-
def stepper: IntStepper
58-
}
59-
60-
/** Classes or objects implementing this trait create `Int` steppers for map keys suitable for sequential use. */
61-
trait MakesIntKeySeqStepper extends Any {
62-
/** Generates a fresh stepper over map keys of type `Int` suitable for sequential use */
63-
def keyStepper: IntStepper
64-
}
65-
66-
/** Classes or objects implementing this trait create `Int` steppers for map values suitable for sequential use. */
67-
trait MakesIntValueSeqStepper extends Any {
68-
/** Generates a fresh stepper over map values of type `Int` suitable for sequential use */
69-
def valueStepper: IntStepper
70-
}
71-
72-
/** Classes or objects implementing this trait create `Long` steppers suitable for sequential use. */
73-
trait MakesLongSeqStepper extends Any {
74-
/** Generates a fresh stepper over `Long`s suitable for sequential use */
75-
def stepper: LongStepper
76-
}
77-
78-
/** Classes or objects implementing this trait create `Long` steppers for map keys suitable for sequential use. */
79-
trait MakesLongKeySeqStepper extends Any {
80-
/** Generates a fresh stepper over map keys of type `Long` suitable for sequential use */
81-
def keyStepper: LongStepper
82-
}
83-
84-
/** Classes or objects implementing this trait create `Long` steppers for map values suitable for sequential use. */
85-
trait MakesLongValueSeqStepper extends Any {
86-
/** Generates a fresh stepper over map values of type `Long` suitable for sequential use */
87-
def valueStepper: LongStepper
88-
}
89-
90-
/** Classes or objects implementing this trait create generic steppers suitable for sequential or parallel use. */
91-
trait MakesAnyStepper[A] extends Any {
92-
/** Generates a fresh stepper over `A`s that can be efficiently subdivided */
93-
def stepper: AnyStepper[A] with EfficientSubstep
94-
}
95-
96-
/** Classes or objects implementing this trait create generic steppers for map keys suitable for sequential or parallel use. */
97-
trait MakesAnyKeyStepper[A] extends Any {
98-
/** Generates a fresh stepper over map keys of type `A` that can be efficiently subdivided */
99-
def keyStepper: AnyStepper[A] with EfficientSubstep
100-
}
101-
102-
/** Classes or objects implementing this trait create generic steppers for map values suitable for sequential or parallel use. */
103-
trait MakesAnyValueStepper[A] extends Any {
104-
/** Generates a fresh stepper over map values of type `A` that can be efficiently subdivided */
105-
def valueStepper: AnyStepper[A] with EfficientSubstep
106-
}
107-
108-
/** Classes or objects implementing this trait create `Double` steppers suitable for sequential or parallel use. */
109-
trait MakesDoubleStepper extends Any {
110-
/** Generates a fresh stepper over `Double`s that can be efficiently subdivided */
111-
def stepper: DoubleStepper with EfficientSubstep
112-
}
113-
114-
/** Classes or objects implementing this trait create `Double` steppers for map keys suitable for sequential or parallel use. */
115-
trait MakesDoubleKeyStepper extends Any {
116-
/** Generates a fresh stepper over map keys of type `Double` that can be efficiently subdivided */
117-
def keyStepper: DoubleStepper with EfficientSubstep
118-
}
119-
120-
/** Classes or objects implementing this trait create `Double` steppers for map values suitable for sequential or parallel use. */
121-
trait MakesDoubleValueStepper extends Any {
122-
/** Generates a fresh stepper over map values of type `Double` that can be efficiently subdivided */
123-
def valueStepper: DoubleStepper with EfficientSubstep
124-
}
125-
126-
/** Classes or objects implementing this trait create `Int` steppers suitable for sequential or parallel use. */
127-
trait MakesIntStepper extends Any {
128-
/** Generates a fresh stepper over `Int`s that can be efficiently subdivided */
129-
def stepper: IntStepper with EfficientSubstep
130-
}
131-
132-
/** Classes or objects implementing this trait create `Int` steppers for map keys suitable for sequential or parallel use. */
133-
trait MakesIntKeyStepper extends Any {
134-
/** Generates a fresh stepper over map keys of type `Int` that can be efficiently subdivided */
135-
def keyStepper: IntStepper with EfficientSubstep
136-
}
137-
138-
/** Classes or objects implementing this trait create `Int` steppers for map values suitable for sequential or parallel use. */
139-
trait MakesIntValueStepper extends Any {
140-
/** Generates a fresh stepper over map values of type `Int` that can be efficiently subdivided */
141-
def valueStepper: IntStepper with EfficientSubstep
142-
}
143-
144-
/** Classes or objects implementing this trait create `Long` steppers suitable for sequential or parallel use. */
145-
trait MakesLongStepper extends Any {
146-
/** Generates a fresh stepper over `Long`s that can be efficiently subdivided */
147-
def stepper: LongStepper with EfficientSubstep
148-
}
149-
150-
/** Classes or objects implementing this trait create `Long` steppers for map keys suitable for sequential or parallel use. */
151-
trait MakesLongKeyStepper extends Any {
152-
/** Generates a fresh stepper over map keys of type `Long` that can be efficiently subdivided */
153-
def keyStepper: LongStepper with EfficientSubstep
154-
}
155-
156-
/** Classes or objects implementing this trait create `Long` steppers for map values suitable for sequential or parallel use. */
157-
trait MakesLongValueStepper extends Any {
158-
/** Generates a fresh stepper over map values of type `Long` that can be efficiently subdivided */
159-
def valueStepper: LongStepper with EfficientSubstep
28+
trait MakesValueStepper[T <: Stepper[_]] extends Any {
29+
/** Generates a fresh stepper of type `T` over map values */
30+
def valueStepper: T
16031
}

0 commit comments

Comments
 (0)