179 lines
4.9 KiB
Java
179 lines
4.9 KiB
Java
package io.reactivex.internal.util;
|
|
|
|
import io.reactivex.Observer;
|
|
import io.reactivex.disposables.Disposable;
|
|
import io.reactivex.internal.functions.ObjectHelper;
|
|
import java.io.Serializable;
|
|
import org.reactivestreams.Subscriber;
|
|
import org.reactivestreams.Subscription;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public enum NotificationLite {
|
|
COMPLETE;
|
|
|
|
static final class DisposableNotification implements Serializable {
|
|
final Disposable a;
|
|
|
|
DisposableNotification(Disposable disposable) {
|
|
this.a = disposable;
|
|
}
|
|
|
|
public String toString() {
|
|
return "NotificationLite.Disposable[" + this.a + "]";
|
|
}
|
|
}
|
|
|
|
static final class ErrorNotification implements Serializable {
|
|
final Throwable a;
|
|
|
|
ErrorNotification(Throwable th) {
|
|
this.a = th;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof ErrorNotification) {
|
|
return ObjectHelper.a(this.a, ((ErrorNotification) obj).a);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.a.hashCode();
|
|
}
|
|
|
|
public String toString() {
|
|
return "NotificationLite.Error[" + this.a + "]";
|
|
}
|
|
}
|
|
|
|
static final class SubscriptionNotification implements Serializable {
|
|
final Subscription a;
|
|
|
|
SubscriptionNotification(Subscription subscription) {
|
|
this.a = subscription;
|
|
}
|
|
|
|
public String toString() {
|
|
return "NotificationLite.Subscription[" + this.a + "]";
|
|
}
|
|
}
|
|
|
|
public static <T> boolean accept(Object obj, Subscriber<? super T> subscriber) {
|
|
if (obj == COMPLETE) {
|
|
subscriber.onComplete();
|
|
return true;
|
|
}
|
|
if (obj instanceof ErrorNotification) {
|
|
subscriber.onError(((ErrorNotification) obj).a);
|
|
return true;
|
|
}
|
|
subscriber.onNext(obj);
|
|
return false;
|
|
}
|
|
|
|
public static <T> boolean acceptFull(Object obj, Subscriber<? super T> subscriber) {
|
|
if (obj == COMPLETE) {
|
|
subscriber.onComplete();
|
|
return true;
|
|
}
|
|
if (obj instanceof ErrorNotification) {
|
|
subscriber.onError(((ErrorNotification) obj).a);
|
|
return true;
|
|
}
|
|
if (obj instanceof SubscriptionNotification) {
|
|
subscriber.onSubscribe(((SubscriptionNotification) obj).a);
|
|
return false;
|
|
}
|
|
subscriber.onNext(obj);
|
|
return false;
|
|
}
|
|
|
|
public static Object complete() {
|
|
return COMPLETE;
|
|
}
|
|
|
|
public static Object disposable(Disposable disposable) {
|
|
return new DisposableNotification(disposable);
|
|
}
|
|
|
|
public static Object error(Throwable th) {
|
|
return new ErrorNotification(th);
|
|
}
|
|
|
|
public static Disposable getDisposable(Object obj) {
|
|
return ((DisposableNotification) obj).a;
|
|
}
|
|
|
|
public static Throwable getError(Object obj) {
|
|
return ((ErrorNotification) obj).a;
|
|
}
|
|
|
|
public static Subscription getSubscription(Object obj) {
|
|
return ((SubscriptionNotification) obj).a;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static <T> T getValue(Object obj) {
|
|
return obj;
|
|
}
|
|
|
|
public static boolean isComplete(Object obj) {
|
|
return obj == COMPLETE;
|
|
}
|
|
|
|
public static boolean isDisposable(Object obj) {
|
|
return obj instanceof DisposableNotification;
|
|
}
|
|
|
|
public static boolean isError(Object obj) {
|
|
return obj instanceof ErrorNotification;
|
|
}
|
|
|
|
public static boolean isSubscription(Object obj) {
|
|
return obj instanceof SubscriptionNotification;
|
|
}
|
|
|
|
public static <T> Object next(T t) {
|
|
return t;
|
|
}
|
|
|
|
public static Object subscription(Subscription subscription) {
|
|
return new SubscriptionNotification(subscription);
|
|
}
|
|
|
|
@Override // java.lang.Enum
|
|
public String toString() {
|
|
return "NotificationLite.Complete";
|
|
}
|
|
|
|
public static <T> boolean accept(Object obj, Observer<? super T> observer) {
|
|
if (obj == COMPLETE) {
|
|
observer.onComplete();
|
|
return true;
|
|
}
|
|
if (obj instanceof ErrorNotification) {
|
|
observer.onError(((ErrorNotification) obj).a);
|
|
return true;
|
|
}
|
|
observer.onNext(obj);
|
|
return false;
|
|
}
|
|
|
|
public static <T> boolean acceptFull(Object obj, Observer<? super T> observer) {
|
|
if (obj == COMPLETE) {
|
|
observer.onComplete();
|
|
return true;
|
|
}
|
|
if (obj instanceof ErrorNotification) {
|
|
observer.onError(((ErrorNotification) obj).a);
|
|
return true;
|
|
}
|
|
if (obj instanceof DisposableNotification) {
|
|
observer.onSubscribe(((DisposableNotification) obj).a);
|
|
return false;
|
|
}
|
|
observer.onNext(obj);
|
|
return false;
|
|
}
|
|
}
|