Rabbit-R1/original r1/java/sources/kotlin/ResultKt.java
2024-05-21 17:08:36 -04:00

139 lines
11 KiB
Java

package kotlin;
import androidx.exifinterface.media.ExifInterface;
import io.sentry.SentryEvent;
import kotlin.Result;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: Result.kt */
@Metadata(d1 = {"\u0000:\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0003\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u000f\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\u001a\u0010\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u0003H\u0001\u001a+\u0010\u0004\u001a\b\u0012\u0004\u0012\u0002H\u00060\u0005\"\u0004\b\u0000\u0010\u00062\f\u0010\u0007\u001a\b\u0012\u0004\u0012\u0002H\u00060\bH\u0087\\u0001\u0000¢\u0006\u0002\u0010\t\u001a\u0084\u0001\u0010\n\u001a\u0002H\u0006\"\u0004\b\u0000\u0010\u0006\"\u0004\b\u0001\u0010\u000b*\b\u0012\u0004\u0012\u0002H\u000b0\u00052!\u0010\f\u001a\u001d\u0012\u0013\u0012\u0011H\u000b¢\u0006\f\b\u000e\u0012\b\b\u000f\u0012\u0004\b\b(\u0010\u0012\u0004\u0012\u0002H\u00060\r2!\u0010\u0011\u001a\u001d\u0012\u0013\u0012\u00110\u0003¢\u0006\f\b\u000e\u0012\b\b\u000f\u0012\u0004\b\b(\u0002\u0012\u0004\u0012\u0002H\u00060\rH\u0087\\u0001\u0000\u0082\u0002\u0014\n\b\b\u0001\u0012\u0002\u0010\u0001 \u0000\n\b\b\u0001\u0012\u0002\u0010\u0002 \u0000¢\u0006\u0002\u0010\u0012\u001a0\u0010\u0013\u001a\u0002H\u0006\"\u0004\b\u0000\u0010\u0006\"\b\b\u0001\u0010\u000b*\u0002H\u0006*\b\u0012\u0004\u0012\u0002H\u000b0\u00052\u0006\u0010\u0014\u001a\u0002H\u0006H\u0087\\u0006\u0002\u0010\u0015\u001a[\u0010\u0016\u001a\u0002H\u0006\"\u0004\b\u0000\u0010\u0006\"\b\b\u0001\u0010\u000b*\u0002H\u0006*\b\u0012\u0004\u0012\u0002H\u000b0\u00052!\u0010\u0011\u001a\u001d\u0012\u0013\u0012\u00110\u0003¢\u0006\f\b\u000e\u0012\b\b\u000f\u0012\u0004\b\b(\u0002\u0012\u0004\u0012\u0002H\u00060\rH\u0087\\u0001\u0000\u0082\u0002\n\n\b\b\u0001\u0012\u0002\u0010\u0001 \u0000¢\u0006\u0002\u0010\u0017\u001a\u001e\u0010\u0018\u001a\u0002H\u000b\"\u0004\b\u0000\u0010\u000b*\b\u0012\u0004\u0012\u0002H\u000b0\u0005H\u0087\\u0006\u0002\u0010\u0019\u001a]\u0010\u001a\u001a\b\u0012\u0004\u0012\u0002H\u00060\u0005\"\u0004\b\u0000\u0010\u0006\"\u0004\b\u0001\u0010\u000b*\b\u0012\u0004\u0012\u0002H\u000b0\u00052!\u0010\u001b\u001a\u001d\u0012\u0013\u0012\u0011H\u000b¢\u0006\f\b\u000e\u0012\b\b\u000f\u0012\u0004\b\b(\u0010\u0012\u0004\u0012\u0002H\u00060\rH\u0087\\u0001\u0000\u0082\u0002\n\n\b\b\u0001\u0012\u0002\u0010\u0001 \u0000¢\u0006\u0002\u0010\u0017\u001aP\u0010\u001c\u001a\b\u0012\u0004\u0012\u0002H\u00060\u0005\"\u0004\b\u0000\u0010\u0006\"\u0004\b\u0001\u0010\u000b*\b\u0012\u0004\u0012\u0002H\u000b0\u00052!\u0010\u001b\u001a\u001d\u0012\u0013\u0012\u0011H\u000b¢\u0006\f\b\u000e\u0012\b\b\u000f\u0012\u0004\b\b(\u0010\u0012\u0004\u0012\u0002H\u00060\rH\u0087\\u0001\u0000¢\u0006\u0002\u0010\u0017\u001aW\u0010\u0011\u001a\b\u0012\u0004\u0012\u0002H\u000b0\u0005\"\u0004\b\u0000\u0010\u000b*\b\u0012\u0004\u0012\u0002H\u000b0\u00052!\u0010\u001d\u001a\u001d\u0012\u0013\u0012\u00110\u0003¢\u0006\f\b\u000e\u0012\b\b\u000f\u0012\u0004\b\b(\u0002\u0012\u0004\u0012\u00020\u001e0\rH\u0087\\u0001\u0000\u0082\u0002\n\n\b\b\u0001\u0012\u0002\u0010\u0001 \u0000¢\u0006\u0002\u0010\u0017\u001aW\u0010\f\u001a\b\u0012\u0004\u0012\u0002H\u000b0\u0005\"\u0004\b\u0000\u0010\u000b*\b\u0012\u0004\u0012\u0002H\u000b0\u00052!\u0010\u001d\u001a\u001d\u0012\u0013\u0012\u0011H\u000b¢\u0006\f\b\u000e\u0012\b\b\u000f\u0012\u0004\b\b(\u0010\u0012\u0004\u0012\u00020\u001e0\rH\u0087\\u0001\u0000\u0082\u0002\n\n\b\b\u0001\u0012\u0002\u0010\u0001 \u0000¢\u0006\u0002\u0010\u0017\u001aa\u0010\u001f\u001a\b\u0012\u0004\u0012\u0002H\u00060\u0005\"\u0004\b\u0000\u0010\u0006\"\b\b\u0001\u0010\u000b*\u0002H\u0006*\b\u0012\u0004\u0012\u0002H\u000b0\u00052!\u0010\u001b\u001a\u001d\u0012\u0013\u0012\u00110\u0003¢\u0006\f\b\u000e\u0012\b\b\u000f\u0012\u0004\b\b(\u0002\u0012\u0004\u0012\u0002H\u00060\rH\u0087\\u0001\u0000\u0082\u0002\n\n\b\b\u0001\u0012\u0002\u0010\u0001 \u0000¢\u0006\u0002\u0010\u0017\u001aT\u0010 \u001a\b\u0012\u0004\u0012\u0002H\u00060\u0005\"\u0004\b\u0000\u0010\u0006\"\b\b\u0001\u0010\u000b*\u0002H\u0006*\b\u0012\u0004\u0012\u0002H\u000b0\u00052!\u0010\u001b\u001a\u001d\u0012\u0013\u0012\u00110\u0003¢\u0006\f\b\u000e\u0012\b\b\u000f\u0012\u0004\b\b(\u0002\u0012\u0004\u0012\u0002H\u00060\rH\u0087\\u0001\u0000¢\u0006\u0002\u0010\u0017\u001a@\u0010\u0004\u001a\b\u0012\u0004\u0012\u0002H\u00060\u0005\"\u0004\b\u0000\u0010\u000b\"\u0004\b\u0001\u0010\u0006*\u0002H\u000b2\u0017\u0010\u0007\u001a\u0013\u0012\u0004\u0012\u0002H\u000b\u0012\u0004\u0012\u0002H\u00060\\u0006\u0002\b!H\u0087\\u0001\u0000¢\u0006\u0002\u0010\u0017\u001a\u0015\u0010\"\u001a\u00020\u001e*\u0006\u0012\u0002\b\u00030\u0005H\u0001¢\u0006\u0002\u0010#\u0082\u0002\u0007\n\u0005\b\u009920\u0001¨\u0006$"}, d2 = {"createFailure", "", SentryEvent.JsonKeys.EXCEPTION, "", "runCatching", "Lkotlin/Result;", "R", "block", "Lkotlin/Function0;", "(Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;", "fold", ExifInterface.GPS_DIRECTION_TRUE, "onSuccess", "Lkotlin/Function1;", "Lkotlin/ParameterName;", "name", "value", "onFailure", "(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;", "getOrDefault", "defaultValue", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", "getOrElse", "(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;", "getOrThrow", "(Ljava/lang/Object;)Ljava/lang/Object;", "map", "transform", "mapCatching", "action", "", "recover", "recoverCatching", "Lkotlin/ExtensionFunctionType;", "throwOnFailure", "(Ljava/lang/Object;)V", "kotlin-stdlib"}, k = 2, mv = {1, 9, 0}, xi = 48)
/* loaded from: classes3.dex */
public final class ResultKt {
public static final Object createFailure(Throwable exception) {
Intrinsics.checkNotNullParameter(exception, "exception");
return new Result.Failure(exception);
}
public static final void throwOnFailure(Object obj) {
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).exception;
}
}
private static final <R> Object runCatching(Function0<? extends R> block) {
Intrinsics.checkNotNullParameter(block, "block");
try {
Result.Companion companion = Result.INSTANCE;
return Result.m5698constructorimpl(block.invoke());
} catch (Throwable th) {
Result.Companion companion2 = Result.INSTANCE;
return Result.m5698constructorimpl(createFailure(th));
}
}
private static final <T, R> Object runCatching(T t, Function1<? super T, ? extends R> block) {
Intrinsics.checkNotNullParameter(block, "block");
try {
Result.Companion companion = Result.INSTANCE;
return Result.m5698constructorimpl(block.invoke(t));
} catch (Throwable th) {
Result.Companion companion2 = Result.INSTANCE;
return Result.m5698constructorimpl(createFailure(th));
}
}
/* JADX WARN: Multi-variable type inference failed */
private static final <T> T getOrThrow(Object obj) {
throwOnFailure(obj);
return obj;
}
/* JADX WARN: Multi-variable type inference failed */
private static final <R, T extends R> R getOrElse(Object obj, Function1<? super Throwable, ? extends R> onFailure) {
Intrinsics.checkNotNullParameter(onFailure, "onFailure");
Throwable m5701exceptionOrNullimpl = Result.m5701exceptionOrNullimpl(obj);
return m5701exceptionOrNullimpl == null ? obj : onFailure.invoke(m5701exceptionOrNullimpl);
}
/* JADX WARN: Multi-variable type inference failed */
private static final <R, T extends R> R getOrDefault(Object obj, R r) {
return Result.m5704isFailureimpl(obj) ? r : obj;
}
private static final <R, T> R fold(Object obj, Function1<? super T, ? extends R> onSuccess, Function1<? super Throwable, ? extends R> onFailure) {
Intrinsics.checkNotNullParameter(onSuccess, "onSuccess");
Intrinsics.checkNotNullParameter(onFailure, "onFailure");
Throwable m5701exceptionOrNullimpl = Result.m5701exceptionOrNullimpl(obj);
if (m5701exceptionOrNullimpl == null) {
return onSuccess.invoke(obj);
}
return onFailure.invoke(m5701exceptionOrNullimpl);
}
private static final <R, T> Object map(Object obj, Function1<? super T, ? extends R> transform) {
Intrinsics.checkNotNullParameter(transform, "transform");
if (!Result.m5705isSuccessimpl(obj)) {
return Result.m5698constructorimpl(obj);
}
Result.Companion companion = Result.INSTANCE;
return Result.m5698constructorimpl(transform.invoke(obj));
}
private static final <R, T> Object mapCatching(Object obj, Function1<? super T, ? extends R> transform) {
Intrinsics.checkNotNullParameter(transform, "transform");
if (!Result.m5705isSuccessimpl(obj)) {
return Result.m5698constructorimpl(obj);
}
try {
Result.Companion companion = Result.INSTANCE;
return Result.m5698constructorimpl(transform.invoke(obj));
} catch (Throwable th) {
Result.Companion companion2 = Result.INSTANCE;
return Result.m5698constructorimpl(createFailure(th));
}
}
private static final <R, T extends R> Object recover(Object obj, Function1<? super Throwable, ? extends R> transform) {
Intrinsics.checkNotNullParameter(transform, "transform");
Throwable m5701exceptionOrNullimpl = Result.m5701exceptionOrNullimpl(obj);
if (m5701exceptionOrNullimpl == null) {
return obj;
}
Result.Companion companion = Result.INSTANCE;
return Result.m5698constructorimpl(transform.invoke(m5701exceptionOrNullimpl));
}
private static final <R, T extends R> Object recoverCatching(Object obj, Function1<? super Throwable, ? extends R> transform) {
Intrinsics.checkNotNullParameter(transform, "transform");
Throwable m5701exceptionOrNullimpl = Result.m5701exceptionOrNullimpl(obj);
if (m5701exceptionOrNullimpl == null) {
return obj;
}
try {
Result.Companion companion = Result.INSTANCE;
return Result.m5698constructorimpl(transform.invoke(m5701exceptionOrNullimpl));
} catch (Throwable th) {
Result.Companion companion2 = Result.INSTANCE;
return Result.m5698constructorimpl(createFailure(th));
}
}
private static final <T> Object onFailure(Object obj, Function1<? super Throwable, Unit> action) {
Intrinsics.checkNotNullParameter(action, "action");
Throwable m5701exceptionOrNullimpl = Result.m5701exceptionOrNullimpl(obj);
if (m5701exceptionOrNullimpl != null) {
action.invoke(m5701exceptionOrNullimpl);
}
return obj;
}
private static final <T> Object onSuccess(Object obj, Function1<? super T, Unit> action) {
Intrinsics.checkNotNullParameter(action, "action");
if (Result.m5705isSuccessimpl(obj)) {
action.invoke(obj);
}
return obj;
}
}