jimu-decompiled/sources/io/reactivex/internal/functions/Functions.java
2025-05-13 19:24:51 +02:00

729 lines
24 KiB
Java

package io.reactivex.internal.functions;
import io.reactivex.Notification;
import io.reactivex.Scheduler;
import io.reactivex.exceptions.OnErrorNotImplementedException;
import io.reactivex.functions.Action;
import io.reactivex.functions.BiConsumer;
import io.reactivex.functions.BiFunction;
import io.reactivex.functions.BooleanSupplier;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.functions.Function3;
import io.reactivex.functions.Function4;
import io.reactivex.functions.Function5;
import io.reactivex.functions.Function6;
import io.reactivex.functions.Function7;
import io.reactivex.functions.Function8;
import io.reactivex.functions.Function9;
import io.reactivex.functions.LongConsumer;
import io.reactivex.functions.Predicate;
import io.reactivex.plugins.RxJavaPlugins;
import io.reactivex.schedulers.Timed;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import org.reactivestreams.Subscription;
/* loaded from: classes2.dex */
public final class Functions {
static final Function<Object, Object> a = new Identity();
public static final Runnable b = new EmptyRunnable();
public static final Action c = new EmptyAction();
static final Consumer<Object> d = new EmptyConsumer();
public static final Consumer<Throwable> e;
static final Predicate<Object> f;
static final Predicate<Object> g;
static final Callable<Object> h;
static final Comparator<Object> i;
static final class ActionConsumer<T> implements Consumer<T> {
final Action a;
ActionConsumer(Action action) {
this.a = action;
}
@Override // io.reactivex.functions.Consumer
public void accept(T t) throws Exception {
this.a.run();
}
}
static final class Array2Func<T1, T2, R> implements Function<Object[], R> {
final BiFunction<? super T1, ? super T2, ? extends R> a;
Array2Func(BiFunction<? super T1, ? super T2, ? extends R> biFunction) {
this.a = biFunction;
}
@Override // io.reactivex.functions.Function
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public R apply(Object[] objArr) throws Exception {
if (objArr.length == 2) {
return this.a.apply(objArr[0], objArr[1]);
}
throw new IllegalArgumentException("Array of size 2 expected but got " + objArr.length);
}
}
static final class Array3Func<T1, T2, T3, R> implements Function<Object[], R> {
final Function3<T1, T2, T3, R> a;
Array3Func(Function3<T1, T2, T3, R> function3) {
this.a = function3;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.Function
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public R apply(Object[] objArr) throws Exception {
if (objArr.length == 3) {
return (R) this.a.apply(objArr[0], objArr[1], objArr[2]);
}
throw new IllegalArgumentException("Array of size 3 expected but got " + objArr.length);
}
}
static final class Array4Func<T1, T2, T3, T4, R> implements Function<Object[], R> {
final Function4<T1, T2, T3, T4, R> a;
Array4Func(Function4<T1, T2, T3, T4, R> function4) {
this.a = function4;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.Function
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public R apply(Object[] objArr) throws Exception {
if (objArr.length == 4) {
return (R) this.a.a(objArr[0], objArr[1], objArr[2], objArr[3]);
}
throw new IllegalArgumentException("Array of size 4 expected but got " + objArr.length);
}
}
static final class Array5Func<T1, T2, T3, T4, T5, R> implements Function<Object[], R> {
private final Function5<T1, T2, T3, T4, T5, R> a;
Array5Func(Function5<T1, T2, T3, T4, T5, R> function5) {
this.a = function5;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.Function
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public R apply(Object[] objArr) throws Exception {
if (objArr.length == 5) {
return (R) this.a.a(objArr[0], objArr[1], objArr[2], objArr[3], objArr[4]);
}
throw new IllegalArgumentException("Array of size 5 expected but got " + objArr.length);
}
}
static final class Array6Func<T1, T2, T3, T4, T5, T6, R> implements Function<Object[], R> {
final Function6<T1, T2, T3, T4, T5, T6, R> a;
Array6Func(Function6<T1, T2, T3, T4, T5, T6, R> function6) {
this.a = function6;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.Function
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public R apply(Object[] objArr) throws Exception {
if (objArr.length == 6) {
return (R) this.a.a(objArr[0], objArr[1], objArr[2], objArr[3], objArr[4], objArr[5]);
}
throw new IllegalArgumentException("Array of size 6 expected but got " + objArr.length);
}
}
static final class Array7Func<T1, T2, T3, T4, T5, T6, T7, R> implements Function<Object[], R> {
final Function7<T1, T2, T3, T4, T5, T6, T7, R> a;
Array7Func(Function7<T1, T2, T3, T4, T5, T6, T7, R> function7) {
this.a = function7;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.Function
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public R apply(Object[] objArr) throws Exception {
if (objArr.length == 7) {
return (R) this.a.a(objArr[0], objArr[1], objArr[2], objArr[3], objArr[4], objArr[5], objArr[6]);
}
throw new IllegalArgumentException("Array of size 7 expected but got " + objArr.length);
}
}
static final class Array8Func<T1, T2, T3, T4, T5, T6, T7, T8, R> implements Function<Object[], R> {
final Function8<T1, T2, T3, T4, T5, T6, T7, T8, R> a;
Array8Func(Function8<T1, T2, T3, T4, T5, T6, T7, T8, R> function8) {
this.a = function8;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.Function
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public R apply(Object[] objArr) throws Exception {
if (objArr.length == 8) {
return (R) this.a.a(objArr[0], objArr[1], objArr[2], objArr[3], objArr[4], objArr[5], objArr[6], objArr[7]);
}
throw new IllegalArgumentException("Array of size 8 expected but got " + objArr.length);
}
}
static final class Array9Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, R> implements Function<Object[], R> {
final Function9<T1, T2, T3, T4, T5, T6, T7, T8, T9, R> a;
Array9Func(Function9<T1, T2, T3, T4, T5, T6, T7, T8, T9, R> function9) {
this.a = function9;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.Function
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public R apply(Object[] objArr) throws Exception {
if (objArr.length == 9) {
return (R) this.a.a(objArr[0], objArr[1], objArr[2], objArr[3], objArr[4], objArr[5], objArr[6], objArr[7], objArr[8]);
}
throw new IllegalArgumentException("Array of size 9 expected but got " + objArr.length);
}
}
static final class ArrayListCapacityCallable<T> implements Callable<List<T>> {
final int a;
ArrayListCapacityCallable(int i) {
this.a = i;
}
@Override // java.util.concurrent.Callable
public List<T> call() throws Exception {
return new ArrayList(this.a);
}
}
static final class BooleanSupplierPredicateReverse<T> implements Predicate<T> {
final BooleanSupplier a;
BooleanSupplierPredicateReverse(BooleanSupplier booleanSupplier) {
this.a = booleanSupplier;
}
@Override // io.reactivex.functions.Predicate
public boolean a(T t) throws Exception {
return !this.a.a();
}
}
static final class CastToClass<T, U> implements Function<T, U> {
final Class<U> a;
CastToClass(Class<U> cls) {
this.a = cls;
}
@Override // io.reactivex.functions.Function
public U apply(T t) throws Exception {
return this.a.cast(t);
}
}
static final class ClassFilter<T, U> implements Predicate<T> {
final Class<U> a;
ClassFilter(Class<U> cls) {
this.a = cls;
}
@Override // io.reactivex.functions.Predicate
public boolean a(T t) throws Exception {
return this.a.isInstance(t);
}
}
static final class EmptyAction implements Action {
EmptyAction() {
}
@Override // io.reactivex.functions.Action
public void run() {
}
public String toString() {
return "EmptyAction";
}
}
static final class EmptyConsumer implements Consumer<Object> {
EmptyConsumer() {
}
@Override // io.reactivex.functions.Consumer
public void accept(Object obj) {
}
public String toString() {
return "EmptyConsumer";
}
}
static final class EmptyLongConsumer implements LongConsumer {
EmptyLongConsumer() {
}
}
static final class EmptyRunnable implements Runnable {
EmptyRunnable() {
}
@Override // java.lang.Runnable
public void run() {
}
public String toString() {
return "EmptyRunnable";
}
}
static final class EqualsPredicate<T> implements Predicate<T> {
final T a;
EqualsPredicate(T t) {
this.a = t;
}
@Override // io.reactivex.functions.Predicate
public boolean a(T t) throws Exception {
return ObjectHelper.a(t, this.a);
}
}
static final class ErrorConsumer implements Consumer<Throwable> {
ErrorConsumer() {
}
@Override // io.reactivex.functions.Consumer
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public void accept(Throwable th) {
RxJavaPlugins.b(th);
}
}
static final class FalsePredicate implements Predicate<Object> {
FalsePredicate() {
}
@Override // io.reactivex.functions.Predicate
public boolean a(Object obj) {
return false;
}
}
enum HashSetCallable implements Callable<Set<Object>> {
INSTANCE;
@Override // java.util.concurrent.Callable
public Set<Object> call() throws Exception {
return new HashSet();
}
}
static final class Identity implements Function<Object, Object> {
Identity() {
}
@Override // io.reactivex.functions.Function
public Object apply(Object obj) {
return obj;
}
public String toString() {
return "IdentityFunction";
}
}
static final class JustValue<T, U> implements Callable<U>, Function<T, U> {
final U a;
JustValue(U u) {
this.a = u;
}
@Override // io.reactivex.functions.Function
public U apply(T t) throws Exception {
return this.a;
}
@Override // java.util.concurrent.Callable
public U call() throws Exception {
return this.a;
}
}
static final class ListSorter<T> implements Function<List<T>, List<T>> {
final Comparator<? super T> a;
ListSorter(Comparator<? super T> comparator) {
this.a = comparator;
}
public List<T> a(List<T> list) {
Collections.sort(list, this.a);
return list;
}
@Override // io.reactivex.functions.Function
public /* bridge */ /* synthetic */ Object apply(Object obj) throws Exception {
List<T> list = (List) obj;
a(list);
return list;
}
}
static final class MaxRequestSubscription implements Consumer<Subscription> {
MaxRequestSubscription() {
}
@Override // io.reactivex.functions.Consumer
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public void accept(Subscription subscription) throws Exception {
subscription.request(Long.MAX_VALUE);
}
}
enum NaturalComparator implements Comparator<Object> {
INSTANCE;
@Override // java.util.Comparator
public int compare(Object obj, Object obj2) {
return ((Comparable) obj).compareTo(obj2);
}
}
static final class NaturalObjectComparator implements Comparator<Object> {
NaturalObjectComparator() {
}
@Override // java.util.Comparator
public int compare(Object obj, Object obj2) {
return ((Comparable) obj).compareTo(obj2);
}
}
static final class NotificationOnComplete<T> implements Action {
final Consumer<? super Notification<T>> a;
NotificationOnComplete(Consumer<? super Notification<T>> consumer) {
this.a = consumer;
}
@Override // io.reactivex.functions.Action
public void run() throws Exception {
this.a.accept(Notification.f());
}
}
static final class NotificationOnError<T> implements Consumer<Throwable> {
final Consumer<? super Notification<T>> a;
NotificationOnError(Consumer<? super Notification<T>> consumer) {
this.a = consumer;
}
@Override // io.reactivex.functions.Consumer
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public void accept(Throwable th) throws Exception {
this.a.accept(Notification.a(th));
}
}
static final class NotificationOnNext<T> implements Consumer<T> {
final Consumer<? super Notification<T>> a;
NotificationOnNext(Consumer<? super Notification<T>> consumer) {
this.a = consumer;
}
@Override // io.reactivex.functions.Consumer
public void accept(T t) throws Exception {
this.a.accept(Notification.a(t));
}
}
static final class NullCallable implements Callable<Object> {
NullCallable() {
}
@Override // java.util.concurrent.Callable
public Object call() {
return null;
}
}
static final class OnErrorMissingConsumer implements Consumer<Throwable> {
OnErrorMissingConsumer() {
}
@Override // io.reactivex.functions.Consumer
/* renamed from: a, reason: merged with bridge method [inline-methods] */
public void accept(Throwable th) {
RxJavaPlugins.b(new OnErrorNotImplementedException(th));
}
}
static final class TimestampFunction<T> implements Function<T, Timed<T>> {
final TimeUnit a;
final Scheduler b;
TimestampFunction(TimeUnit timeUnit, Scheduler scheduler) {
this.a = timeUnit;
this.b = scheduler;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.Function
public /* bridge */ /* synthetic */ Object apply(Object obj) throws Exception {
return apply((TimestampFunction<T>) obj);
}
@Override // io.reactivex.functions.Function
public Timed<T> apply(T t) throws Exception {
return new Timed<>(t, this.b.a(this.a), this.a);
}
}
static final class ToMapKeySelector<K, T> implements BiConsumer<Map<K, T>, T> {
private final Function<? super T, ? extends K> a;
ToMapKeySelector(Function<? super T, ? extends K> function) {
this.a = function;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.BiConsumer
public /* bridge */ /* synthetic */ void a(Object obj, Object obj2) throws Exception {
a((Map<K, Map<K, T>>) obj, (Map<K, T>) obj2);
}
public void a(Map<K, T> map, T t) throws Exception {
map.put(this.a.apply(t), t);
}
}
static final class ToMapKeyValueSelector<K, V, T> implements BiConsumer<Map<K, V>, T> {
private final Function<? super T, ? extends V> a;
private final Function<? super T, ? extends K> b;
ToMapKeyValueSelector(Function<? super T, ? extends V> function, Function<? super T, ? extends K> function2) {
this.a = function;
this.b = function2;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.BiConsumer
public /* bridge */ /* synthetic */ void a(Object obj, Object obj2) throws Exception {
a((Map) obj, (Map<K, V>) obj2);
}
public void a(Map<K, V> map, T t) throws Exception {
map.put(this.b.apply(t), this.a.apply(t));
}
}
static final class ToMultimapKeyValueSelector<K, V, T> implements BiConsumer<Map<K, Collection<V>>, T> {
private final Function<? super K, ? extends Collection<? super V>> a;
private final Function<? super T, ? extends V> b;
private final Function<? super T, ? extends K> c;
ToMultimapKeyValueSelector(Function<? super K, ? extends Collection<? super V>> function, Function<? super T, ? extends V> function2, Function<? super T, ? extends K> function3) {
this.a = function;
this.b = function2;
this.c = function3;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // io.reactivex.functions.BiConsumer
public /* bridge */ /* synthetic */ void a(Object obj, Object obj2) throws Exception {
a((Map) obj, (Map<K, Collection<V>>) obj2);
}
public void a(Map<K, Collection<V>> map, T t) throws Exception {
K apply = this.c.apply(t);
Collection<? super V> collection = (Collection) map.get(apply);
if (collection == null) {
collection = this.a.apply(apply);
map.put(apply, collection);
}
collection.add(this.b.apply(t));
}
}
static final class TruePredicate implements Predicate<Object> {
TruePredicate() {
}
@Override // io.reactivex.functions.Predicate
public boolean a(Object obj) {
return true;
}
}
static {
new ErrorConsumer();
e = new OnErrorMissingConsumer();
new EmptyLongConsumer();
f = new TruePredicate();
g = new FalsePredicate();
h = new NullCallable();
i = new NaturalObjectComparator();
new MaxRequestSubscription();
}
public static <T1, T2, R> Function<Object[], R> a(BiFunction<? super T1, ? super T2, ? extends R> biFunction) {
ObjectHelper.a(biFunction, "f is null");
return new Array2Func(biFunction);
}
public static <T> Predicate<T> b() {
return (Predicate<T>) f;
}
public static <T, U> Function<T, U> c(U u) {
return new JustValue(u);
}
public static <T> Consumer<T> d() {
return (Consumer<T>) d;
}
public static <T> Function<T, T> e() {
return (Function<T, T>) a;
}
public static <T> Comparator<T> f() {
return NaturalComparator.INSTANCE;
}
public static <T> Comparator<T> g() {
return (Comparator<T>) i;
}
public static <T> Callable<T> h() {
return (Callable<T>) h;
}
public static <T> Callable<T> b(T t) {
return new JustValue(t);
}
public static <T> Callable<Set<T>> c() {
return HashSetCallable.INSTANCE;
}
public static <T1, T2, T3, R> Function<Object[], R> a(Function3<T1, T2, T3, R> function3) {
ObjectHelper.a(function3, "f is null");
return new Array3Func(function3);
}
public static <T> Consumer<Throwable> b(Consumer<? super Notification<T>> consumer) {
return new NotificationOnError(consumer);
}
public static <T> Consumer<T> c(Consumer<? super Notification<T>> consumer) {
return new NotificationOnNext(consumer);
}
public static <T, U> Predicate<T> b(Class<U> cls) {
return new ClassFilter(cls);
}
public static <T1, T2, T3, T4, R> Function<Object[], R> a(Function4<T1, T2, T3, T4, R> function4) {
ObjectHelper.a(function4, "f is null");
return new Array4Func(function4);
}
public static <T1, T2, T3, T4, T5, R> Function<Object[], R> a(Function5<T1, T2, T3, T4, T5, R> function5) {
ObjectHelper.a(function5, "f is null");
return new Array5Func(function5);
}
public static <T1, T2, T3, T4, T5, T6, R> Function<Object[], R> a(Function6<T1, T2, T3, T4, T5, T6, R> function6) {
ObjectHelper.a(function6, "f is null");
return new Array6Func(function6);
}
public static <T1, T2, T3, T4, T5, T6, T7, R> Function<Object[], R> a(Function7<T1, T2, T3, T4, T5, T6, T7, R> function7) {
ObjectHelper.a(function7, "f is null");
return new Array7Func(function7);
}
public static <T1, T2, T3, T4, T5, T6, T7, T8, R> Function<Object[], R> a(Function8<T1, T2, T3, T4, T5, T6, T7, T8, R> function8) {
ObjectHelper.a(function8, "f is null");
return new Array8Func(function8);
}
public static <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> Function<Object[], R> a(Function9<T1, T2, T3, T4, T5, T6, T7, T8, T9, R> function9) {
ObjectHelper.a(function9, "f is null");
return new Array9Func(function9);
}
public static <T> Predicate<T> a() {
return (Predicate<T>) g;
}
public static <T, U> Function<T, U> a(Class<U> cls) {
return new CastToClass(cls);
}
public static <T> Callable<List<T>> a(int i2) {
return new ArrayListCapacityCallable(i2);
}
public static <T> Predicate<T> a(T t) {
return new EqualsPredicate(t);
}
public static <T> Action a(Consumer<? super Notification<T>> consumer) {
return new NotificationOnComplete(consumer);
}
public static <T> Consumer<T> a(Action action) {
return new ActionConsumer(action);
}
public static <T> Predicate<T> a(BooleanSupplier booleanSupplier) {
return new BooleanSupplierPredicateReverse(booleanSupplier);
}
public static <T> Function<T, Timed<T>> a(TimeUnit timeUnit, Scheduler scheduler) {
return new TimestampFunction(timeUnit, scheduler);
}
public static <T, K> BiConsumer<Map<K, T>, T> a(Function<? super T, ? extends K> function) {
return new ToMapKeySelector(function);
}
public static <T, K, V> BiConsumer<Map<K, V>, T> a(Function<? super T, ? extends K> function, Function<? super T, ? extends V> function2) {
return new ToMapKeyValueSelector(function2, function);
}
public static <T, K, V> BiConsumer<Map<K, Collection<V>>, T> a(Function<? super T, ? extends K> function, Function<? super T, ? extends V> function2, Function<? super K, ? extends Collection<? super V>> function3) {
return new ToMultimapKeyValueSelector(function3, function2, function);
}
public static <T> Function<List<T>, List<T>> a(Comparator<? super T> comparator) {
return new ListSorter(comparator);
}
}