Debian Codegraph @

src/main/java/io/reactivex/rxjava3/internal/util/EmptyComponent.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.util;
15
16 import org.reactivestreams.*;
17
18 import io.reactivex.rxjava3.core.*;
19 import io.reactivex.rxjava3.disposables.Disposable;
20 import io.reactivex.rxjava3.plugins.RxJavaPlugins;
21
22 /**
23 * Singleton implementing many interfaces as empty.
24 */
25 public enum EmptyComponent implements FlowableSubscriber<Object>, Observer<Object>, MaybeObserver<Object>,
26 SingleObserver<Object>, CompletableObserver, Subscription, Disposable {
27 INSTANCE;
28
29 @SuppressWarnings("unchecked")
30 public static <T> Subscriber<T> asSubscriber() {
31 return (Subscriber<T>)INSTANCE;
32 }
33
34 @SuppressWarnings("unchecked")
35 public static <T> Observer<T> asObserver() {
36 return (Observer<T>)INSTANCE;
37 }
38
39 @Override
40 public void dispose() {
41 // deliberately no-op
42 }
43
44 @Override
45 public boolean isDisposed() {
46 return true;
47 }
48
49 @Override
50 public void request(long n) {
51 // deliberately no-op
52 }
53
54 @Override
55 public void cancel() {
56 // deliberately no-op
57 }
58
59 @Override
60 public void onSubscribe(Disposable d) {
61 d.dispose();
62 }
63
64 @Override
65 public void onSubscribe(Subscription s) {
66 s.cancel();
67 }
68
69 @Override
70 public void onNext(Object t) {
71 // deliberately no-op
72 }
73
74 @Override
75 public void onError(Throwable t) {
76 RxJavaPlugins.onError(t);
77 }
78
79 @Override
80 public void onComplete() {
81 // deliberately no-op
82 }
83
84 @Override
85 public void onSuccess(Object value) {
86 // deliberately no-op
87 }
88 }