- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
74 lines
3.5 KiB
Java
74 lines
3.5 KiB
Java
package androidx.room;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.room.RoomDatabase;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.text.StringsKt__StringsJVMKt;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class Room {
|
|
private static final String CURSOR_CONV_SUFFIX = "_CursorConverter";
|
|
public static final Room INSTANCE = new Room();
|
|
public static final String LOG_TAG = "ROOM";
|
|
public static final String MASTER_TABLE_NAME = "room_master_table";
|
|
|
|
private Room() {
|
|
}
|
|
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
|
|
public static final <T, C> T getGeneratedImplementation(Class<C> klass, String suffix) {
|
|
String replace$default;
|
|
String str;
|
|
Intrinsics.checkNotNullParameter(klass, "klass");
|
|
Intrinsics.checkNotNullParameter(suffix, "suffix");
|
|
Package r0 = klass.getPackage();
|
|
Intrinsics.checkNotNull(r0);
|
|
String fullPackage = r0.getName();
|
|
String canonicalName = klass.getCanonicalName();
|
|
Intrinsics.checkNotNull(canonicalName);
|
|
Intrinsics.checkNotNullExpressionValue(fullPackage, "fullPackage");
|
|
if (fullPackage.length() != 0) {
|
|
canonicalName = canonicalName.substring(fullPackage.length() + 1);
|
|
Intrinsics.checkNotNullExpressionValue(canonicalName, "this as java.lang.String).substring(startIndex)");
|
|
}
|
|
String str2 = canonicalName;
|
|
StringBuilder sb = new StringBuilder();
|
|
replace$default = StringsKt__StringsJVMKt.replace$default(str2, '.', '_', false, 4, (Object) null);
|
|
sb.append(replace$default);
|
|
sb.append(suffix);
|
|
String sb2 = sb.toString();
|
|
try {
|
|
if (fullPackage.length() == 0) {
|
|
str = sb2;
|
|
} else {
|
|
str = fullPackage + '.' + sb2;
|
|
}
|
|
Class<?> cls = Class.forName(str, true, klass.getClassLoader());
|
|
Intrinsics.checkNotNull(cls, "null cannot be cast to non-null type java.lang.Class<T of androidx.room.Room.getGeneratedImplementation>");
|
|
return (T) cls.getDeclaredConstructor(new Class[0]).newInstance(new Object[0]);
|
|
} catch (ClassNotFoundException unused) {
|
|
throw new RuntimeException("Cannot find implementation for " + klass.getCanonicalName() + ". " + sb2 + " does not exist");
|
|
} catch (IllegalAccessException unused2) {
|
|
throw new RuntimeException("Cannot access the constructor " + klass.getCanonicalName());
|
|
} catch (InstantiationException unused3) {
|
|
throw new RuntimeException("Failed to create an instance of " + klass.getCanonicalName());
|
|
}
|
|
}
|
|
|
|
public static final <T extends RoomDatabase> RoomDatabase.Builder<T> inMemoryDatabaseBuilder(Context context, Class<T> klass) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Intrinsics.checkNotNullParameter(klass, "klass");
|
|
return new RoomDatabase.Builder<>(context, klass, null);
|
|
}
|
|
|
|
public static final <T extends RoomDatabase> RoomDatabase.Builder<T> databaseBuilder(Context context, Class<T> klass, String str) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Intrinsics.checkNotNullParameter(klass, "klass");
|
|
if (!(true ^ (str == null || StringsKt__StringsJVMKt.isBlank(str)))) {
|
|
throw new IllegalArgumentException("Cannot build a database with null or empty name. If you are trying to create an in memory database, use Room.inMemoryDatabaseBuilder".toString());
|
|
}
|
|
return new RoomDatabase.Builder<>(context, klass, str);
|
|
}
|
|
}
|