Skip to content

Commit d7a4651

Browse files
authored
[Reactive] Reorganize methods, remove Single.mapMany (helidon-io#1603)
* [Reactive] Reorganize methods, remove Single.mapMany * [Reactive] Change map(Mapper) to map(Function) * Fix copyright year
1 parent ab64814 commit d7a4651

19 files changed

Lines changed: 774 additions & 761 deletions

File tree

common/reactive/src/main/java/io/helidon/common/reactive/Multi.java

Lines changed: 473 additions & 460 deletions
Large diffs are not rendered by default.

common/reactive/src/main/java/io/helidon/common/reactive/MultiMapperPublisher.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.Objects;
1919
import java.util.concurrent.Flow;
20+
import java.util.function.Function;
2021

2122
import io.helidon.common.mapper.Mapper;
2223

@@ -29,9 +30,9 @@ final class MultiMapperPublisher<T, R> implements Multi<R> {
2930

3031
private final Flow.Publisher<T> source;
3132

32-
private final Mapper<? super T, ? extends R> mapper;
33+
private final Function<? super T, ? extends R> mapper;
3334

34-
MultiMapperPublisher(Flow.Publisher<T> source, Mapper<? super T, ? extends R> mapper) {
35+
MultiMapperPublisher(Flow.Publisher<T> source, Function<? super T, ? extends R> mapper) {
3536
this.source = source;
3637
this.mapper = mapper;
3738
}
@@ -45,11 +46,11 @@ static final class MapperSubscriber<T, R> implements Flow.Subscriber<T>, Flow.Su
4546

4647
private final Flow.Subscriber<? super R> downstream;
4748

48-
private final Mapper<? super T, ? extends R> mapper;
49+
private final Function<? super T, ? extends R> mapper;
4950

5051
private Flow.Subscription upstream;
5152

52-
MapperSubscriber(Flow.Subscriber<? super R> downstream, Mapper<? super T, ? extends R> mapper) {
53+
MapperSubscriber(Flow.Subscriber<? super R> downstream, Function<? super T, ? extends R> mapper) {
5354
this.downstream = downstream;
5455
this.mapper = mapper;
5556
}
@@ -69,7 +70,7 @@ public void onNext(T item) {
6970
R result;
7071

7172
try {
72-
result = Objects.requireNonNull(mapper.map(item), "The mapper returned a null value.");
73+
result = Objects.requireNonNull(mapper.apply(item), "The mapper returned a null value.");
7374
} catch (Throwable ex) {
7475
s.cancel();
7576
onError(ex);

0 commit comments

Comments
 (0)