Debian Codegraph @

src/main/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableMaterialize.java

raw
1 /*
2 * Copyright (c) 2016-present, RxJava Contributors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11 * the License for the specific language governing permissions and limitations under the License.
12 */
13
14 package io.reactivex.rxjava3.internal.operators.flowable;
15
16 import org.reactivestreams.Subscriber;
17
18 import io.reactivex.rxjava3.core.*;
19 import io.reactivex.rxjava3.internal.subscribers.SinglePostCompleteSubscriber;
20 import io.reactivex.rxjava3.plugins.RxJavaPlugins;
21
22 public final class FlowableMaterialize<T> extends AbstractFlowableWithUpstream<T, Notification<T>> {
23
24 public FlowableMaterialize(Flowable<T> source) {
25 super(source);
26 }
27
28 @Override
29 protected void subscribeActual(Subscriber<? super Notification<T>> s) {
30 source.subscribe(new MaterializeSubscriber<>(s));
31 }
32
33 static final class MaterializeSubscriber<T> extends SinglePostCompleteSubscriber<T, Notification<T>> {
34
35 private static final long serialVersionUID = -3740826063558713822L;
36
37 MaterializeSubscriber(Subscriber<? super Notification<T>> downstream) {
38 super(downstream);
39 }
40
41 @Override
42 public void onNext(T t) {
43 produced++;
44 downstream.onNext(Notification.createOnNext(t));
45 }
46
47 @Override
48 public void onError(Throwable t) {
49 complete(Notification.createOnError(t));
50 }
51
52 @Override
53 public void onComplete() {
54 complete(Notification.createOnComplete());
55 }
56
57 @Override
58 protected void onDrop(Notification<T> n) {
59 if (n.isOnError()) {
60 RxJavaPlugins.onError(n.getError());
61 }
62 }
63 }
64 }