Skip to content

Commit

Permalink
[Reactive] Reorganize methods, remove Single.mapMany (#1603)
Browse files Browse the repository at this point in the history
* [Reactive] Reorganize methods, remove Single.mapMany

* [Reactive] Change map(Mapper) to map(Function)

* Fix copyright year
  • Loading branch information
akarnokd committed Apr 1, 2020
1 parent ab64814 commit d7a4651
Show file tree
Hide file tree
Showing 19 changed files with 774 additions and 761 deletions.
933 changes: 473 additions & 460 deletions common/reactive/src/main/java/io/helidon/common/reactive/Multi.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.Objects;
import java.util.concurrent.Flow;
import java.util.function.Function;

import io.helidon.common.mapper.Mapper;

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

private final Flow.Publisher<T> source;

private final Mapper<? super T, ? extends R> mapper;
private final Function<? super T, ? extends R> mapper;

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

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

private final Mapper<? super T, ? extends R> mapper;
private final Function<? super T, ? extends R> mapper;

private Flow.Subscription upstream;

MapperSubscriber(Flow.Subscriber<? super R> downstream, Mapper<? super T, ? extends R> mapper) {
MapperSubscriber(Flow.Subscriber<? super R> downstream, Function<? super T, ? extends R> mapper) {
this.downstream = downstream;
this.mapper = mapper;
}
Expand All @@ -69,7 +70,7 @@ public void onNext(T item) {
R result;

try {
result = Objects.requireNonNull(mapper.map(item), "The mapper returned a null value.");
result = Objects.requireNonNull(mapper.apply(item), "The mapper returned a null value.");
} catch (Throwable ex) {
s.cancel();
onError(ex);
Expand Down
Loading

0 comments on commit d7a4651

Please sign in to comment.