Converting room-common from Java to Kotlin.
Test: N/A
Bug: 206858235
Relnote: Converting room-common from Java to Kotlin.
Change-Id: I69c4832704c00c17dc989109992d3059261695a9
diff --git a/room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/vo/BookAuthor.kt b/room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/vo/BookAuthor.kt
index a7a0777..8988695 100644
--- a/room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/vo/BookAuthor.kt
+++ b/room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/vo/BookAuthor.kt
@@ -39,7 +39,7 @@
deferred = true
)
),
- primaryKeys = arrayOf("bookId", "authorId"),
+ primaryKeys = ["bookId", "authorId"],
indices = [Index("bookId"), Index("authorId")]
)
data class BookAuthor(val bookId: String, val authorId: String)
diff --git a/room/room-common/api/current.ignore b/room/room-common/api/current.ignore
new file mode 100644
index 0000000..f5c3f3f
--- /dev/null
+++ b/room/room-common/api/current.ignore
@@ -0,0 +1,71 @@
+// Baseline format: 1.0
+ChangedType: androidx.room.AutoMigration#spec():
+ Method androidx.room.AutoMigration.spec has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.Database#entities():
+ Method androidx.room.Database.entities has changed return type from Class<?>[] to kotlin.reflect.KClass<?>[]
+ChangedType: androidx.room.Database#views():
+ Method androidx.room.Database.views has changed return type from Class<?>[] to kotlin.reflect.KClass<?>[]
+ChangedType: androidx.room.Delete#entity():
+ Method androidx.room.Delete.entity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.ForeignKey#entity():
+ Method androidx.room.ForeignKey.entity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.Fts4#contentEntity():
+ Method androidx.room.Fts4.contentEntity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.Insert#entity():
+ Method androidx.room.Insert.entity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.Junction#value():
+ Method androidx.room.Junction.value has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.RawQuery#observedEntities():
+ Method androidx.room.RawQuery.observedEntities has changed return type from Class<?>[] to kotlin.reflect.KClass<?>[]
+ChangedType: androidx.room.Relation#entity():
+ Method androidx.room.Relation.entity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.TypeConverters#value():
+ Method androidx.room.TypeConverters.value has changed return type from Class<?>[] to kotlin.reflect.KClass<?>[]
+ChangedType: androidx.room.Update#entity():
+ Method androidx.room.Update.entity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+
+
+ChangedValue: androidx.room.AutoMigration#spec():
+ Method androidx.room.AutoMigration.spec has changed value from java.lang.Object.class to java.lang.Object
+ChangedValue: androidx.room.Database#autoMigrations():
+ Method androidx.room.Database.autoMigrations has changed value from {} to nothing
+ChangedValue: androidx.room.Database#views():
+ Method androidx.room.Database.views has changed value from {} to nothing
+ChangedValue: androidx.room.Delete#entity():
+ Method androidx.room.Delete.entity has changed value from java.lang.Object.class to java.lang.Object
+ChangedValue: androidx.room.Entity#foreignKeys():
+ Method androidx.room.Entity.foreignKeys has changed value from {} to nothing
+ChangedValue: androidx.room.Entity#ignoredColumns():
+ Method androidx.room.Entity.ignoredColumns has changed value from {} to nothing
+ChangedValue: androidx.room.Entity#indices():
+ Method androidx.room.Entity.indices has changed value from {} to nothing
+ChangedValue: androidx.room.Entity#primaryKeys():
+ Method androidx.room.Entity.primaryKeys has changed value from {} to nothing
+ChangedValue: androidx.room.Fts3#tokenizerArgs():
+ Method androidx.room.Fts3.tokenizerArgs has changed value from {} to nothing
+ChangedValue: androidx.room.Fts4#contentEntity():
+ Method androidx.room.Fts4.contentEntity has changed value from java.lang.Object.class to java.lang.Object
+ChangedValue: androidx.room.Fts4#notIndexed():
+ Method androidx.room.Fts4.notIndexed has changed value from {} to nothing
+ChangedValue: androidx.room.Fts4#prefix():
+ Method androidx.room.Fts4.prefix has changed value from {} to nothing
+ChangedValue: androidx.room.Fts4#tokenizerArgs():
+ Method androidx.room.Fts4.tokenizerArgs has changed value from {} to nothing
+ChangedValue: androidx.room.Index#orders():
+ Method androidx.room.Index.orders has changed value from {} to nothing
+ChangedValue: androidx.room.Insert#entity():
+ Method androidx.room.Insert.entity has changed value from java.lang.Object.class to java.lang.Object
+ChangedValue: androidx.room.RawQuery#observedEntities():
+ Method androidx.room.RawQuery.observedEntities has changed value from {} to nothing
+ChangedValue: androidx.room.Relation#associateBy():
+ Method androidx.room.Relation.associateBy has changed value from @androidx.room.Junction to androidx.room.Junction(java.lang.Object)
+ChangedValue: androidx.room.Relation#entity():
+ Method androidx.room.Relation.entity has changed value from java.lang.Object.class to java.lang.Object
+ChangedValue: androidx.room.Relation#projection():
+ Method androidx.room.Relation.projection has changed value from {} to nothing
+ChangedValue: androidx.room.TypeConverters#builtInTypeConverters():
+ Method androidx.room.TypeConverters.builtInTypeConverters has changed value from @androidx.room.BuiltInTypeConverters to androidx.room.BuiltInTypeConverters()
+ChangedValue: androidx.room.TypeConverters#value():
+ Method androidx.room.TypeConverters.value has changed value from {} to nothing
+ChangedValue: androidx.room.Update#entity():
+ Method androidx.room.Update.entity has changed value from java.lang.Object.class to java.lang.Object
diff --git a/room/room-common/api/current.txt b/room/room-common/api/current.txt
index 74796f1..6161558 100644
--- a/room/room-common/api/current.txt
+++ b/room/room-common/api/current.txt
@@ -1,15 +1,20 @@
// Signature format: 4.0
package androidx.room {
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface AutoMigration {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface AutoMigration {
method public abstract int from();
- method public abstract Class<?> spec() default java.lang.Object.class;
+ method public abstract kotlin.reflect.KClass<?> spec() default java.lang.Object;
method public abstract int to();
+ property public abstract int from;
+ property public abstract kotlin.reflect.KClass<?> spec;
+ property public abstract int to;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface BuiltInTypeConverters {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface BuiltInTypeConverters {
method public abstract androidx.room.BuiltInTypeConverters.State enums() default androidx.room.BuiltInTypeConverters.State.INHERITED;
method public abstract androidx.room.BuiltInTypeConverters.State uuid() default androidx.room.BuiltInTypeConverters.State.INHERITED;
+ property public abstract androidx.room.BuiltInTypeConverters.State enums;
+ property public abstract androidx.room.BuiltInTypeConverters.State uuid;
}
public enum BuiltInTypeConverters.State {
@@ -18,12 +23,37 @@
enum_constant public static final androidx.room.BuiltInTypeConverters.State INHERITED;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface ColumnInfo {
- method @androidx.room.ColumnInfo.Collate public abstract int collate() default androidx.room.ColumnInfo.UNSPECIFIED;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface ColumnInfo {
+ method public abstract int collate() default androidx.room.ColumnInfo.UNSPECIFIED;
method public abstract String defaultValue() default androidx.room.ColumnInfo.VALUE_UNSPECIFIED;
method public abstract boolean index() default false;
method public abstract String name() default androidx.room.ColumnInfo.INHERIT_FIELD_NAME;
- method @androidx.room.ColumnInfo.SQLiteTypeAffinity public abstract int typeAffinity() default androidx.room.ColumnInfo.UNDEFINED;
+ method public abstract int typeAffinity() default androidx.room.ColumnInfo.UNDEFINED;
+ property public abstract int collate;
+ property public abstract String defaultValue;
+ property public abstract boolean index;
+ property public abstract String name;
+ property public abstract int typeAffinity;
+ field public static final int BINARY = 2; // 0x2
+ field public static final int BLOB = 5; // 0x5
+ field public static final androidx.room.ColumnInfo.Companion Companion;
+ field public static final String INHERIT_FIELD_NAME = "[field-name]";
+ field public static final int INTEGER = 3; // 0x3
+ field @RequiresApi(21) public static final int LOCALIZED = 5; // 0x5
+ field public static final int NOCASE = 3; // 0x3
+ field public static final int REAL = 4; // 0x4
+ field public static final int RTRIM = 4; // 0x4
+ field public static final int TEXT = 2; // 0x2
+ field public static final int UNDEFINED = 1; // 0x1
+ field @RequiresApi(21) public static final int UNICODE = 6; // 0x6
+ field public static final int UNSPECIFIED = 1; // 0x1
+ field public static final String VALUE_UNSPECIFIED = "[value-unspecified]";
+ }
+
+ @IntDef({androidx.room.ColumnInfo.UNSPECIFIED, androidx.room.ColumnInfo.BINARY, androidx.room.ColumnInfo.NOCASE, androidx.room.ColumnInfo.RTRIM, androidx.room.ColumnInfo.LOCALIZED, androidx.room.ColumnInfo.UNICODE}) @RequiresApi(21) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public static @interface ColumnInfo.Collate {
+ }
+
+ public static final class ColumnInfo.Companion {
field public static final int BINARY = 2; // 0x2
field public static final int BLOB = 5; // 0x5
field public static final String INHERIT_FIELD_NAME = "[field-name]";
@@ -39,69 +69,104 @@
field public static final String VALUE_UNSPECIFIED = "[value-unspecified]";
}
- @IntDef({androidx.room.ColumnInfo.UNSPECIFIED, androidx.room.ColumnInfo.BINARY, androidx.room.ColumnInfo.NOCASE, androidx.room.ColumnInfo.RTRIM, androidx.room.ColumnInfo.LOCALIZED, androidx.room.ColumnInfo.UNICODE}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface ColumnInfo.Collate {
+ @IntDef({androidx.room.ColumnInfo.UNDEFINED, androidx.room.ColumnInfo.TEXT, androidx.room.ColumnInfo.INTEGER, androidx.room.ColumnInfo.REAL, androidx.room.ColumnInfo.BLOB}) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public static @interface ColumnInfo.SQLiteTypeAffinity {
}
- @IntDef({androidx.room.ColumnInfo.UNDEFINED, androidx.room.ColumnInfo.TEXT, androidx.room.ColumnInfo.INTEGER, androidx.room.ColumnInfo.REAL, androidx.room.ColumnInfo.BLOB}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface ColumnInfo.SQLiteTypeAffinity {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Dao {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Dao {
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Database {
- method public abstract androidx.room.AutoMigration[] autoMigrations() default {};
- method public abstract Class<?>[] entities();
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Database {
+ method public abstract androidx.room.AutoMigration[] autoMigrations();
+ method public abstract kotlin.reflect.KClass<?>[] entities();
method public abstract boolean exportSchema() default true;
method public abstract int version();
- method public abstract Class<?>[] views() default {};
+ method public abstract kotlin.reflect.KClass<?>[] views();
+ property public abstract androidx.room.AutoMigration![] autoMigrations;
+ property public abstract kotlin.reflect.KClass<?>![] entities;
+ property public abstract boolean exportSchema;
+ property public abstract int version;
+ property public abstract kotlin.reflect.KClass<?>![] views;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface DatabaseView {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface DatabaseView {
method public abstract String value() default "";
method public abstract String viewName() default "";
+ property public abstract String value;
+ property public abstract String viewName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface Delete {
- method public abstract Class<?> entity() default java.lang.Object.class;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Delete {
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
+ property public abstract kotlin.reflect.KClass<?> entity;
}
- @java.lang.annotation.Repeatable(DeleteColumn.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface DeleteColumn {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface DeleteColumn {
method public abstract String columnName();
method public abstract String tableName();
+ property public abstract String columnName;
+ property public abstract String tableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface DeleteColumn.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface DeleteColumn.Entries {
method public abstract androidx.room.DeleteColumn[] value();
+ property public abstract androidx.room.DeleteColumn![] value;
}
- @java.lang.annotation.Repeatable(DeleteTable.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface DeleteTable {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface DeleteTable {
method public abstract String tableName();
+ property public abstract String tableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface DeleteTable.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface DeleteTable.Entries {
method public abstract androidx.room.DeleteTable[] value();
+ property public abstract androidx.room.DeleteTable![] value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface Embedded {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface Embedded {
method public abstract String prefix() default "";
+ property public abstract String prefix;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Entity {
- method public abstract androidx.room.ForeignKey[] foreignKeys() default {};
- method public abstract String[] ignoredColumns() default {};
- method public abstract androidx.room.Index[] indices() default {};
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Entity {
+ method public abstract androidx.room.ForeignKey[] foreignKeys();
+ method public abstract String[] ignoredColumns();
+ method public abstract androidx.room.Index[] indices();
method public abstract boolean inheritSuperIndices() default false;
- method public abstract String[] primaryKeys() default {};
+ method public abstract String[] primaryKeys();
method public abstract String tableName() default "";
+ property public abstract androidx.room.ForeignKey![] foreignKeys;
+ property public abstract String![] ignoredColumns;
+ property public abstract androidx.room.Index![] indices;
+ property public abstract boolean inheritSuperIndices;
+ property public abstract String![] primaryKeys;
+ property public abstract String tableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface ForeignKey {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface ForeignKey {
method public abstract String[] childColumns();
method public abstract boolean deferred() default false;
- method public abstract Class<?> entity();
- method @androidx.room.ForeignKey.Action public abstract int onDelete() default androidx.room.ForeignKey.NO_ACTION;
- method @androidx.room.ForeignKey.Action public abstract int onUpdate() default androidx.room.ForeignKey.NO_ACTION;
+ method public abstract kotlin.reflect.KClass<?> entity();
+ method public abstract int onDelete() default androidx.room.ForeignKey.NO_ACTION;
+ method public abstract int onUpdate() default androidx.room.ForeignKey.NO_ACTION;
method public abstract String[] parentColumns();
+ property public abstract String![] childColumns;
+ property public abstract boolean deferred;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract int onDelete;
+ property public abstract int onUpdate;
+ property public abstract String![] parentColumns;
+ field public static final int CASCADE = 5; // 0x5
+ field public static final androidx.room.ForeignKey.Companion Companion;
+ field public static final int NO_ACTION = 1; // 0x1
+ field public static final int RESTRICT = 2; // 0x2
+ field public static final int SET_DEFAULT = 4; // 0x4
+ field public static final int SET_NULL = 3; // 0x3
+ }
+
+ @IntDef({androidx.room.ForeignKey.NO_ACTION, androidx.room.ForeignKey.RESTRICT, androidx.room.ForeignKey.SET_NULL, androidx.room.ForeignKey.SET_DEFAULT, androidx.room.ForeignKey.CASCADE}) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public static @interface ForeignKey.Action {
+ }
+
+ public static final class ForeignKey.Companion {
field public static final int CASCADE = 5; // 0x5
field public static final int NO_ACTION = 1; // 0x1
field public static final int RESTRICT = 2; // 0x2
@@ -109,26 +174,34 @@
field public static final int SET_NULL = 3; // 0x3
}
- @IntDef({androidx.room.ForeignKey.NO_ACTION, androidx.room.ForeignKey.RESTRICT, androidx.room.ForeignKey.SET_NULL, androidx.room.ForeignKey.SET_DEFAULT, androidx.room.ForeignKey.CASCADE}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface ForeignKey.Action {
- }
-
- @RequiresApi(16) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Fts3 {
+ @RequiresApi(16) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Fts3 {
method public abstract String tokenizer() default androidx.room.FtsOptions.TOKENIZER_SIMPLE;
- method public abstract String[] tokenizerArgs() default {};
+ method public abstract String[] tokenizerArgs();
+ property public abstract String tokenizer;
+ property public abstract String![] tokenizerArgs;
}
- @RequiresApi(16) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Fts4 {
- method public abstract Class<?> contentEntity() default java.lang.Object.class;
+ @RequiresApi(16) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Fts4 {
+ method public abstract kotlin.reflect.KClass<?> contentEntity() default java.lang.Object;
method public abstract String languageId() default "";
method public abstract androidx.room.FtsOptions.MatchInfo matchInfo() default androidx.room.FtsOptions.MatchInfo.FTS4;
- method public abstract String[] notIndexed() default {};
+ method public abstract String[] notIndexed();
method public abstract androidx.room.FtsOptions.Order order() default androidx.room.FtsOptions.Order.ASC;
- method public abstract int[] prefix() default {};
+ method public abstract int[] prefix();
method public abstract String tokenizer() default androidx.room.FtsOptions.TOKENIZER_SIMPLE;
- method public abstract String[] tokenizerArgs() default {};
+ method public abstract String[] tokenizerArgs();
+ property public abstract kotlin.reflect.KClass<?> contentEntity;
+ property public abstract String languageId;
+ property public abstract androidx.room.FtsOptions.MatchInfo matchInfo;
+ property public abstract String![] notIndexed;
+ property public abstract androidx.room.FtsOptions.Order order;
+ property public abstract int[] prefix;
+ property public abstract String tokenizer;
+ property public abstract String![] tokenizerArgs;
}
- public class FtsOptions {
+ public final class FtsOptions {
+ field public static final androidx.room.FtsOptions INSTANCE;
field public static final String TOKENIZER_ICU = "icu";
field public static final String TOKENIZER_PORTER = "porter";
field public static final String TOKENIZER_SIMPLE = "simple";
@@ -145,14 +218,18 @@
enum_constant public static final androidx.room.FtsOptions.Order DESC;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.CONSTRUCTOR}) public @interface Ignore {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.CONSTRUCTOR}) public @interface Ignore {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface Index {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface Index {
method public abstract String name() default "";
- method public abstract androidx.room.Index.Order[] orders() default {};
+ method public abstract androidx.room.Index.Order[] orders();
method public abstract boolean unique() default false;
method public abstract String[] value();
+ property public abstract String name;
+ property public abstract androidx.room.Index.Order![] orders;
+ property public abstract boolean unique;
+ property public abstract String![] value;
}
public enum Index.Order {
@@ -160,23 +237,39 @@
enum_constant public static final androidx.room.Index.Order DESC;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface Insert {
- method public abstract Class<?> entity() default java.lang.Object.class;
- method @androidx.room.OnConflictStrategy public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Insert {
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
+ method public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract int onConflict;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface Junction {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface Junction {
method public abstract String entityColumn() default "";
method public abstract String parentColumn() default "";
- method public abstract Class<?> value();
+ method public abstract kotlin.reflect.KClass<?> value();
+ property public abstract String entityColumn;
+ property public abstract String parentColumn;
+ property public abstract kotlin.reflect.KClass<?> value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface MapInfo {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface MapInfo {
method public abstract String keyColumn() default "";
method public abstract String valueColumn() default "";
+ property public abstract String keyColumn;
+ property public abstract String valueColumn;
}
- @IntDef({androidx.room.OnConflictStrategy.REPLACE, androidx.room.OnConflictStrategy.ROLLBACK, androidx.room.OnConflictStrategy.ABORT, androidx.room.OnConflictStrategy.FAIL, androidx.room.OnConflictStrategy.IGNORE}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface OnConflictStrategy {
+ @IntDef({androidx.room.OnConflictStrategy.REPLACE, androidx.room.OnConflictStrategy.ROLLBACK, androidx.room.OnConflictStrategy.ABORT, androidx.room.OnConflictStrategy.FAIL, androidx.room.OnConflictStrategy.IGNORE}) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public @interface OnConflictStrategy {
+ field public static final int ABORT = 3; // 0x3
+ field public static final androidx.room.OnConflictStrategy.Companion Companion;
+ field @Deprecated public static final int FAIL = 4; // 0x4
+ field public static final int IGNORE = 5; // 0x5
+ field public static final int REPLACE = 1; // 0x1
+ field @Deprecated public static final int ROLLBACK = 2; // 0x2
+ }
+
+ public static final class OnConflictStrategy.Companion {
field public static final int ABORT = 3; // 0x3
field @Deprecated public static final int FAIL = 4; // 0x4
field public static final int IGNORE = 5; // 0x5
@@ -184,58 +277,74 @@
field @Deprecated public static final int ROLLBACK = 2; // 0x2
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface PrimaryKey {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface PrimaryKey {
method public abstract boolean autoGenerate() default false;
+ property public abstract boolean autoGenerate;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface ProvidedAutoMigrationSpec {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface ProvidedAutoMigrationSpec {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface ProvidedTypeConverter {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface ProvidedTypeConverter {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface Query {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Query {
method public abstract String value();
+ property public abstract String value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface RawQuery {
- method public abstract Class<?>[] observedEntities() default {};
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface RawQuery {
+ method public abstract kotlin.reflect.KClass<?>[] observedEntities();
+ property public abstract kotlin.reflect.KClass<?>![] observedEntities;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface Relation {
- method public abstract androidx.room.Junction associateBy() default @androidx.room.Junction;
- method public abstract Class<?> entity() default java.lang.Object.class;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface Relation {
+ method public abstract androidx.room.Junction associateBy() default androidx.room.Junction(java.lang.Object);
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
method public abstract String entityColumn();
method public abstract String parentColumn();
- method public abstract String[] projection() default {};
+ method public abstract String[] projection();
+ property public abstract androidx.room.Junction associateBy;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract String entityColumn;
+ property public abstract String parentColumn;
+ property public abstract String![] projection;
}
- @java.lang.annotation.Repeatable(RenameColumn.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface RenameColumn {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface RenameColumn {
method public abstract String fromColumnName();
method public abstract String tableName();
method public abstract String toColumnName();
+ property public abstract String fromColumnName;
+ property public abstract String tableName;
+ property public abstract String toColumnName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface RenameColumn.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface RenameColumn.Entries {
method public abstract androidx.room.RenameColumn[] value();
+ property public abstract androidx.room.RenameColumn![] value;
}
- @java.lang.annotation.Repeatable(RenameTable.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface RenameTable {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface RenameTable {
method public abstract String fromTableName();
method public abstract String toTableName();
+ property public abstract String fromTableName;
+ property public abstract String toTableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface RenameTable.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface RenameTable.Entries {
method public abstract androidx.room.RenameTable[] value();
+ property public abstract androidx.room.RenameTable![] value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.TYPE}) public @interface RewriteQueriesToDropUnusedColumns {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.CLASS}) public @interface RewriteQueriesToDropUnusedColumns {
}
public class RoomWarnings {
ctor @Deprecated public RoomWarnings();
field public static final String CANNOT_CREATE_VERIFICATION_DATABASE = "ROOM_CANNOT_CREATE_VERIFICATION_DATABASE";
field public static final String CURSOR_MISMATCH = "ROOM_CURSOR_MISMATCH";
+ field public static final androidx.room.RoomWarnings.Companion Companion;
field public static final String DEFAULT_CONSTRUCTOR = "ROOM_DEFAULT_CONSTRUCTOR";
field public static final String DOES_NOT_IMPLEMENT_EQUALS_HASHCODE = "ROOM_TYPE_DOES_NOT_IMPLEMENT_EQUALS_HASHCODE";
field public static final String INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED = "ROOM_EMBEDDED_ENTITY_INDEX_IS_DROPPED";
@@ -253,23 +362,30 @@
field public static final String RELATION_TYPE_MISMATCH = "ROOM_RELATION_TYPE_MISMATCH";
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.TYPE}) public @interface SkipQueryVerification {
+ public static final class RoomWarnings.Companion {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface Transaction {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.CLASS}) public @interface SkipQueryVerification {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface TypeConverter {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Transaction {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE, java.lang.annotation.ElementType.FIELD}) public @interface TypeConverters {
- method public abstract androidx.room.BuiltInTypeConverters builtInTypeConverters() default @androidx.room.BuiltInTypeConverters;
- method public abstract Class<?>[] value() default {};
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface TypeConverter {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface Update {
- method public abstract Class<?> entity() default java.lang.Object.class;
- method @androidx.room.OnConflictStrategy public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.CLASS}) public @interface TypeConverters {
+ method public abstract androidx.room.BuiltInTypeConverters builtInTypeConverters() default androidx.room.BuiltInTypeConverters();
+ method public abstract kotlin.reflect.KClass<?>[] value();
+ property public abstract androidx.room.BuiltInTypeConverters builtInTypeConverters;
+ property public abstract kotlin.reflect.KClass<?>![] value;
+ }
+
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Update {
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
+ method public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract int onConflict;
}
}
diff --git a/room/room-common/api/public_plus_experimental_current.txt b/room/room-common/api/public_plus_experimental_current.txt
index 74796f1..6161558 100644
--- a/room/room-common/api/public_plus_experimental_current.txt
+++ b/room/room-common/api/public_plus_experimental_current.txt
@@ -1,15 +1,20 @@
// Signature format: 4.0
package androidx.room {
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface AutoMigration {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface AutoMigration {
method public abstract int from();
- method public abstract Class<?> spec() default java.lang.Object.class;
+ method public abstract kotlin.reflect.KClass<?> spec() default java.lang.Object;
method public abstract int to();
+ property public abstract int from;
+ property public abstract kotlin.reflect.KClass<?> spec;
+ property public abstract int to;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface BuiltInTypeConverters {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface BuiltInTypeConverters {
method public abstract androidx.room.BuiltInTypeConverters.State enums() default androidx.room.BuiltInTypeConverters.State.INHERITED;
method public abstract androidx.room.BuiltInTypeConverters.State uuid() default androidx.room.BuiltInTypeConverters.State.INHERITED;
+ property public abstract androidx.room.BuiltInTypeConverters.State enums;
+ property public abstract androidx.room.BuiltInTypeConverters.State uuid;
}
public enum BuiltInTypeConverters.State {
@@ -18,12 +23,37 @@
enum_constant public static final androidx.room.BuiltInTypeConverters.State INHERITED;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface ColumnInfo {
- method @androidx.room.ColumnInfo.Collate public abstract int collate() default androidx.room.ColumnInfo.UNSPECIFIED;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface ColumnInfo {
+ method public abstract int collate() default androidx.room.ColumnInfo.UNSPECIFIED;
method public abstract String defaultValue() default androidx.room.ColumnInfo.VALUE_UNSPECIFIED;
method public abstract boolean index() default false;
method public abstract String name() default androidx.room.ColumnInfo.INHERIT_FIELD_NAME;
- method @androidx.room.ColumnInfo.SQLiteTypeAffinity public abstract int typeAffinity() default androidx.room.ColumnInfo.UNDEFINED;
+ method public abstract int typeAffinity() default androidx.room.ColumnInfo.UNDEFINED;
+ property public abstract int collate;
+ property public abstract String defaultValue;
+ property public abstract boolean index;
+ property public abstract String name;
+ property public abstract int typeAffinity;
+ field public static final int BINARY = 2; // 0x2
+ field public static final int BLOB = 5; // 0x5
+ field public static final androidx.room.ColumnInfo.Companion Companion;
+ field public static final String INHERIT_FIELD_NAME = "[field-name]";
+ field public static final int INTEGER = 3; // 0x3
+ field @RequiresApi(21) public static final int LOCALIZED = 5; // 0x5
+ field public static final int NOCASE = 3; // 0x3
+ field public static final int REAL = 4; // 0x4
+ field public static final int RTRIM = 4; // 0x4
+ field public static final int TEXT = 2; // 0x2
+ field public static final int UNDEFINED = 1; // 0x1
+ field @RequiresApi(21) public static final int UNICODE = 6; // 0x6
+ field public static final int UNSPECIFIED = 1; // 0x1
+ field public static final String VALUE_UNSPECIFIED = "[value-unspecified]";
+ }
+
+ @IntDef({androidx.room.ColumnInfo.UNSPECIFIED, androidx.room.ColumnInfo.BINARY, androidx.room.ColumnInfo.NOCASE, androidx.room.ColumnInfo.RTRIM, androidx.room.ColumnInfo.LOCALIZED, androidx.room.ColumnInfo.UNICODE}) @RequiresApi(21) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public static @interface ColumnInfo.Collate {
+ }
+
+ public static final class ColumnInfo.Companion {
field public static final int BINARY = 2; // 0x2
field public static final int BLOB = 5; // 0x5
field public static final String INHERIT_FIELD_NAME = "[field-name]";
@@ -39,69 +69,104 @@
field public static final String VALUE_UNSPECIFIED = "[value-unspecified]";
}
- @IntDef({androidx.room.ColumnInfo.UNSPECIFIED, androidx.room.ColumnInfo.BINARY, androidx.room.ColumnInfo.NOCASE, androidx.room.ColumnInfo.RTRIM, androidx.room.ColumnInfo.LOCALIZED, androidx.room.ColumnInfo.UNICODE}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface ColumnInfo.Collate {
+ @IntDef({androidx.room.ColumnInfo.UNDEFINED, androidx.room.ColumnInfo.TEXT, androidx.room.ColumnInfo.INTEGER, androidx.room.ColumnInfo.REAL, androidx.room.ColumnInfo.BLOB}) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public static @interface ColumnInfo.SQLiteTypeAffinity {
}
- @IntDef({androidx.room.ColumnInfo.UNDEFINED, androidx.room.ColumnInfo.TEXT, androidx.room.ColumnInfo.INTEGER, androidx.room.ColumnInfo.REAL, androidx.room.ColumnInfo.BLOB}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface ColumnInfo.SQLiteTypeAffinity {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Dao {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Dao {
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Database {
- method public abstract androidx.room.AutoMigration[] autoMigrations() default {};
- method public abstract Class<?>[] entities();
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Database {
+ method public abstract androidx.room.AutoMigration[] autoMigrations();
+ method public abstract kotlin.reflect.KClass<?>[] entities();
method public abstract boolean exportSchema() default true;
method public abstract int version();
- method public abstract Class<?>[] views() default {};
+ method public abstract kotlin.reflect.KClass<?>[] views();
+ property public abstract androidx.room.AutoMigration![] autoMigrations;
+ property public abstract kotlin.reflect.KClass<?>![] entities;
+ property public abstract boolean exportSchema;
+ property public abstract int version;
+ property public abstract kotlin.reflect.KClass<?>![] views;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface DatabaseView {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface DatabaseView {
method public abstract String value() default "";
method public abstract String viewName() default "";
+ property public abstract String value;
+ property public abstract String viewName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface Delete {
- method public abstract Class<?> entity() default java.lang.Object.class;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Delete {
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
+ property public abstract kotlin.reflect.KClass<?> entity;
}
- @java.lang.annotation.Repeatable(DeleteColumn.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface DeleteColumn {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface DeleteColumn {
method public abstract String columnName();
method public abstract String tableName();
+ property public abstract String columnName;
+ property public abstract String tableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface DeleteColumn.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface DeleteColumn.Entries {
method public abstract androidx.room.DeleteColumn[] value();
+ property public abstract androidx.room.DeleteColumn![] value;
}
- @java.lang.annotation.Repeatable(DeleteTable.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface DeleteTable {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface DeleteTable {
method public abstract String tableName();
+ property public abstract String tableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface DeleteTable.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface DeleteTable.Entries {
method public abstract androidx.room.DeleteTable[] value();
+ property public abstract androidx.room.DeleteTable![] value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface Embedded {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface Embedded {
method public abstract String prefix() default "";
+ property public abstract String prefix;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Entity {
- method public abstract androidx.room.ForeignKey[] foreignKeys() default {};
- method public abstract String[] ignoredColumns() default {};
- method public abstract androidx.room.Index[] indices() default {};
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Entity {
+ method public abstract androidx.room.ForeignKey[] foreignKeys();
+ method public abstract String[] ignoredColumns();
+ method public abstract androidx.room.Index[] indices();
method public abstract boolean inheritSuperIndices() default false;
- method public abstract String[] primaryKeys() default {};
+ method public abstract String[] primaryKeys();
method public abstract String tableName() default "";
+ property public abstract androidx.room.ForeignKey![] foreignKeys;
+ property public abstract String![] ignoredColumns;
+ property public abstract androidx.room.Index![] indices;
+ property public abstract boolean inheritSuperIndices;
+ property public abstract String![] primaryKeys;
+ property public abstract String tableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface ForeignKey {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface ForeignKey {
method public abstract String[] childColumns();
method public abstract boolean deferred() default false;
- method public abstract Class<?> entity();
- method @androidx.room.ForeignKey.Action public abstract int onDelete() default androidx.room.ForeignKey.NO_ACTION;
- method @androidx.room.ForeignKey.Action public abstract int onUpdate() default androidx.room.ForeignKey.NO_ACTION;
+ method public abstract kotlin.reflect.KClass<?> entity();
+ method public abstract int onDelete() default androidx.room.ForeignKey.NO_ACTION;
+ method public abstract int onUpdate() default androidx.room.ForeignKey.NO_ACTION;
method public abstract String[] parentColumns();
+ property public abstract String![] childColumns;
+ property public abstract boolean deferred;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract int onDelete;
+ property public abstract int onUpdate;
+ property public abstract String![] parentColumns;
+ field public static final int CASCADE = 5; // 0x5
+ field public static final androidx.room.ForeignKey.Companion Companion;
+ field public static final int NO_ACTION = 1; // 0x1
+ field public static final int RESTRICT = 2; // 0x2
+ field public static final int SET_DEFAULT = 4; // 0x4
+ field public static final int SET_NULL = 3; // 0x3
+ }
+
+ @IntDef({androidx.room.ForeignKey.NO_ACTION, androidx.room.ForeignKey.RESTRICT, androidx.room.ForeignKey.SET_NULL, androidx.room.ForeignKey.SET_DEFAULT, androidx.room.ForeignKey.CASCADE}) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public static @interface ForeignKey.Action {
+ }
+
+ public static final class ForeignKey.Companion {
field public static final int CASCADE = 5; // 0x5
field public static final int NO_ACTION = 1; // 0x1
field public static final int RESTRICT = 2; // 0x2
@@ -109,26 +174,34 @@
field public static final int SET_NULL = 3; // 0x3
}
- @IntDef({androidx.room.ForeignKey.NO_ACTION, androidx.room.ForeignKey.RESTRICT, androidx.room.ForeignKey.SET_NULL, androidx.room.ForeignKey.SET_DEFAULT, androidx.room.ForeignKey.CASCADE}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface ForeignKey.Action {
- }
-
- @RequiresApi(16) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Fts3 {
+ @RequiresApi(16) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Fts3 {
method public abstract String tokenizer() default androidx.room.FtsOptions.TOKENIZER_SIMPLE;
- method public abstract String[] tokenizerArgs() default {};
+ method public abstract String[] tokenizerArgs();
+ property public abstract String tokenizer;
+ property public abstract String![] tokenizerArgs;
}
- @RequiresApi(16) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Fts4 {
- method public abstract Class<?> contentEntity() default java.lang.Object.class;
+ @RequiresApi(16) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Fts4 {
+ method public abstract kotlin.reflect.KClass<?> contentEntity() default java.lang.Object;
method public abstract String languageId() default "";
method public abstract androidx.room.FtsOptions.MatchInfo matchInfo() default androidx.room.FtsOptions.MatchInfo.FTS4;
- method public abstract String[] notIndexed() default {};
+ method public abstract String[] notIndexed();
method public abstract androidx.room.FtsOptions.Order order() default androidx.room.FtsOptions.Order.ASC;
- method public abstract int[] prefix() default {};
+ method public abstract int[] prefix();
method public abstract String tokenizer() default androidx.room.FtsOptions.TOKENIZER_SIMPLE;
- method public abstract String[] tokenizerArgs() default {};
+ method public abstract String[] tokenizerArgs();
+ property public abstract kotlin.reflect.KClass<?> contentEntity;
+ property public abstract String languageId;
+ property public abstract androidx.room.FtsOptions.MatchInfo matchInfo;
+ property public abstract String![] notIndexed;
+ property public abstract androidx.room.FtsOptions.Order order;
+ property public abstract int[] prefix;
+ property public abstract String tokenizer;
+ property public abstract String![] tokenizerArgs;
}
- public class FtsOptions {
+ public final class FtsOptions {
+ field public static final androidx.room.FtsOptions INSTANCE;
field public static final String TOKENIZER_ICU = "icu";
field public static final String TOKENIZER_PORTER = "porter";
field public static final String TOKENIZER_SIMPLE = "simple";
@@ -145,14 +218,18 @@
enum_constant public static final androidx.room.FtsOptions.Order DESC;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.CONSTRUCTOR}) public @interface Ignore {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.CONSTRUCTOR}) public @interface Ignore {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface Index {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface Index {
method public abstract String name() default "";
- method public abstract androidx.room.Index.Order[] orders() default {};
+ method public abstract androidx.room.Index.Order[] orders();
method public abstract boolean unique() default false;
method public abstract String[] value();
+ property public abstract String name;
+ property public abstract androidx.room.Index.Order![] orders;
+ property public abstract boolean unique;
+ property public abstract String![] value;
}
public enum Index.Order {
@@ -160,23 +237,39 @@
enum_constant public static final androidx.room.Index.Order DESC;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface Insert {
- method public abstract Class<?> entity() default java.lang.Object.class;
- method @androidx.room.OnConflictStrategy public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Insert {
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
+ method public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract int onConflict;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface Junction {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface Junction {
method public abstract String entityColumn() default "";
method public abstract String parentColumn() default "";
- method public abstract Class<?> value();
+ method public abstract kotlin.reflect.KClass<?> value();
+ property public abstract String entityColumn;
+ property public abstract String parentColumn;
+ property public abstract kotlin.reflect.KClass<?> value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface MapInfo {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface MapInfo {
method public abstract String keyColumn() default "";
method public abstract String valueColumn() default "";
+ property public abstract String keyColumn;
+ property public abstract String valueColumn;
}
- @IntDef({androidx.room.OnConflictStrategy.REPLACE, androidx.room.OnConflictStrategy.ROLLBACK, androidx.room.OnConflictStrategy.ABORT, androidx.room.OnConflictStrategy.FAIL, androidx.room.OnConflictStrategy.IGNORE}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface OnConflictStrategy {
+ @IntDef({androidx.room.OnConflictStrategy.REPLACE, androidx.room.OnConflictStrategy.ROLLBACK, androidx.room.OnConflictStrategy.ABORT, androidx.room.OnConflictStrategy.FAIL, androidx.room.OnConflictStrategy.IGNORE}) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public @interface OnConflictStrategy {
+ field public static final int ABORT = 3; // 0x3
+ field public static final androidx.room.OnConflictStrategy.Companion Companion;
+ field @Deprecated public static final int FAIL = 4; // 0x4
+ field public static final int IGNORE = 5; // 0x5
+ field public static final int REPLACE = 1; // 0x1
+ field @Deprecated public static final int ROLLBACK = 2; // 0x2
+ }
+
+ public static final class OnConflictStrategy.Companion {
field public static final int ABORT = 3; // 0x3
field @Deprecated public static final int FAIL = 4; // 0x4
field public static final int IGNORE = 5; // 0x5
@@ -184,58 +277,74 @@
field @Deprecated public static final int ROLLBACK = 2; // 0x2
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface PrimaryKey {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface PrimaryKey {
method public abstract boolean autoGenerate() default false;
+ property public abstract boolean autoGenerate;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface ProvidedAutoMigrationSpec {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface ProvidedAutoMigrationSpec {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface ProvidedTypeConverter {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface ProvidedTypeConverter {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface Query {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Query {
method public abstract String value();
+ property public abstract String value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface RawQuery {
- method public abstract Class<?>[] observedEntities() default {};
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface RawQuery {
+ method public abstract kotlin.reflect.KClass<?>[] observedEntities();
+ property public abstract kotlin.reflect.KClass<?>![] observedEntities;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface Relation {
- method public abstract androidx.room.Junction associateBy() default @androidx.room.Junction;
- method public abstract Class<?> entity() default java.lang.Object.class;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface Relation {
+ method public abstract androidx.room.Junction associateBy() default androidx.room.Junction(java.lang.Object);
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
method public abstract String entityColumn();
method public abstract String parentColumn();
- method public abstract String[] projection() default {};
+ method public abstract String[] projection();
+ property public abstract androidx.room.Junction associateBy;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract String entityColumn;
+ property public abstract String parentColumn;
+ property public abstract String![] projection;
}
- @java.lang.annotation.Repeatable(RenameColumn.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface RenameColumn {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface RenameColumn {
method public abstract String fromColumnName();
method public abstract String tableName();
method public abstract String toColumnName();
+ property public abstract String fromColumnName;
+ property public abstract String tableName;
+ property public abstract String toColumnName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface RenameColumn.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface RenameColumn.Entries {
method public abstract androidx.room.RenameColumn[] value();
+ property public abstract androidx.room.RenameColumn![] value;
}
- @java.lang.annotation.Repeatable(RenameTable.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface RenameTable {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface RenameTable {
method public abstract String fromTableName();
method public abstract String toTableName();
+ property public abstract String fromTableName;
+ property public abstract String toTableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface RenameTable.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface RenameTable.Entries {
method public abstract androidx.room.RenameTable[] value();
+ property public abstract androidx.room.RenameTable![] value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.TYPE}) public @interface RewriteQueriesToDropUnusedColumns {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.CLASS}) public @interface RewriteQueriesToDropUnusedColumns {
}
public class RoomWarnings {
ctor @Deprecated public RoomWarnings();
field public static final String CANNOT_CREATE_VERIFICATION_DATABASE = "ROOM_CANNOT_CREATE_VERIFICATION_DATABASE";
field public static final String CURSOR_MISMATCH = "ROOM_CURSOR_MISMATCH";
+ field public static final androidx.room.RoomWarnings.Companion Companion;
field public static final String DEFAULT_CONSTRUCTOR = "ROOM_DEFAULT_CONSTRUCTOR";
field public static final String DOES_NOT_IMPLEMENT_EQUALS_HASHCODE = "ROOM_TYPE_DOES_NOT_IMPLEMENT_EQUALS_HASHCODE";
field public static final String INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED = "ROOM_EMBEDDED_ENTITY_INDEX_IS_DROPPED";
@@ -253,23 +362,30 @@
field public static final String RELATION_TYPE_MISMATCH = "ROOM_RELATION_TYPE_MISMATCH";
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.TYPE}) public @interface SkipQueryVerification {
+ public static final class RoomWarnings.Companion {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface Transaction {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.CLASS}) public @interface SkipQueryVerification {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface TypeConverter {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Transaction {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE, java.lang.annotation.ElementType.FIELD}) public @interface TypeConverters {
- method public abstract androidx.room.BuiltInTypeConverters builtInTypeConverters() default @androidx.room.BuiltInTypeConverters;
- method public abstract Class<?>[] value() default {};
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface TypeConverter {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface Update {
- method public abstract Class<?> entity() default java.lang.Object.class;
- method @androidx.room.OnConflictStrategy public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.CLASS}) public @interface TypeConverters {
+ method public abstract androidx.room.BuiltInTypeConverters builtInTypeConverters() default androidx.room.BuiltInTypeConverters();
+ method public abstract kotlin.reflect.KClass<?>[] value();
+ property public abstract androidx.room.BuiltInTypeConverters builtInTypeConverters;
+ property public abstract kotlin.reflect.KClass<?>![] value;
+ }
+
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Update {
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
+ method public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract int onConflict;
}
}
diff --git a/room/room-common/api/restricted_current.ignore b/room/room-common/api/restricted_current.ignore
new file mode 100644
index 0000000..f5c3f3f
--- /dev/null
+++ b/room/room-common/api/restricted_current.ignore
@@ -0,0 +1,71 @@
+// Baseline format: 1.0
+ChangedType: androidx.room.AutoMigration#spec():
+ Method androidx.room.AutoMigration.spec has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.Database#entities():
+ Method androidx.room.Database.entities has changed return type from Class<?>[] to kotlin.reflect.KClass<?>[]
+ChangedType: androidx.room.Database#views():
+ Method androidx.room.Database.views has changed return type from Class<?>[] to kotlin.reflect.KClass<?>[]
+ChangedType: androidx.room.Delete#entity():
+ Method androidx.room.Delete.entity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.ForeignKey#entity():
+ Method androidx.room.ForeignKey.entity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.Fts4#contentEntity():
+ Method androidx.room.Fts4.contentEntity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.Insert#entity():
+ Method androidx.room.Insert.entity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.Junction#value():
+ Method androidx.room.Junction.value has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.RawQuery#observedEntities():
+ Method androidx.room.RawQuery.observedEntities has changed return type from Class<?>[] to kotlin.reflect.KClass<?>[]
+ChangedType: androidx.room.Relation#entity():
+ Method androidx.room.Relation.entity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+ChangedType: androidx.room.TypeConverters#value():
+ Method androidx.room.TypeConverters.value has changed return type from Class<?>[] to kotlin.reflect.KClass<?>[]
+ChangedType: androidx.room.Update#entity():
+ Method androidx.room.Update.entity has changed return type from Class<?> to kotlin.reflect.KClass<?>
+
+
+ChangedValue: androidx.room.AutoMigration#spec():
+ Method androidx.room.AutoMigration.spec has changed value from java.lang.Object.class to java.lang.Object
+ChangedValue: androidx.room.Database#autoMigrations():
+ Method androidx.room.Database.autoMigrations has changed value from {} to nothing
+ChangedValue: androidx.room.Database#views():
+ Method androidx.room.Database.views has changed value from {} to nothing
+ChangedValue: androidx.room.Delete#entity():
+ Method androidx.room.Delete.entity has changed value from java.lang.Object.class to java.lang.Object
+ChangedValue: androidx.room.Entity#foreignKeys():
+ Method androidx.room.Entity.foreignKeys has changed value from {} to nothing
+ChangedValue: androidx.room.Entity#ignoredColumns():
+ Method androidx.room.Entity.ignoredColumns has changed value from {} to nothing
+ChangedValue: androidx.room.Entity#indices():
+ Method androidx.room.Entity.indices has changed value from {} to nothing
+ChangedValue: androidx.room.Entity#primaryKeys():
+ Method androidx.room.Entity.primaryKeys has changed value from {} to nothing
+ChangedValue: androidx.room.Fts3#tokenizerArgs():
+ Method androidx.room.Fts3.tokenizerArgs has changed value from {} to nothing
+ChangedValue: androidx.room.Fts4#contentEntity():
+ Method androidx.room.Fts4.contentEntity has changed value from java.lang.Object.class to java.lang.Object
+ChangedValue: androidx.room.Fts4#notIndexed():
+ Method androidx.room.Fts4.notIndexed has changed value from {} to nothing
+ChangedValue: androidx.room.Fts4#prefix():
+ Method androidx.room.Fts4.prefix has changed value from {} to nothing
+ChangedValue: androidx.room.Fts4#tokenizerArgs():
+ Method androidx.room.Fts4.tokenizerArgs has changed value from {} to nothing
+ChangedValue: androidx.room.Index#orders():
+ Method androidx.room.Index.orders has changed value from {} to nothing
+ChangedValue: androidx.room.Insert#entity():
+ Method androidx.room.Insert.entity has changed value from java.lang.Object.class to java.lang.Object
+ChangedValue: androidx.room.RawQuery#observedEntities():
+ Method androidx.room.RawQuery.observedEntities has changed value from {} to nothing
+ChangedValue: androidx.room.Relation#associateBy():
+ Method androidx.room.Relation.associateBy has changed value from @androidx.room.Junction to androidx.room.Junction(java.lang.Object)
+ChangedValue: androidx.room.Relation#entity():
+ Method androidx.room.Relation.entity has changed value from java.lang.Object.class to java.lang.Object
+ChangedValue: androidx.room.Relation#projection():
+ Method androidx.room.Relation.projection has changed value from {} to nothing
+ChangedValue: androidx.room.TypeConverters#builtInTypeConverters():
+ Method androidx.room.TypeConverters.builtInTypeConverters has changed value from @androidx.room.BuiltInTypeConverters to androidx.room.BuiltInTypeConverters()
+ChangedValue: androidx.room.TypeConverters#value():
+ Method androidx.room.TypeConverters.value has changed value from {} to nothing
+ChangedValue: androidx.room.Update#entity():
+ Method androidx.room.Update.entity has changed value from java.lang.Object.class to java.lang.Object
diff --git a/room/room-common/api/restricted_current.txt b/room/room-common/api/restricted_current.txt
index 51036df..7a4dea4 100644
--- a/room/room-common/api/restricted_current.txt
+++ b/room/room-common/api/restricted_current.txt
@@ -1,15 +1,20 @@
// Signature format: 4.0
package androidx.room {
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface AutoMigration {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface AutoMigration {
method public abstract int from();
- method public abstract Class<?> spec() default java.lang.Object.class;
+ method public abstract kotlin.reflect.KClass<?> spec() default java.lang.Object;
method public abstract int to();
+ property public abstract int from;
+ property public abstract kotlin.reflect.KClass<?> spec;
+ property public abstract int to;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface BuiltInTypeConverters {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface BuiltInTypeConverters {
method public abstract androidx.room.BuiltInTypeConverters.State enums() default androidx.room.BuiltInTypeConverters.State.INHERITED;
method public abstract androidx.room.BuiltInTypeConverters.State uuid() default androidx.room.BuiltInTypeConverters.State.INHERITED;
+ property public abstract androidx.room.BuiltInTypeConverters.State enums;
+ property public abstract androidx.room.BuiltInTypeConverters.State uuid;
}
public enum BuiltInTypeConverters.State {
@@ -18,12 +23,37 @@
enum_constant public static final androidx.room.BuiltInTypeConverters.State INHERITED;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface ColumnInfo {
- method @androidx.room.ColumnInfo.Collate public abstract int collate() default androidx.room.ColumnInfo.UNSPECIFIED;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface ColumnInfo {
+ method public abstract int collate() default androidx.room.ColumnInfo.UNSPECIFIED;
method public abstract String defaultValue() default androidx.room.ColumnInfo.VALUE_UNSPECIFIED;
method public abstract boolean index() default false;
method public abstract String name() default androidx.room.ColumnInfo.INHERIT_FIELD_NAME;
- method @androidx.room.ColumnInfo.SQLiteTypeAffinity public abstract int typeAffinity() default androidx.room.ColumnInfo.UNDEFINED;
+ method public abstract int typeAffinity() default androidx.room.ColumnInfo.UNDEFINED;
+ property public abstract int collate;
+ property public abstract String defaultValue;
+ property public abstract boolean index;
+ property public abstract String name;
+ property public abstract int typeAffinity;
+ field public static final int BINARY = 2; // 0x2
+ field public static final int BLOB = 5; // 0x5
+ field public static final androidx.room.ColumnInfo.Companion Companion;
+ field public static final String INHERIT_FIELD_NAME = "[field-name]";
+ field public static final int INTEGER = 3; // 0x3
+ field @RequiresApi(21) public static final int LOCALIZED = 5; // 0x5
+ field public static final int NOCASE = 3; // 0x3
+ field public static final int REAL = 4; // 0x4
+ field public static final int RTRIM = 4; // 0x4
+ field public static final int TEXT = 2; // 0x2
+ field public static final int UNDEFINED = 1; // 0x1
+ field @RequiresApi(21) public static final int UNICODE = 6; // 0x6
+ field public static final int UNSPECIFIED = 1; // 0x1
+ field public static final String VALUE_UNSPECIFIED = "[value-unspecified]";
+ }
+
+ @IntDef({androidx.room.ColumnInfo.UNSPECIFIED, androidx.room.ColumnInfo.BINARY, androidx.room.ColumnInfo.NOCASE, androidx.room.ColumnInfo.RTRIM, androidx.room.ColumnInfo.LOCALIZED, androidx.room.ColumnInfo.UNICODE}) @RequiresApi(21) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public static @interface ColumnInfo.Collate {
+ }
+
+ public static final class ColumnInfo.Companion {
field public static final int BINARY = 2; // 0x2
field public static final int BLOB = 5; // 0x5
field public static final String INHERIT_FIELD_NAME = "[field-name]";
@@ -39,69 +69,104 @@
field public static final String VALUE_UNSPECIFIED = "[value-unspecified]";
}
- @IntDef({androidx.room.ColumnInfo.UNSPECIFIED, androidx.room.ColumnInfo.BINARY, androidx.room.ColumnInfo.NOCASE, androidx.room.ColumnInfo.RTRIM, androidx.room.ColumnInfo.LOCALIZED, androidx.room.ColumnInfo.UNICODE}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface ColumnInfo.Collate {
+ @IntDef({androidx.room.ColumnInfo.UNDEFINED, androidx.room.ColumnInfo.TEXT, androidx.room.ColumnInfo.INTEGER, androidx.room.ColumnInfo.REAL, androidx.room.ColumnInfo.BLOB}) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public static @interface ColumnInfo.SQLiteTypeAffinity {
}
- @IntDef({androidx.room.ColumnInfo.UNDEFINED, androidx.room.ColumnInfo.TEXT, androidx.room.ColumnInfo.INTEGER, androidx.room.ColumnInfo.REAL, androidx.room.ColumnInfo.BLOB}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface ColumnInfo.SQLiteTypeAffinity {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Dao {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Dao {
- }
-
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Database {
- method public abstract androidx.room.AutoMigration[] autoMigrations() default {};
- method public abstract Class<?>[] entities();
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Database {
+ method public abstract androidx.room.AutoMigration[] autoMigrations();
+ method public abstract kotlin.reflect.KClass<?>[] entities();
method public abstract boolean exportSchema() default true;
method public abstract int version();
- method public abstract Class<?>[] views() default {};
+ method public abstract kotlin.reflect.KClass<?>[] views();
+ property public abstract androidx.room.AutoMigration![] autoMigrations;
+ property public abstract kotlin.reflect.KClass<?>![] entities;
+ property public abstract boolean exportSchema;
+ property public abstract int version;
+ property public abstract kotlin.reflect.KClass<?>![] views;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface DatabaseView {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface DatabaseView {
method public abstract String value() default "";
method public abstract String viewName() default "";
+ property public abstract String value;
+ property public abstract String viewName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface Delete {
- method public abstract Class<?> entity() default java.lang.Object.class;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Delete {
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
+ property public abstract kotlin.reflect.KClass<?> entity;
}
- @java.lang.annotation.Repeatable(DeleteColumn.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface DeleteColumn {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface DeleteColumn {
method public abstract String columnName();
method public abstract String tableName();
+ property public abstract String columnName;
+ property public abstract String tableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface DeleteColumn.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface DeleteColumn.Entries {
method public abstract androidx.room.DeleteColumn[] value();
+ property public abstract androidx.room.DeleteColumn![] value;
}
- @java.lang.annotation.Repeatable(DeleteTable.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface DeleteTable {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface DeleteTable {
method public abstract String tableName();
+ property public abstract String tableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface DeleteTable.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface DeleteTable.Entries {
method public abstract androidx.room.DeleteTable[] value();
+ property public abstract androidx.room.DeleteTable![] value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface Embedded {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface Embedded {
method public abstract String prefix() default "";
+ property public abstract String prefix;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Entity {
- method public abstract androidx.room.ForeignKey[] foreignKeys() default {};
- method public abstract String[] ignoredColumns() default {};
- method public abstract androidx.room.Index[] indices() default {};
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Entity {
+ method public abstract androidx.room.ForeignKey[] foreignKeys();
+ method public abstract String[] ignoredColumns();
+ method public abstract androidx.room.Index[] indices();
method public abstract boolean inheritSuperIndices() default false;
- method public abstract String[] primaryKeys() default {};
+ method public abstract String[] primaryKeys();
method public abstract String tableName() default "";
+ property public abstract androidx.room.ForeignKey![] foreignKeys;
+ property public abstract String![] ignoredColumns;
+ property public abstract androidx.room.Index![] indices;
+ property public abstract boolean inheritSuperIndices;
+ property public abstract String![] primaryKeys;
+ property public abstract String tableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface ForeignKey {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface ForeignKey {
method public abstract String[] childColumns();
method public abstract boolean deferred() default false;
- method public abstract Class<?> entity();
- method @androidx.room.ForeignKey.Action public abstract int onDelete() default androidx.room.ForeignKey.NO_ACTION;
- method @androidx.room.ForeignKey.Action public abstract int onUpdate() default androidx.room.ForeignKey.NO_ACTION;
+ method public abstract kotlin.reflect.KClass<?> entity();
+ method public abstract int onDelete() default androidx.room.ForeignKey.NO_ACTION;
+ method public abstract int onUpdate() default androidx.room.ForeignKey.NO_ACTION;
method public abstract String[] parentColumns();
+ property public abstract String![] childColumns;
+ property public abstract boolean deferred;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract int onDelete;
+ property public abstract int onUpdate;
+ property public abstract String![] parentColumns;
+ field public static final int CASCADE = 5; // 0x5
+ field public static final androidx.room.ForeignKey.Companion Companion;
+ field public static final int NO_ACTION = 1; // 0x1
+ field public static final int RESTRICT = 2; // 0x2
+ field public static final int SET_DEFAULT = 4; // 0x4
+ field public static final int SET_NULL = 3; // 0x3
+ }
+
+ @IntDef({androidx.room.ForeignKey.NO_ACTION, androidx.room.ForeignKey.RESTRICT, androidx.room.ForeignKey.SET_NULL, androidx.room.ForeignKey.SET_DEFAULT, androidx.room.ForeignKey.CASCADE}) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public static @interface ForeignKey.Action {
+ }
+
+ public static final class ForeignKey.Companion {
field public static final int CASCADE = 5; // 0x5
field public static final int NO_ACTION = 1; // 0x1
field public static final int RESTRICT = 2; // 0x2
@@ -109,26 +174,34 @@
field public static final int SET_NULL = 3; // 0x3
}
- @IntDef({androidx.room.ForeignKey.NO_ACTION, androidx.room.ForeignKey.RESTRICT, androidx.room.ForeignKey.SET_NULL, androidx.room.ForeignKey.SET_DEFAULT, androidx.room.ForeignKey.CASCADE}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public static @interface ForeignKey.Action {
- }
-
- @RequiresApi(16) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Fts3 {
+ @RequiresApi(16) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Fts3 {
method public abstract String tokenizer() default androidx.room.FtsOptions.TOKENIZER_SIMPLE;
- method public abstract String[] tokenizerArgs() default {};
+ method public abstract String[] tokenizerArgs();
+ property public abstract String tokenizer;
+ property public abstract String![] tokenizerArgs;
}
- @RequiresApi(16) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface Fts4 {
- method public abstract Class<?> contentEntity() default java.lang.Object.class;
+ @RequiresApi(16) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface Fts4 {
+ method public abstract kotlin.reflect.KClass<?> contentEntity() default java.lang.Object;
method public abstract String languageId() default "";
method public abstract androidx.room.FtsOptions.MatchInfo matchInfo() default androidx.room.FtsOptions.MatchInfo.FTS4;
- method public abstract String[] notIndexed() default {};
+ method public abstract String[] notIndexed();
method public abstract androidx.room.FtsOptions.Order order() default androidx.room.FtsOptions.Order.ASC;
- method public abstract int[] prefix() default {};
+ method public abstract int[] prefix();
method public abstract String tokenizer() default androidx.room.FtsOptions.TOKENIZER_SIMPLE;
- method public abstract String[] tokenizerArgs() default {};
+ method public abstract String[] tokenizerArgs();
+ property public abstract kotlin.reflect.KClass<?> contentEntity;
+ property public abstract String languageId;
+ property public abstract androidx.room.FtsOptions.MatchInfo matchInfo;
+ property public abstract String![] notIndexed;
+ property public abstract androidx.room.FtsOptions.Order order;
+ property public abstract int[] prefix;
+ property public abstract String tokenizer;
+ property public abstract String![] tokenizerArgs;
}
- public class FtsOptions {
+ public final class FtsOptions {
+ field public static final androidx.room.FtsOptions INSTANCE;
field public static final String TOKENIZER_ICU = "icu";
field public static final String TOKENIZER_PORTER = "porter";
field public static final String TOKENIZER_SIMPLE = "simple";
@@ -145,14 +218,18 @@
enum_constant public static final androidx.room.FtsOptions.Order DESC;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.CONSTRUCTOR}) public @interface Ignore {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.CONSTRUCTOR}) public @interface Ignore {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface Index {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface Index {
method public abstract String name() default "";
- method public abstract androidx.room.Index.Order[] orders() default {};
+ method public abstract androidx.room.Index.Order[] orders();
method public abstract boolean unique() default false;
method public abstract String[] value();
+ property public abstract String name;
+ property public abstract androidx.room.Index.Order![] orders;
+ property public abstract boolean unique;
+ property public abstract String![] value;
}
public enum Index.Order {
@@ -160,23 +237,39 @@
enum_constant public static final androidx.room.Index.Order DESC;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface Insert {
- method public abstract Class<?> entity() default java.lang.Object.class;
- method @androidx.room.OnConflictStrategy public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Insert {
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
+ method public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract int onConflict;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({}) public @interface Junction {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={}) public @interface Junction {
method public abstract String entityColumn() default "";
method public abstract String parentColumn() default "";
- method public abstract Class<?> value();
+ method public abstract kotlin.reflect.KClass<?> value();
+ property public abstract String entityColumn;
+ property public abstract String parentColumn;
+ property public abstract kotlin.reflect.KClass<?> value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface MapInfo {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface MapInfo {
method public abstract String keyColumn() default "";
method public abstract String valueColumn() default "";
+ property public abstract String keyColumn;
+ property public abstract String valueColumn;
}
- @IntDef({androidx.room.OnConflictStrategy.REPLACE, androidx.room.OnConflictStrategy.ROLLBACK, androidx.room.OnConflictStrategy.ABORT, androidx.room.OnConflictStrategy.FAIL, androidx.room.OnConflictStrategy.IGNORE}) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface OnConflictStrategy {
+ @IntDef({androidx.room.OnConflictStrategy.REPLACE, androidx.room.OnConflictStrategy.ROLLBACK, androidx.room.OnConflictStrategy.ABORT, androidx.room.OnConflictStrategy.FAIL, androidx.room.OnConflictStrategy.IGNORE}) @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public @interface OnConflictStrategy {
+ field public static final int ABORT = 3; // 0x3
+ field public static final androidx.room.OnConflictStrategy.Companion Companion;
+ field @Deprecated public static final int FAIL = 4; // 0x4
+ field public static final int IGNORE = 5; // 0x5
+ field public static final int REPLACE = 1; // 0x1
+ field @Deprecated public static final int ROLLBACK = 2; // 0x2
+ }
+
+ public static final class OnConflictStrategy.Companion {
field public static final int ABORT = 3; // 0x3
field @Deprecated public static final int FAIL = 4; // 0x4
field public static final int IGNORE = 5; // 0x5
@@ -184,56 +277,71 @@
field @Deprecated public static final int ROLLBACK = 2; // 0x2
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface PrimaryKey {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface PrimaryKey {
method public abstract boolean autoGenerate() default false;
+ property public abstract boolean autoGenerate;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface ProvidedAutoMigrationSpec {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface ProvidedAutoMigrationSpec {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface ProvidedTypeConverter {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface ProvidedTypeConverter {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface Query {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Query {
method public abstract String value();
+ property public abstract String value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.METHOD) public @interface RawQuery {
- method public abstract Class<?>[] observedEntities() default {};
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface RawQuery {
+ method public abstract kotlin.reflect.KClass<?>[] observedEntities();
+ property public abstract kotlin.reflect.KClass<?>![] observedEntities;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD}) public @interface Relation {
- method public abstract androidx.room.Junction associateBy() default @androidx.room.Junction;
- method public abstract Class<?> entity() default java.lang.Object.class;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.FUNCTION}) public @interface Relation {
+ method public abstract androidx.room.Junction associateBy() default androidx.room.Junction(java.lang.Object);
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
method public abstract String entityColumn();
method public abstract String parentColumn();
- method public abstract String[] projection() default {};
+ method public abstract String[] projection();
+ property public abstract androidx.room.Junction associateBy;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract String entityColumn;
+ property public abstract String parentColumn;
+ property public abstract String![] projection;
}
- @java.lang.annotation.Repeatable(RenameColumn.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface RenameColumn {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface RenameColumn {
method public abstract String fromColumnName();
method public abstract String tableName();
method public abstract String toColumnName();
+ property public abstract String fromColumnName;
+ property public abstract String tableName;
+ property public abstract String toColumnName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface RenameColumn.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface RenameColumn.Entries {
method public abstract androidx.room.RenameColumn[] value();
+ property public abstract androidx.room.RenameColumn![] value;
}
- @java.lang.annotation.Repeatable(RenameTable.Entries.class) @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public @interface RenameTable {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public @interface RenameTable {
method public abstract String fromTableName();
method public abstract String toTableName();
+ property public abstract String fromTableName;
+ property public abstract String toTableName;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE) public static @interface RenameTable.Entries {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.CLASS) public static @interface RenameTable.Entries {
method public abstract androidx.room.RenameTable[] value();
+ property public abstract androidx.room.RenameTable![] value;
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.TYPE}) public @interface RewriteQueriesToDropUnusedColumns {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.CLASS}) public @interface RewriteQueriesToDropUnusedColumns {
}
- @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public class RoomMasterTable {
- method public static String! createInsertQuery(String!);
+ @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public final class RoomMasterTable {
+ method public static String createInsertQuery(String hash);
field public static final String CREATE_QUERY = "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)";
field public static final String DEFAULT_ID = "42";
field public static final String NAME = "room_master_table";
@@ -245,6 +353,7 @@
ctor @Deprecated public RoomWarnings();
field public static final String CANNOT_CREATE_VERIFICATION_DATABASE = "ROOM_CANNOT_CREATE_VERIFICATION_DATABASE";
field public static final String CURSOR_MISMATCH = "ROOM_CURSOR_MISMATCH";
+ field public static final androidx.room.RoomWarnings.Companion Companion;
field public static final String DEFAULT_CONSTRUCTOR = "ROOM_DEFAULT_CONSTRUCTOR";
field public static final String DOES_NOT_IMPLEMENT_EQUALS_HASHCODE = "ROOM_TYPE_DOES_NOT_IMPLEMENT_EQUALS_HASHCODE";
field public static final String INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED = "ROOM_EMBEDDED_ENTITY_INDEX_IS_DROPPED";
@@ -262,23 +371,30 @@
field public static final String RELATION_TYPE_MISMATCH = "ROOM_RELATION_TYPE_MISMATCH";
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.TYPE}) public @interface SkipQueryVerification {
+ public static final class RoomWarnings.Companion {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface Transaction {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.CLASS}) public @interface SkipQueryVerification {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD}) public @interface TypeConverter {
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Transaction {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.PARAMETER, java.lang.annotation.ElementType.TYPE, java.lang.annotation.ElementType.FIELD}) public @interface TypeConverters {
- method public abstract androidx.room.BuiltInTypeConverters builtInTypeConverters() default @androidx.room.BuiltInTypeConverters;
- method public abstract Class<?>[] value() default {};
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface TypeConverter {
}
- @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) public @interface Update {
- method public abstract Class<?> entity() default java.lang.Object.class;
- method @androidx.room.OnConflictStrategy public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets={kotlin.annotation.AnnotationTarget.FUNCTION, kotlin.annotation.AnnotationTarget.VALUE_PARAMETER, kotlin.annotation.AnnotationTarget.FIELD, kotlin.annotation.AnnotationTarget.CLASS}) public @interface TypeConverters {
+ method public abstract androidx.room.BuiltInTypeConverters builtInTypeConverters() default androidx.room.BuiltInTypeConverters();
+ method public abstract kotlin.reflect.KClass<?>[] value();
+ property public abstract androidx.room.BuiltInTypeConverters builtInTypeConverters;
+ property public abstract kotlin.reflect.KClass<?>![] value;
+ }
+
+ @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets=kotlin.annotation.AnnotationTarget.FUNCTION) public @interface Update {
+ method public abstract kotlin.reflect.KClass<?> entity() default java.lang.Object;
+ method public abstract int onConflict() default androidx.room.OnConflictStrategy.ABORT;
+ property public abstract kotlin.reflect.KClass<?> entity;
+ property public abstract int onConflict;
}
}
diff --git a/room/room-common/build.gradle b/room/room-common/build.gradle
index dee88d6..f05c7b7 100644
--- a/room/room-common/build.gradle
+++ b/room/room-common/build.gradle
@@ -24,7 +24,7 @@
dependencies {
api("androidx.annotation:annotation:1.1.0")
- testImplementation(libs.kotlinStdlib)
+ api(libs.kotlinStdlibJdk8)
testImplementation(libs.junit)
testImplementation(libs.mockitoCore)
testImplementation(libs.guava)
diff --git a/room/room-common/src/main/java/androidx/room/AutoMigration.kt b/room/room-common/src/main/java/androidx/room/AutoMigration.kt
index b6bc1b7..c60ddb8 100644
--- a/room/room-common/src/main/java/androidx/room/AutoMigration.kt
+++ b/room/room-common/src/main/java/androidx/room/AutoMigration.kt
@@ -14,106 +14,105 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
+import kotlin.reflect.KClass
/**
* Declares an automatic migration on a Database.
- * <p>
- * An automatic migration is a {@link androidx.room.migration.Migration Migration} that is generated
- * via the use of database schema files at two versions of a {@link androidx.room.RoomDatabase
- * RoomDatabase}. Room automatically detects changes on the database between these two schemas,
- * and constructs a {@link androidx.room.migration.Migration Migration} to migrate between the
+ *
+ * An automatic migration is a [androidx.room.migration.Migration] that is generated
+ * via the use of database schema files at two versions of a [androidx.room.RoomDatabase].
+ * Room automatically detects changes on the database between these two schemas,
+ * and constructs a [androidx.room.migration.Migration] to migrate between the
* two versions. In case of ambiguous scenarios (e.g. column/table rename/deletes), additional
* information is required, and can be provided via the
- * {@link androidx.room.migration.AutoMigrationSpec AutoMigrationSpec} property.
- * <p>
+ * [androidx.room.migration.AutoMigrationSpec] property.
+ *
* An auto migration must define the 'from' and 'to' versions of the schema for which a migration
* implementation will be generated. A class that implements AutoMigrationSpec can be declared in
- * the {@link androidx.room.migration.AutoMigrationSpec AutoMigrationSpec} property to either
+ * the [androidx.room.migration.AutoMigrationSpec] property to either
* provide more information for ambiguous scenarios or execute callbacks during the migration.
- * <p>
+ *
* If there are any column/table renames/deletes between the two versions of the database
* provided then it is said that there are ambiguous scenarios in the migration. In
- * such scenarios then an {@link androidx.room.migration.AutoMigrationSpec AutoMigrationSpec} is
+ * such scenarios then an [androidx.room.migration.AutoMigrationSpec] is
* required and the class provided must be annotated with the relevant change annotation(s):
- * {@link RenameColumn}, {@link RenameTable}, {@link DeleteColumn} or {@link DeleteTable}. When
- * no ambiguous scenario is present, then the {@link androidx.room.migration.AutoMigrationSpec
- * AutoMigrationSpec} property is optional.
- * <p>
- * If an auto migration is defined for a database, then {@link androidx.room.Database#exportSchema}
- * must be set to true.
- * <p>
- * Example:
- * <pre>
- * {@literal @}Database(
- * version = MusicDatabase.LATEST_VERSION,
- * entities = {
- * Song.class,
- * Artist.class
- * },
- * autoMigrations = {
- * {@literal @}AutoMigration (
- * from = 1,
- * to = 2
- * ),
- * {@literal @}AutoMigration (
- * from = 2,
- * to = 3,
- * spec = MusicDatabase.MyExampleAutoMigration.class
- * )
- * },
- * exportSchema = true
- * )
- * public abstract class MusicDatabase extends RoomDatabase {
- * static final int LATEST_VERSION = 3;
+ * [RenameColumn], [RenameTable], [DeleteColumn] or [DeleteTable]. When
+ * no ambiguous scenario is present, then the [androidx.room.migration.AutoMigrationSpec]
+ * property is optional.
*
- * {@literal @}DeleteTable(deletedTableName = "Album")
- * {@literal @}RenameTable(fromTableName = "Singer", toTableName = "Artist")
- * {@literal @}RenameColumn(
- * tableName = "Song",
- * fromColumnName = "songName",
- * toColumnName = "songTitle"
+ * If an auto migration is defined for a database, then [androidx.room.Database.exportSchema]
+ * must be set to true.
+ *
+ * Example:
+ *
+ * ```
+ * @Database(
+ * version = MusicDatabase.LATEST_VERSION,
+ * entities = [
+ * Song.class,
+ * Artist.class
+ * ],
+ * autoMigrations = [
+ * @AutoMigration (
+ * from = 1,
+ * to = 2
+ * ),
+ * @AutoMigration (
+ * from = 2,
+ * to = 3,
+ * spec = MusicDatabase.MyExampleAutoMigration::class
+ * )
+ * ],
+ * exportSchema = true
+ * )
+ * abstract class MusicDatabase : RoomDatabase() {
+ * const val LATEST_VERSION = 3
+ *
+ * @DeleteTable(deletedTableName = "Album")
+ * @RenameTable(fromTableName = "Singer", toTableName = "Artist")
+ * @RenameColumn(
+ * tableName = "Song",
+ * fromColumnName = "songName",
+ * toColumnName = "songTitle"
* )
- * {@literal @}DeleteColumn(fromTableName = "Song", deletedColumnName = "genre")
- * static class MyExampleAutoMigration implements AutoMigrationSpec {
- * {@literal @}Override
- * default void onPostMigrate({@literal @}NonNull SupportSQLiteDatabase db) {
- * // Invoked once auto migration is done
- * }
+ * @DeleteColumn(fromTableName = "Song", deletedColumnName = "genre")
+ * class MyExampleAutoMigration : AutoMigrationSpec {
+ * @Override
+ * override fun onPostMigrate(db: SupportSQLiteDatabase) {
+ * // Invoked once auto migration is done
+ * }
* }
* }
- * </pre>
+ * ```
*
- * @see androidx.room.RoomDatabase RoomDatabase
- * @see androidx.room.migration.AutoMigrationSpec AutoMigrationSpec
+ * @see [androidx.room.RoomDatabase]
+ * @see [androidx.room.migration.AutoMigrationSpec]
*/
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface AutoMigration {
+
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+
+public annotation class AutoMigration(
/**
* Version of the database schema to migrate from.
*
* @return Version number of the database to migrate from.
*/
- int from();
+ val from: Int,
/**
* Version of the database schema to migrate to.
*
* @return Version number of the database to migrate to.
*/
- int to();
+ val to: Int,
/**
* User implemented custom auto migration spec.
*
* @return The auto migration specification or none if the user has not implemented a spec
*/
- Class<?> spec() default Object.class;
-}
+ val spec: KClass<*> = Any::class
+)
diff --git a/room/room-common/src/main/java/androidx/room/BuiltInTypeConverters.kt b/room/room-common/src/main/java/androidx/room/BuiltInTypeConverters.kt
index 5e206a4..3be4055 100644
--- a/room/room-common/src/main/java/androidx/room/BuiltInTypeConverters.kt
+++ b/room/room-common/src/main/java/androidx/room/BuiltInTypeConverters.kt
@@ -14,11 +14,7 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
* Flags to turn on/off extra type converters provided by Room.
@@ -27,35 +23,35 @@
* default, these type converters are enabled but have lower priority than user provided type
* converters.
*
- * You can set these flags in the {@link TypeConverters} annotation to turn them off / on. It
+ * You can set these flags in the [TypeConverters] annotation to turn them off / on. It
* might be useful if you want to have more strict control over how these types are saved into
* the database.
*/
-@Target({})
-@Retention(RetentionPolicy.CLASS)
-public @interface BuiltInTypeConverters {
+@Target(allowedTargets = []) // Complex annotation target
+@Retention(AnnotationRetention.BINARY)
+public annotation class BuiltInTypeConverters(
/**
* Controls whether Room can generate a TypeConverter for enum types and use their
- * {@code name()} in the database.
+ * `name()` in the database.
*
- * By default, it is set to {@link State#INHERITED} (on by default unless set to another
+ * By default, it is set to [State.INHERITED] (on by default unless set to another
* value in a higher scope).
*/
- State enums() default State.INHERITED;
+ val enums: State = State.INHERITED,
/**
- * Controls whether Room can generate a TypeConverter for {@link java.util.UUID} and use its
- * {@code byte[]} representation while saving it into database.
+ * Controls whether Room can generate a TypeConverter for [java.util.UUID] and use its
+ * `byte[]` representation while saving it into database.
*
- * By default, it is set to {@link State#INHERITED} (on by default unless set to another
+ * By default, it is set to [State.INHERITED] (on by default unless set to another
* value in a higher scope).
*/
- State uuid() default State.INHERITED;
-
+ val uuid: State = State.INHERITED,
+) {
/**
* Control flags for built in converters.
*/
- enum State {
+ public enum class State {
/**
* Room can use the built in converter.
*/
@@ -65,9 +61,9 @@
*/
DISABLED,
/**
- * The value is inherited from the higher scope. See {@link TypeConverters} documentation
- * to learn more about {@code TypeConverter} scoping.
- * If this value is never set, it defaults to {@link #ENABLED}.
+ * The value is inherited from the higher scope. See [TypeConverters] documentation
+ * to learn more about [TypeConverter] scoping.
+ * If this value is never set, it defaults to [ENABLED].
*/
INHERITED
}
diff --git a/room/room-common/src/main/java/androidx/room/ColumnInfo.kt b/room/room-common/src/main/java/androidx/room/ColumnInfo.kt
index ee2adc1..c3817a0d 100644
--- a/room/room-common/src/main/java/androidx/room/ColumnInfo.kt
+++ b/room/room-common/src/main/java/androidx/room/ColumnInfo.kt
@@ -14,198 +14,203 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import androidx.annotation.IntDef;
-import androidx.annotation.RequiresApi;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import androidx.annotation.IntDef
+import androidx.annotation.RequiresApi
/**
* Allows specific customization about the column associated with this field.
- * <p>
+ *
* For example, you can specify a column name for the field or change the column's type affinity.
*/
-@Target({ElementType.FIELD, ElementType.METHOD})
-@Retention(RetentionPolicy.CLASS)
-public @interface ColumnInfo {
+@Target(AnnotationTarget.FIELD, AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class ColumnInfo(
/**
* Name of the column in the database. Defaults to the field name if not set.
*
* @return Name of the column in the database.
*/
- String name() default INHERIT_FIELD_NAME;
+ val name: String = INHERIT_FIELD_NAME,
/**
* The type affinity for the column, which will be used when constructing the database.
- * <p>
- * If it is not specified, the value defaults to {@link #UNDEFINED} and Room resolves it based
- * on the field's type and available TypeConverters.
- * <p>
- * See <a href="https://www.sqlite.org/datatype3.html">SQLite types documentation</a> for
- * details.
*
- * @return The type affinity of the column. This is either {@link #UNDEFINED}, {@link #TEXT},
- * {@link #INTEGER}, {@link #REAL}, or {@link #BLOB}.
+ * If it is not specified, the value defaults to [UNDEFINED] and Room resolves it based
+ * on the field's type and available TypeConverters.
+ *
+ * See [SQLite types documentation](https://www.sqlite.org/datatype3.html) for details.
+ *
+ * @return The type affinity of the column. This is either [UNDEFINED], [TEXT],
+ * [INTEGER], [REAL], or [BLOB].
*/
- @SuppressWarnings("unused") @SQLiteTypeAffinity int typeAffinity() default UNDEFINED;
+ @SuppressWarnings("unused")
+ @SQLiteTypeAffinity
+ val typeAffinity: Int = UNDEFINED,
/**
* Convenience method to index the field.
- * <p>
- * If you would like to create a composite index instead, see: {@link Index}.
+ *
+ * If you would like to create a composite index instead, see: [Index].
*
* @return True if this field should be indexed, false otherwise. Defaults to false.
*/
- boolean index() default false;
+ val index: Boolean = false,
/**
* The collation sequence for the column, which will be used when constructing the database.
- * <p>
- * The default value is {@link #UNSPECIFIED}. In that case, Room does not add any
- * collation sequence to the column, and SQLite treats it like {@link #BINARY}.
*
- * @return The collation sequence of the column. This is either {@link #UNSPECIFIED},
- * {@link #BINARY}, {@link #NOCASE}, {@link #RTRIM}, {@link #LOCALIZED} or {@link #UNICODE}.
+ * The default value is [UNSPECIFIED]. In that case, Room does not add any
+ * collation sequence to the column, and SQLite treats it like [BINARY].
+ *
+ * @return The collation sequence of the column. This is either [UNSPECIFIED],
+ * [BINARY], [NOCASE], [RTRIM], [LOCALIZED] or [UNICODE].
*/
- @Collate int collate() default UNSPECIFIED;
+ @Collate
+ val collate: Int = UNSPECIFIED,
/**
* The default value for this column.
- * <pre>
- * {@literal @}ColumnInfo(defaultValue = "No name")
- * public String name;
*
- * {@literal @}ColumnInfo(defaultValue = "0")
- * public int flag;
- * </pre>
- * <p>
- * Note that the default value you specify here will <em>NOT</em> be used if you simply
- * insert the {@link Entity} with {@link Insert @Insert}. In that case, any value assigned in
- * Java/Kotlin will be used. Use {@link Query @Query} with an <code>INSERT</code> statement
+ * ```
+ * @ColumnInfo(defaultValue = "No name")
+ * public name: String
+ *
+ * @ColumnInfo(defaultValue = "0")
+ * public flag: Int
+ * ```
+ *
+ * Note that the default value you specify here will _NOT_ be used if you simply
+ * insert the [Entity] with [Insert]. In that case, any value assigned in
+ * Java/Kotlin will be used. Use [Query] with an `INSERT` statement
* and skip this column there in order to use this default value.
- * </p>
- * <p>
+ *
* NULL, CURRENT_TIMESTAMP and other SQLite constant values are interpreted as such. If you want
* to use them as strings for some reason, surround them with single-quotes.
- * </p>
- * <pre>
- * {@literal @}ColumnInfo(defaultValue = "NULL")
- * {@literal @}Nullable
- * public String description;
*
- * {@literal @}ColumnInfo(defaultValue = "'NULL'")
- * {@literal @}NonNull
- * public String name;
- * </pre>
- * <p>
+ * ```
+ * @ColumnInfo(defaultValue = "NULL")
+ * public description: String?
+ *
+ * @ColumnInfo(defaultValue = "'NULL'")
+ * public name: String
+ * ```
+ *
* You can also use constant expressions by surrounding them with parentheses.
- * </p>
- * <pre>
- * {@literal @}CoumnInfo(defaultValue = "('Created at' || CURRENT_TIMESTAMP)")
- * public String notice;
- * </pre>
+ *
+ * ```
+ * @ColumnInfo(defaultValue = "('Created at' || CURRENT_TIMESTAMP)")
+ * public notice: String
+ * ```
*
* @return The default value for this column.
- * @see #VALUE_UNSPECIFIED
+ * @see [VALUE_UNSPECIFIED]
*/
- String defaultValue() default VALUE_UNSPECIFIED;
+ val defaultValue: String = VALUE_UNSPECIFIED,
+) {
+ /**
+ * The SQLite column type constants that can be used in [typeAffinity()]
+ */
+ @IntDef(UNDEFINED, TEXT, INTEGER, REAL, BLOB)
+ @Retention(AnnotationRetention.BINARY)
+ public annotation class SQLiteTypeAffinity
- /**
- * Constant to let Room inherit the field name as the column name. If used, Room will use the
- * field name as the column name.
- */
- String INHERIT_FIELD_NAME = "[field-name]";
-
- /**
- * Undefined type affinity. Will be resolved based on the type.
- *
- * @see #typeAffinity()
- */
- int UNDEFINED = 1;
- /**
- * Column affinity constant for strings.
- *
- * @see #typeAffinity()
- */
- int TEXT = 2;
- /**
- * Column affinity constant for integers or booleans.
- *
- * @see #typeAffinity()
- */
- int INTEGER = 3;
- /**
- * Column affinity constant for floats or doubles.
- *
- * @see #typeAffinity()
- */
- int REAL = 4;
- /**
- * Column affinity constant for binary data.
- *
- * @see #typeAffinity()
- */
- int BLOB = 5;
-
- /**
- * The SQLite column type constants that can be used in {@link #typeAffinity()}
- */
- @IntDef({UNDEFINED, TEXT, INTEGER, REAL, BLOB})
- @Retention(RetentionPolicy.CLASS)
- @interface SQLiteTypeAffinity {
- }
-
- /**
- * Collation sequence is not specified. The match will behave like {@link #BINARY}.
- *
- * @see #collate()
- */
- int UNSPECIFIED = 1;
- /**
- * Collation sequence for case-sensitive match.
- *
- * @see #collate()
- */
- int BINARY = 2;
- /**
- * Collation sequence for case-insensitive match.
- *
- * @see #collate()
- */
- int NOCASE = 3;
- /**
- * Collation sequence for case-sensitive match except that trailing space characters are
- * ignored.
- *
- * @see #collate()
- */
- int RTRIM = 4;
- /**
- * Collation sequence that uses system's current locale.
- *
- * @see #collate()
- */
@RequiresApi(21)
- int LOCALIZED = 5;
- /**
- * Collation sequence that uses Unicode Collation Algorithm.
- *
- * @see #collate()
- */
- @RequiresApi(21)
- int UNICODE = 6;
+ @IntDef(UNSPECIFIED, BINARY, NOCASE, RTRIM, LOCALIZED, UNICODE)
+ @Retention(AnnotationRetention.BINARY)
+ public annotation class Collate
- @IntDef({UNSPECIFIED, BINARY, NOCASE, RTRIM, LOCALIZED, UNICODE})
- @Retention(RetentionPolicy.CLASS)
- @interface Collate {
+ public companion object {
+ /**
+ * Constant to let Room inherit the field name as the column name. If used, Room will use
+ * the field name as the column name.
+ */
+ public const val INHERIT_FIELD_NAME: String = "[field-name]"
+
+ /**
+ * Undefined type affinity. Will be resolved based on the type.
+ *
+ * @see typeAffinity()
+ */
+ public const val UNDEFINED: Int = 1
+
+ /**
+ * Column affinity constant for strings.
+ *
+ * @see typeAffinity()
+ */
+ public const val TEXT: Int = 2
+
+ /**
+ * Column affinity constant for integers or booleans.
+ *
+ * @see typeAffinity()
+ */
+ public const val INTEGER: Int = 3
+
+ /**
+ * Column affinity constant for floats or doubles.
+ *
+ * @see typeAffinity()
+ */
+ public const val REAL: Int = 4
+
+ /**
+ * Column affinity constant for binary data.
+ *
+ * @see typeAffinity()
+ */
+ public const val BLOB: Int = 5
+
+ /**
+ * Collation sequence is not specified. The match will behave like [BINARY].
+ *
+ * @see collate()
+ */
+ public const val UNSPECIFIED: Int = 1
+
+ /**
+ * Collation sequence for case-sensitive match.
+ *
+ * @see collate()
+ */
+ public const val BINARY: Int = 2
+
+ /**
+ * Collation sequence for case-insensitive match.
+ *
+ * @see collate()
+ */
+ public const val NOCASE: Int = 3
+
+ /**
+ * Collation sequence for case-sensitive match except that trailing space characters are
+ * ignored.
+ *
+ * @see collate()
+ */
+ public const val RTRIM: Int = 4
+
+ /**
+ * Collation sequence that uses system's current locale.
+ *
+ * @see collate()
+ */
+ @RequiresApi(21)
+ public const val LOCALIZED: Int = 5
+
+ /**
+ * Collation sequence that uses Unicode Collation Algorithm.
+ *
+ * @see collate()
+ */
+ @RequiresApi(21)
+ public const val UNICODE: Int = 6
+
+ /**
+ * A constant for [defaultValue()] that makes the column to have no default value.
+ */
+ public const val VALUE_UNSPECIFIED: String = "[value-unspecified]"
}
-
- /**
- * A constant for {@link #defaultValue()} that makes the column to have no default value.
- */
- String VALUE_UNSPECIFIED = "[value-unspecified]";
-}
+}
\ No newline at end of file
diff --git a/room/room-common/src/main/java/androidx/room/Dao.kt b/room/room-common/src/main/java/androidx/room/Dao.kt
index c62c641..d2f4e7b 100644
--- a/room/room-common/src/main/java/androidx/room/Dao.kt
+++ b/room/room-common/src/main/java/androidx/room/Dao.kt
@@ -14,34 +14,28 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
* Marks the class as a Data Access Object.
- * <p>
+ *
* Data Access Objects are the main classes where you define your database interactions. They can
* include a variety of query methods.
- * <p>
- * The class marked with {@code @Dao} should either be an interface or an abstract class. At compile
+ *
+ * The class marked with `@Dao` should either be an interface or an abstract class. At compile
* time, Room will generate an implementation of this class when it is referenced by a
- * {@link Database}.
- * <p>
- * An abstract {@code @Dao} class can optionally have a constructor that takes a {@link Database}
+ * [Database].
+ *
+ * An abstract `@Dao` class can optionally have a constructor that takes a [Database]
* as its only parameter.
- * <p>
- * It is recommended to have multiple {@code Dao} classes in your codebase depending on the tables
+ *
+ * It is recommended to have multiple `Dao` classes in your codebase depending on the tables
* they touch.
*
- * @see Query
- * @see Delete
- * @see Insert
+ * @see [Query]
+ * @see [Delete]
+ * @see [Insert]
*/
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface Dao {
-}
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Dao
diff --git a/room/room-common/src/main/java/androidx/room/Database.kt b/room/room-common/src/main/java/androidx/room/Database.kt
index e667c8f..4b5eac1 100644
--- a/room/room-common/src/main/java/androidx/room/Database.kt
+++ b/room/room-common/src/main/java/androidx/room/Database.kt
@@ -14,67 +14,67 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import kotlin.reflect.KClass
/**
* Marks a class as a RoomDatabase.
- * <p>
- * The class should be an abstract class and extend {@link androidx.room.RoomDatabase RoomDatabase}.
- * <p>
+ *
+ * The class should be an abstract class and extend [androidx.room.RoomDatabase].
+ *
* You can receive an implementation of the class via
- * {@link androidx.room.Room#databaseBuilder Room.databaseBuilder} or
- * {@link androidx.room.Room#inMemoryDatabaseBuilder Room.inMemoryDatabaseBuilder}.
- * <p>
- * <pre>
- * // Song and Album are classes annotated with {@literal @}Entity.
- * {@literal @}Database(version = 1, entities = {Song.class, Album.class})
- * abstract class MusicDatabase extends RoomDatabase {
- * // SongDao is a class annotated with {@literal @}Dao.
- * abstract public SongDao getSongDao();
- * // AlbumDao is a class annotated with {@literal @}Dao.
- * abstract public ArtistDao getArtistDao();
- * // SongAlbumDao is a class annotated with {@literal @}Dao.
- * abstract public SongAlbumDao getSongAlbumDao();
+ * [androidx.room.Room.databaseBuilder] or
+ * [androidx.room.Room.inMemoryDatabaseBuilder].
+ *
+ * ```
+ * // Song and Album are classes annotated with @Entity.
+ * @Database(version = 1, entities = {Song.class, Album.class})
+ * abstract class MusicDatabase : RoomDatabase {
+ * // SongDao is a class annotated with @Dao.
+ * abstract fun getSongDao(): SongDao
+ *
+ * // AlbumDao is a class annotated with @Dao.
+ * abstract fun getArtistDao(): ArtistDao
+ *
+ * // SongAlbumDao is a class annotated with @Dao.
+ * abstract fun getSongAlbumDao(): SongAlbumDao
* }
- * </pre>
+ * ```
+ *
* The example above defines a class that has 2 tables and 3 DAO classes that are used to access it.
- * There is no limit on the number of {@link Entity} or {@link Dao} classes but they must be unique
+ * There is no limit on the number of [Entity] or [Dao] classes but they must be unique
* within the Database.
- * <p>
+ *
* Instead of running queries on the database directly, you are highly recommended to create
- * {@link Dao} classes. Using Dao classes will allow you to abstract the database communication in
+ * [Dao] classes. Using Dao classes will allow you to abstract the database communication in
* a more logical layer which will be much easier to mock in tests (compared to running direct
- * SQL queries). It also automatically does the conversion from {@code Cursor} to your application
+ * SQL queries). It also automatically does the conversion from `Cursor` to your application
* data classes so you don't need to deal with lower level database APIs for most of your data
* access.
- * <p>
- * Room also verifies all of your queries in {@link Dao} classes while the application is being
- * compiled so that if there is a problem in one of the queries, you will be notified instantly.
- * <p>
- * To automatically generate a migration between two versions of the database, assuming you have
- * the relevant schema files, you are recommended to use {@link AutoMigration} annotations. Note
- * that if an autoMigration is defined in a database, {@code exportSchema} must be {@code true}.
*
- * @see Dao
- * @see Entity
- * @see AutoMigration
- * @see androidx.room.RoomDatabase RoomDatabase
+ * Room also verifies all of your queries in [Dao] classes while the application is being
+ * compiled so that if there is a problem in one of the queries, you will be notified instantly.
+ *
+ * To automatically generate a migration between two versions of the database, assuming you have
+ * the relevant schema files, you are recommended to use [AutoMigration] annotations. Note
+ * that if an autoMigration is defined in a database, `exportSchema` must be `true`.
+ *
+ * @see [Dao]
+ * @see [Entity]
+ * @see [AutoMigration]
+ * @see [androidx.room.RoomDatabase]
*/
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface Database {
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Database(
/**
* The list of entities included in the database. Each entity turns into a table in the
* database.
*
* @return The list of entities in the database.
*/
- Class<?>[] entities();
+ val entities: Array<KClass<*>> = [],
/**
* The list of database views included in the database. Each class turns into a view in the
@@ -82,42 +82,42 @@
*
* @return The list of database views.
*/
- Class<?>[] views() default {};
+ val views: Array<KClass<*>> = [],
/**
* The database version.
*
* @return The database version.
*/
- int version();
+ val version: Int,
/**
- * You can set the annotation processor argument ({@code room.schemaLocation}) to tell Room to
+ * You can set the annotation processor argument (`room.schemaLocation`) to tell Room to
* export the database schema into a folder. Even though it is not mandatory, it is a good
* practice to have version history of your schema in your codebase and you should commit the
* schema files into your version control system (but don't ship them with your app!).
- * <p>
- * When {@code room.schemaLocation} is set, Room will check this variable and if it is set to
- * {@code true}, the database schema will be exported into the given folder.
- * <p>
- * {@code exportSchema} is {@code true} by default but you can disable it for databases when
+ *
+ * When `room.schemaLocation` is set, Room will check this variable and if it is set to
+ * `true`, the database schema will be exported into the given folder.
+ *
+ * Value of `exportSchema` is `true` by default but you can disable it for databases when
* you don't want to keep history of versions (like an in-memory only database).
*
* @return Whether the schema should be exported to the given folder when the
- * {@code room.schemaLocation} argument is set. Defaults to {@code true}.
+ * `room.schemaLocation` argument is set. Defaults to `true`.
*/
- boolean exportSchema() default true;
+ val exportSchema: Boolean = true,
/**
* List of AutoMigrations that can be performed on this Database.
*
- * See {@link AutoMigration} for example code usage.
+ * See [AutoMigration] for example code usage.
*
- * For more complicated cases not covered by {@link AutoMigration}, runtime defined
- * {@link androidx.room.migration.Migration Migration} added with
- * {@link androidx.room.RoomDatabase.Builder#addMigrations addMigrations} can still be used.
+ * For more complicated cases not covered by [AutoMigration], runtime defined
+ * [androidx.room.migration.Migration] added with
+ * [androidx.room.RoomDatabase.Builder.addMigrations] can still be used.
*
- * @return List of AutoMigration annotations.
+ * @return List of [AutoMigration] annotations.
*/
- AutoMigration[] autoMigrations() default {};
-}
+ val autoMigrations: Array<AutoMigration> = []
+)
diff --git a/room/room-common/src/main/java/androidx/room/DatabaseView.kt b/room/room-common/src/main/java/androidx/room/DatabaseView.kt
index 7d7f417..75cf74a 100644
--- a/room/room-common/src/main/java/androidx/room/DatabaseView.kt
+++ b/room/room-common/src/main/java/androidx/room/DatabaseView.kt
@@ -14,60 +14,57 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
* Marks a class as an SQLite view.
- * <p>
- * The value of the annotation is a SELECT query used when the view is created.
- * <p>
- * The class will behave like normal POJO when it is used in a {@link Dao}. You can SELECT FROM a
- * {@link DatabaseView} similar to an {@link Entity}, but you can not INSERT, DELETE or UPDATE
- * into a {@link DatabaseView}.
- * <p>
- * Similar to an {@link Entity}, you can use {@link ColumnInfo} and {@link Embedded} inside to
- * customize the data class.
- * <p>
- * Example:
- * <pre>
- * {@literal @}DatabaseView(
- * "SELECT id, name, release_year FROM Song " +
- * "WHERE release_year >= 1990 AND release_year <= 1999")
- * public class SongFrom90s {
- * long id;
- * String name;
- * {@literal @}ColumnInfo(name = "release_year")
- * private int releaseYear;
- * }
- * </pre>
- * <p>
- * Views have to be registered to a RoomDatabase via {@link Database#views}.
*
- * @see Dao
- * @see Database
- * @see ColumnInfo
- * @see Embedded
+ * The value of the annotation is a SELECT query used when the view is created.
+ *
+ * The class will behave like normal POJO when it is used in a [Dao]. You can SELECT FROM a
+ * [DatabaseView] similar to an [Entity], but you can not INSERT, DELETE or UPDATE
+ * into a [DatabaseView].
+ *
+ * Similar to an [Entity], you can use [ColumnInfo] and [Embedded] inside to
+ * customize the data class.
+ *
+ * Example:
+ *
+ * ```
+ * @DatabaseView(
+ * "SELECT id, name, release_year FROM Song " +
+ * "WHERE release_year >= 1990 AND release_year <= 1999"
+ * )
+ * data class SongFrom90s (
+ * val id: Long,
+ * val name: String,
+ * @ColumnInfo(name = "release_year")
+ * val releaseYear: Int
+ * )
+ * ```
+ *
+ * Views have to be registered to a RoomDatabase via [Database.views].
+ *
+ * @see [Dao]
+ * @see [Database]
+ * @see [ColumnInfo]
+ * @see [Embedded]
*/
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface DatabaseView {
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class DatabaseView(
/**
* The SELECT query.
*
* @return The SELECT query.
*/
- String value() default "";
+ val value: String = "",
/**
* The view name in the SQLite database. If not set, it defaults to the class name.
*
* @return The SQLite view name.
*/
- String viewName() default "";
-}
+ val viewName: String = ""
+)
diff --git a/room/room-common/src/main/java/androidx/room/Delete.kt b/room/room-common/src/main/java/androidx/room/Delete.kt
index 7daa422..176fd26 100644
--- a/room/room-common/src/main/java/androidx/room/Delete.kt
+++ b/room/room-common/src/main/java/androidx/room/Delete.kt
@@ -14,76 +14,76 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import kotlin.reflect.KClass
/**
- * Marks a method in a {@link Dao} annotated class as a delete method.
- * <p>
+ * Marks a method in a [Dao] annotated class as a delete method.
+ *
* The implementation of the method will delete its parameters from the database.
- * <p>
- * All of the parameters of the Delete method must either be classes annotated with {@link Entity}
+ *
+ * All of the parameters of the Delete method must either be classes annotated with [Entity]
* or collections/array of it.
- * <p>
+ *
* Example:
- * <pre>
- * {@literal @}Dao
+ * ```
+ * @Dao
* public interface MusicDao {
- * {@literal @}Delete
- * public void deleteSongs(Song... songs);
+ * @Delete
+ * public fun deleteSongs(vararg songs: Song)
*
- * {@literal @}Delete
- * public void deleteAlbumAndSongs(Album album, List<Song> songs);
+ * @Delete
+ * public fun deleteAlbumAndSongs(val album: Album, val songs: List<Song>)
* }
- * </pre>
- * If the target entity is specified via {@link #entity()} then the parameters can be of arbitrary
+ * ```
+ *
+ * If the target entity is specified via [entity] then the parameters can be of arbitrary
* POJO types that will be interpreted as partial entities. For example:
- * <pre>
- * {@literal @}Entity
- * public class Playlist {
- * {@literal @}PrimaryKey
- * long playlistId;
- * long ownerId;
- * String name;
- * {@literal @}ColumnInfo(defaultValue = "normal")
- * String category;
- * }
*
- * public class OwnerIdAndCategory {
- * long ownerId;
- * String category;
- * }
+ * ```
+ * @Entity
+ * data class Playlist (
+ * @PrimaryKey
+ * val playlistId: Long,
+ * val ownerId: Long,
+ * val name: String,
+ * @ColumnInfo(defaultValue = "normal")
+ * val category: String
+ * )
*
- * {@literal @}Dao
+ * data class OwnerIdAndCategory (
+ * val ownerId: Long,
+ * val category: String
+ * )
+ *
+ * @Dao
* public interface PlaylistDao {
- * {@literal @}Delete(entity = Playlist.class)
- * public void deleteByOwnerIdAndCategory(OwnerIdAndCategory... idCategory);
+ * @Delete(entity = Playlist::class)
+ * fun deleteByOwnerIdAndCategory(varargs idCategory: OwnerIdAndCategory)
* }
- * </pre>
+ * ```
*
* @see Insert
* @see Update
*/
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.CLASS)
-public @interface Delete {
+
+@Target(AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Delete(
/**
* The target entity of the delete method.
- * <p>
+ *
* When this is declared, the delete method parameters are interpreted as partial entities when
* the type of the parameter differs from the target. The POJO class that represents the entity
* must contain a subset of the fields of the target entity. The fields value will be used to
* find matching entities to delete.
- * <p>
+ *
* By default the target entity is interpreted by the method parameters.
*
* @return the target entity of the delete method or none if the method should use the
* parameter type entities.
*/
- Class<?> entity() default Object.class;
-}
+ val entity: KClass<*> = Any::class
+)
diff --git a/room/room-common/src/main/java/androidx/room/DeleteColumn.kt b/room/room-common/src/main/java/androidx/room/DeleteColumn.kt
index 6ef3ef6..1f90a85 100644
--- a/room/room-common/src/main/java/androidx/room/DeleteColumn.kt
+++ b/room/room-common/src/main/java/androidx/room/DeleteColumn.kt
@@ -14,45 +14,39 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
- * Repeatable annotation declaring the deleted columns in the {@link AutoMigration#to} version of
+ * Repeatable annotation declaring the deleted columns in the [AutoMigration.to] version of
* an auto migration.
*
* @see AutoMigration
*/
-@Repeatable(DeleteColumn.Entries.class)
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface DeleteColumn {
+@JvmRepeatable(DeleteColumn.Entries::class)
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class DeleteColumn(
/**
- * Name of the table in the {@link AutoMigration#from} version of the database the column was
+ * Name of the table in the [AutoMigration.from] version of the database the column was
* deleted from.
*
* @return Name of the table
*/
- String tableName();
+ val tableName: String,
/**
- * Name of the column deleted in the {@link AutoMigration#to} version of the database.
+ * Name of the column deleted in the [AutoMigration.to] version of the database.
*
* @return Name of the column.
*/
- String columnName();
-
+ val columnName: String,
+) {
/**
- * Container annotation for the repeatable annotation {@link DeleteColumn}.
+ * Container annotation for the repeatable annotation [DeleteColumn].
*/
- @Target(ElementType.TYPE)
- @Retention(RetentionPolicy.CLASS)
- @interface Entries {
- DeleteColumn[] value();
- }
+ @Target(AnnotationTarget.CLASS)
+ @Retention(AnnotationRetention.BINARY)
+ public annotation class Entries(
+ vararg val value: DeleteColumn
+ )
}
diff --git a/room/room-common/src/main/java/androidx/room/DeleteTable.kt b/room/room-common/src/main/java/androidx/room/DeleteTable.kt
index 0897f5f..7aaaf51 100644
--- a/room/room-common/src/main/java/androidx/room/DeleteTable.kt
+++ b/room/room-common/src/main/java/androidx/room/DeleteTable.kt
@@ -14,37 +14,31 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
- * Repeatable annotation declaring the deleted tables in the {@link AutoMigration#to} version of
+ * Repeatable annotation declaring the deleted tables in the [AutoMigration.to] version of
* an auto migration.
*
* @see AutoMigration
*/
-@Repeatable(DeleteTable.Entries.class)
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface DeleteTable {
+@JvmRepeatable(DeleteTable.Entries::class)
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class DeleteTable(
/**
- * Name of the table in the {@link AutoMigration#from} version of the database to be deleted.
+ * Name of the table in the [AutoMigration.from] version of the database to be deleted.
*
* @return Name of the table.
*/
- String tableName();
-
+ val tableName: String
+) {
/**
- * Container annotation for the repeatable annotation {@link DeleteTable}.
+ * Container annotation for the repeatable annotation [DeleteTable].
*/
- @Target(ElementType.TYPE)
- @Retention(RetentionPolicy.CLASS)
- @interface Entries {
- DeleteTable[] value();
- }
+ @Target(AnnotationTarget.CLASS)
+ @Retention(AnnotationRetention.BINARY)
+ public annotation class Entries(
+ vararg val value: DeleteTable
+ )
}
diff --git a/room/room-common/src/main/java/androidx/room/Embedded.kt b/room/room-common/src/main/java/androidx/room/Embedded.kt
index 1c63cc0..722e748 100644
--- a/room/room-common/src/main/java/androidx/room/Embedded.kt
+++ b/room/room-common/src/main/java/androidx/room/Embedded.kt
@@ -14,77 +14,77 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
- * Marks a field of an {@link Entity} or POJO to allow nested fields (i.e. fields of the annotated
+ * Marks a field of an [Entity] or POJO to allow nested fields (i.e. fields of the annotated
* field's class) to be referenced directly in the SQL queries.
- * <p>
- * If the container is an {@link Entity}, these sub fields will be columns in the {@link Entity}'s
+ *
+ * If the container is an [Entity], these sub fields will be columns in the [Entity]'s
* database table.
- * <p>
+ *
* For example, if you have 2 classes:
- * <pre>
- * public class Coordinates {
- * double latitude;
- * double longitude;
- * }
- * public class Address {
- * String street;
- * {@literal @}Embedded
- * Coordinates coordinates;
- * }
- * </pre>
- * Room will consider {@code latitude} and {@code longitude} as if they are fields of the
- * {@code Address} class when mapping an SQLite row to {@code Address}.
- * <p>
- * So if you have a query that returns {@code street, latitude, longitude}, Room will properly
- * construct an {@code Address} class.
- * <p>
- * If the {@code Address} class is annotated with {@link Entity}, its database table will have 3
- * columns: {@code street}, {@code latitude} and {@code longitude}.
- * <p>
+ *
+ * ```
+ * data class Coordinates (
+ * val latitude: Double,
+ * val longitude: Double
+ * )
+ *
+ * data class Address (
+ * val street: String,
+ * @Embedded
+ * val coordinates: Coordinates
+ * )
+ * ```
+ *
+ * Room will consider `latitude` and `longitude` as if they are fields of the
+ * `Address` class when mapping an SQLite row to `Address`.
+ *
+ * So if you have a query that returns `street, latitude, longitude`, Room will properly
+ * construct an `Address` class.
+ *
+ * If the `Address` class is annotated with [Entity], its database table will have 3
+ * columns: `street`, `latitude` and `longitude`.
+ *
* If there is a name conflict with the fields of the sub object and the owner object, you can
- * specify a {@link #prefix()} for the fields of the sub object. Note that prefix is always applied
- * to sub fields even if they have a {@link ColumnInfo} with a specific {@code name}.
- * <p>
- * If sub fields of an embedded field has {@link PrimaryKey} annotation, they <b>will not</b> be
- * considered as primary keys in the owner {@link Entity}.
- * <p>
+ * specify a [prefix] for the fields of the sub object. Note that prefix is always applied
+ * to sub fields even if they have a [ColumnInfo] with a specific `name`.
+ *
+ * If sub fields of an embedded field has [PrimaryKey] annotation, they **will not** be
+ * considered as primary keys in the owner [Entity].
+ *
* When an embedded field is read, if all fields of the embedded field (and its sub fields) are
- * {@code null} in the {@link android.database.Cursor Cursor}, it is set to {@code null}. Otherwise,
+ * `null` in the [android.database.Cursor], it is set to `null`. Otherwise,
* it is constructed.
- * <p>
- * Note that even if you have {@link TypeConverter}s that convert a {@code null} column into a
- * {@code non-null} value, if all columns of the embedded field in the
- * {@link android.database.Cursor Cursor} are null, the {@link TypeConverter} will never be called
+ *
+ * Note that even if you have [TypeConverter]s that convert a `null` column into a
+ * `non-null` value, if all columns of the embedded field in the
+ * [android.database.Cursor] are null, the [TypeConverter] will never be called
* and the embedded field will not be constructed.
- * <p>
+ *
* You can override this behavior by annotating the embedded field with
- * {@link androidx.annotation.NonNull}.
+ * [androidx.annotation.NonNull].
*/
-@Target({ElementType.FIELD, ElementType.METHOD})
-@Retention(RetentionPolicy.CLASS)
-public @interface Embedded {
+@Target(AnnotationTarget.FIELD, AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Embedded(
/**
* Specifies a prefix to prepend the column names of the fields in the embedded fields.
- * <p>
+ *
* For the example above, if we've written:
- * <pre>
- * {@literal @}Embedded(prefix = "loc_")
- * Coordinates coordinates;
- * </pre>
- * The column names for {@code latitude} and {@code longitude} will be {@code loc_latitude} and
- * {@code loc_longitude} respectively.
- * <p>
+ *
+ * ```
+ * @Embedded(prefix = "loc_")
+ * val coordinates: Coordinates
+ * ```
+ *
+ * The column names for `latitude` and `longitude` will be `loc_latitude` and
+ * `loc_longitude` respectively.
+ *
* By default, prefix is the empty string.
*
* @return The prefix to be used for the fields of the embedded item.
*/
- String prefix() default "";
-}
+ val prefix: String = ""
+)
diff --git a/room/room-common/src/main/java/androidx/room/Entity.kt b/room/room-common/src/main/java/androidx/room/Entity.kt
index 0b3e43c..0762f90 100644
--- a/room/room-common/src/main/java/androidx/room/Entity.kt
+++ b/room/room-common/src/main/java/androidx/room/Entity.kt
@@ -14,60 +14,37 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
* Marks a class as an entity. This class will have a mapping SQLite table in the database.
- * <p>
- * Each entity must have at least 1 field annotated with {@link PrimaryKey}.
- * You can also use {@link #primaryKeys()} attribute to define the primary key.
- * <p>
+ *
+ * Each entity must have at least 1 field annotated with [PrimaryKey].
+ * You can also use [primaryKeys] attribute to define the primary key.
+ *
* Each entity must either have a no-arg constructor or a constructor whose parameters match
* fields (based on type and name). Constructor does not have to receive all fields as parameters
* but if a field is not passed into the constructor, it should either be public or have a public
* setter. If a matching constructor is available, Room will always use it. If you don't want it
- * to use a constructor, you can annotate it with {@link Ignore}.
- * <p>
- * When a class is marked as an Entity, all of its fields are persisted. If you would like to
- * exclude some of its fields, you can mark them with {@link Ignore}.
- * <p>
- * If a field is {@code transient}, it is automatically ignored <b>unless</b> it is annotated with
- * {@link ColumnInfo}, {@link Embedded} or {@link Relation}.
- * <p>
+ * to use a constructor, you can annotate it with [Ignore].
+ *
+ * When a class is marked as an [Entity], all of its fields are persisted. If you would like to
+ * exclude some of its fields, you can mark them with [Ignore].
+ *
+ * If a field is `transient`, it is automatically ignored **unless** it is annotated with
+ * `ColumnInfo`, `Embedded` or `Relation`.
+ *
* Example:
- * <pre>
- * {@literal @}Entity
- * public class Song {
- * {@literal @}PrimaryKey
- * private final long id;
- * private final String name;
- * {@literal @}ColumnInfo(name = "release_year")
- * private final int releaseYear;
- *
- * public Song(long id, String name, int releaseYear) {
- * this.id = id;
- * this.name = name;
- * this.releaseYear = releaseYear;
- * }
- *
- * public int getId() {
- * return id;
- * }
- *
- * public String getName() {
- * return name;
- * }
- *
- * public int getReleaseYear() {
- * return releaseYear;
- * }
- * }
- * </pre>
+ * ```
+ * @Entity
+ * data class Song (
+ * @PrimaryKey
+ * val id: Long,
+ * val name: String,
+ * @ColumnInfo(name = "release_year")
+ * val releaseYear: Int
+ * )
+ * ```
*
* @see Dao
* @see Database
@@ -75,70 +52,70 @@
* @see ColumnInfo
* @see Index
*/
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface Entity {
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Entity(
/**
* The table name in the SQLite database. If not set, defaults to the class name.
*
* @return The SQLite tableName of the Entity.
*/
- String tableName() default "";
+ val tableName: String = "",
/**
* List of indices on the table.
*
* @return The list of indices on the table.
*/
- Index[] indices() default {};
+ val indices: Array<Index> = [],
/**
- * If set to {@code true}, any Index defined in parent classes of this class will be carried
- * over to the current {@code Entity}. Note that if you set this to {@code true}, even if the
- * {@code Entity} has a parent which sets this value to {@code false}, the {@code Entity} will
+ * If set to `true`, any Index defined in parent classes of this class will be carried
+ * over to the current `Entity`. Note that if you set this to `true`, even if the
+ * `Entity` has a parent which sets this value to `false`, the `Entity` will
* still inherit indices from it and its parents.
- * <p>
- * When the {@code Entity} inherits an index from the parent, it is <b>always</b> renamed with
- * the default naming schema since SQLite <b>does not</b> allow using the same index name in
- * multiple tables. See {@link Index} for the details of the default name.
- * <p>
+ *
+ * When the `Entity` inherits an index from the parent, it is **always** renamed with
+ * the default naming schema since SQLite **does not** allow using the same index name in
+ * multiple tables. See [Index] for the details of the default name.
+ *
* By default, indices defined in parent classes are dropped to avoid unexpected indices.
- * When this happens, you will receive a {@link RoomWarnings#INDEX_FROM_PARENT_FIELD_IS_DROPPED}
- * or {@link RoomWarnings#INDEX_FROM_PARENT_IS_DROPPED} warning during compilation.
+ * When this happens, you will receive a [RoomWarnings.INDEX_FROM_PARENT_FIELD_IS_DROPPED]
+ * or [RoomWarnings.INDEX_FROM_PARENT_IS_DROPPED] warning during compilation.
*
* @return True if indices from parent classes should be automatically inherited by this Entity,
* false otherwise. Defaults to false.
*/
- boolean inheritSuperIndices() default false;
+ val inheritSuperIndices: Boolean = false,
/**
* The list of Primary Key column names.
- * <p>
- * If you would like to define an auto generated primary key, you can use {@link PrimaryKey}
- * annotation on the field with {@link PrimaryKey#autoGenerate()} set to {@code true}.
+ *
+ * If you would like to define an auto generated primary key, you can use [PrimaryKey]
+ * annotation on the field with [PrimaryKey.autoGenerate] set to `true`.
*
* @return The primary key of this Entity. Can be empty if the class has a field annotated
- * with {@link PrimaryKey}.
+ * with [PrimaryKey].
*/
- String[] primaryKeys() default {};
+ val primaryKeys: Array<String> = [],
/**
- * List of {@link ForeignKey} constraints on this entity.
+ * List of [ForeignKey] constraints on this entity.
*
- * @return The list of {@link ForeignKey} constraints on this entity.
+ * @return The list of [ForeignKey] constraints on this entity.
*/
- ForeignKey[] foreignKeys() default {};
+ val foreignKeys: Array<ForeignKey> = [],
/**
* The list of column names that should be ignored by Room.
- * <p>
- * Normally, you can use {@link Ignore}, but this is useful for ignoring fields inherited from
+ *
+ * Normally, you can use [Ignore], but this is useful for ignoring fields inherited from
* parents.
- * <p>
- * Columns that are part of an {@link Embedded} field can not be individually ignored. To ignore
- * columns from an inherited {@link Embedded} field, use the name of the field.
+ *
+ * Columns that are part of an [Embedded] field can not be individually ignored. To ignore
+ * columns from an inherited [Embedded] field, use the name of the field.
*
* @return The list of field names.
*/
- String[] ignoredColumns() default {};
-}
+ val ignoredColumns: Array<String> = []
+)
diff --git a/room/room-common/src/main/java/androidx/room/ForeignKey.kt b/room/room-common/src/main/java/androidx/room/ForeignKey.kt
index d3c7f5e..38f9b76 100644
--- a/room/room-common/src/main/java/androidx/room/ForeignKey.kt
+++ b/room/room-common/src/main/java/androidx/room/ForeignKey.kt
@@ -13,160 +13,160 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import androidx.annotation.IntDef;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import androidx.annotation.IntDef
+import kotlin.reflect.KClass
/**
- * Declares a foreign key on another {@link Entity}.
- * <p>
+ * Declares a foreign key on another [Entity].
+ *
* Foreign keys allows you to specify constraints across Entities such that SQLite will ensure that
* the relationship is valid when you modify the database.
- * <p>
+ *
* When a foreign key constraint is specified, SQLite requires the referenced columns to be part of
* a unique index in the parent table or the primary key of that table. You must create a unique
* index in the parent entity that covers the referenced columns (Room will verify this at compile
* time and print an error if it is missing).
- * <p>
+ *
* It is also recommended to create an index on the child table to avoid full table scans when the
* parent table is modified. If a suitable index on the child table is missing, Room will print
- * {@link RoomWarnings#MISSING_INDEX_ON_FOREIGN_KEY_CHILD} warning.
- * <p>
+ * [RoomWarnings.MISSING_INDEX_ON_FOREIGN_KEY_CHILD] warning.
+ *
* A foreign key constraint can be deferred until the transaction is complete. This is useful if
* you are doing bulk inserts into the database in a single transaction. By default, foreign key
- * constraints are immediate but you can change this value by setting {@link #deferred()} to
- * {@code true}. You can also use
- * <a href="https://sqlite.org/pragma.html#pragma_defer_foreign_keys">defer_foreign_keys</a> PRAGMA
- * to defer them depending on your transaction.
- * <p>
- * Please refer to the SQLite <a href="https://sqlite.org/foreignkeys.html">foreign keys</a>
- * documentation for details.
+ * constraints are immediate but you can change this value by setting [deferred] to
+ * `true`. You can also use
+ * [defer_foreign_keys](https://sqlite.org/pragma.html#pragma_defer_foreign_keys) to defer them
+ * depending on your transaction.
+ *
+ * Please refer to the SQLite [foreign keys](https://sqlite.org/foreignkeys.html) documentation for
+ * details.
*/
-@Target({})
-@Retention(RetentionPolicy.CLASS)
-public @interface ForeignKey {
+@Target(allowedTargets = []) // Complex annotation target
+@Retention(AnnotationRetention.BINARY)
+public annotation class ForeignKey(
/**
- * The parent Entity to reference. It must be a class annotated with {@link Entity} and
+ * The parent Entity to reference. It must be a class annotated with [Entity] and
* referenced in the same database.
*
* @return The parent Entity.
*/
- Class<?> entity();
+ val entity: KClass<*>,
/**
- * The list of column names in the parent {@link Entity}.
- * <p>
- * Number of columns must match the number of columns specified in {@link #childColumns()}.
+ * The list of column names in the parent [Entity].
+ *
+ * Number of columns must match the number of columns specified in [childColumns].
*
* @return The list of column names in the parent Entity.
- * @see #childColumns()
+ * @see [childColumns]
*/
- String[] parentColumns();
+ val parentColumns: Array<String>,
/**
- * The list of column names in the current {@link Entity}.
- * <p>
- * Number of columns must match the number of columns specified in {@link #parentColumns()}.
+ * The list of column names in the current [Entity].
+ *
+ * Number of columns must match the number of columns specified in [parentColumns].
*
* @return The list of column names in the current Entity.
*/
- String[] childColumns();
+ val childColumns: Array<String>,
/**
- * Action to take when the parent {@link Entity} is deleted from the database.
- * <p>
- * By default, {@link #NO_ACTION} is used.
+ * Action to take when the parent [Entity] is deleted from the database.
+ *
+ * By default, [NO_ACTION] is used.
*
* @return The action to take when the referenced entity is deleted from the database.
*/
- @Action int onDelete() default NO_ACTION;
+ @Action
+ val onDelete: Int = NO_ACTION,
/**
- * Action to take when the parent {@link Entity} is updated in the database.
- * <p>
- * By default, {@link #NO_ACTION} is used.
+ * Action to take when the parent [Entity] is updated in the database.
+ *
+ * By default, [NO_ACTION] is used.
*
* @return The action to take when the referenced entity is updated in the database.
*/
- @Action int onUpdate() default NO_ACTION;
+ @Action
+ val onUpdate: Int = NO_ACTION,
/**
- * * A foreign key constraint can be deferred until the transaction is complete. This is useful
+ * A foreign key constraint can be deferred until the transaction is complete. This is useful
* if you are doing bulk inserts into the database in a single transaction. By default, foreign
- * key constraints are immediate but you can change it by setting this field to {@code true}.
+ * key constraints are immediate but you can change it by setting this field to `true`.
* You can also use
- * <a href="https://sqlite.org/pragma.html#pragma_defer_foreign_keys">defer_foreign_keys</a>
+ * [defer_foreign_keys](https://sqlite.org/pragma.html#pragma_defer_foreign_keys)
* PRAGMA to defer them depending on your transaction.
*
* @return Whether the foreign key constraint should be deferred until the transaction is
- * complete. Defaults to {@code false}.
+ * complete. Defaults to `false`.
*/
- boolean deferred() default false;
+ val deferred: Boolean = false
+) {
+ public companion object {
+ /**
+ * Possible value for [onDelete] or [onUpdate].
+ *
+ * When a parent key is modified or deleted from the database, no special action is taken.
+ * This means that SQLite will not make any effort to fix the constraint failure, instead,
+ * reject the change.
+ */
+ public const val NO_ACTION: Int = 1
- /**
- * Possible value for {@link #onDelete()} or {@link #onUpdate()}.
- * <p>
- * When a parent key is modified or deleted from the database, no special action is taken.
- * This means that SQLite will not make any effort to fix the constraint failure, instead,
- * reject the change.
- */
- int NO_ACTION = 1;
+ /**
+ * Possible value for [onDelete] or [onUpdate].
+ *
+ * The RESTRICT action means that the application is prohibited from deleting
+ * (for [onDelete]) or modifying (for [onUpdate]) a parent key when there
+ * exists one or more child keys mapped to it. The difference between the effect of a RESTRICT
+ * action and normal foreign key constraint enforcement is that the RESTRICT action processing
+ * happens as soon as the field is updated - not at the end of the current statement as it would
+ * with an immediate constraint, or at the end of the current transaction as it would with a
+ * [deferred] constraint.
+ *
+ * Even if the foreign key constraint it is attached to is [deferred], configuring a
+ * RESTRICT action causes SQLite to return an error immediately if a parent key with dependent
+ * child keys is deleted or modified.
+ */
+ public const val RESTRICT: Int = 2
- /**
- * Possible value for {@link #onDelete()} or {@link #onUpdate()}.
- * <p>
- * The RESTRICT action means that the application is prohibited from deleting
- * (for {@link #onDelete()}) or modifying (for {@link #onUpdate()}) a parent key when there
- * exists one or more child keys mapped to it. The difference between the effect of a RESTRICT
- * action and normal foreign key constraint enforcement is that the RESTRICT action processing
- * happens as soon as the field is updated - not at the end of the current statement as it would
- * with an immediate constraint, or at the end of the current transaction as it would with a
- * {@link #deferred()} constraint.
- * <p>
- * Even if the foreign key constraint it is attached to is {@link #deferred()}, configuring a
- * RESTRICT action causes SQLite to return an error immediately if a parent key with dependent
- * child keys is deleted or modified.
- */
- int RESTRICT = 2;
+ /**
+ * Possible value for [onDelete] or [onUpdate].
+ *
+ * If the configured action is "SET NULL", then when a parent key is deleted
+ * (for [onDelete]) or modified (for [onUpdate]), the child key columns of all
+ * rows in the child table that mapped to the parent key are set to contain `NULL` values.
+ */
+ public const val SET_NULL: Int = 3
- /**
- * Possible value for {@link #onDelete()} or {@link #onUpdate()}.
- * <p>
- * If the configured action is "SET NULL", then when a parent key is deleted
- * (for {@link #onDelete()}) or modified (for {@link #onUpdate()}), the child key columns of all
- * rows in the child table that mapped to the parent key are set to contain {@code NULL} values.
- */
- int SET_NULL = 3;
+ /**
+ * Possible value for [onDelete] or [onUpdate].
+ *
+ * The "SET DEFAULT" actions are similar to [SET_NULL], except that each of the child key
+ * columns is set to contain the columns default value instead of `NULL`.
+ */
+ public const val SET_DEFAULT: Int = 4
- /**
- * Possible value for {@link #onDelete()} or {@link #onUpdate()}.
- * <p>
- * The "SET DEFAULT" actions are similar to {@link #SET_NULL}, except that each of the child key
- * columns is set to contain the columns default value instead of {@code NULL}.
- */
- int SET_DEFAULT = 4;
-
- /**
- * Possible value for {@link #onDelete()} or {@link #onUpdate()}.
- * <p>
- * A "CASCADE" action propagates the delete or update operation on the parent key to each
- * dependent child key. For {@link #onDelete()} action, this means that each row in the child
- * entity that was associated with the deleted parent row is also deleted. For an
- * {@link #onUpdate()} action, it means that the values stored in each dependent child key are
- * modified to match the new parent key values.
- */
- int CASCADE = 5;
-
- /**
- * Constants definition for values that can be used in {@link #onDelete()} and
- * {@link #onUpdate()}.
- */
- @IntDef({NO_ACTION, RESTRICT, SET_NULL, SET_DEFAULT, CASCADE})
- @Retention(RetentionPolicy.CLASS)
- @interface Action {
+ /**
+ * Possible value for [onDelete] or [onUpdate].
+ *
+ * A "CASCADE" action propagates the delete or update operation on the parent key to each
+ * dependent child key. For [onDelete] action, this means that each row in the child
+ * entity that was associated with the deleted parent row is also deleted. For an
+ * [onUpdate] action, it means that the values stored in each dependent child key are
+ * modified to match the new parent key values.
+ */
+ public const val CASCADE: Int = 5
}
+
+ /**
+ * Constants definition for values that can be used in [onDelete] and
+ * [onUpdate].
+ */
+ @IntDef(NO_ACTION, RESTRICT, SET_NULL, SET_DEFAULT, CASCADE)
+ @Retention(AnnotationRetention.BINARY)
+ public annotation class Action
}
diff --git a/room/room-common/src/main/java/androidx/room/Fts3.kt b/room/room-common/src/main/java/androidx/room/Fts3.kt
index 9e61098..e1d9f17 100644
--- a/room/room-common/src/main/java/androidx/room/Fts3.kt
+++ b/room/room-common/src/main/java/androidx/room/Fts3.kt
@@ -14,89 +14,69 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import static androidx.room.FtsOptions.TOKENIZER_SIMPLE;
-
-import androidx.annotation.RequiresApi;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import androidx.annotation.RequiresApi
+import androidx.room.FtsOptions.TOKENIZER_SIMPLE
/**
- * Marks an {@link Entity} annotated class as a FTS3 entity. This class will have a mapping SQLite
+ * Marks an [Entity] annotated class as a FTS3 entity. This class will have a mapping SQLite
* FTS3 table in the database.
- * <p>
- * <a href="https://www.sqlite.org/fts3.html">FTS3 and FTS4</a> are SQLite virtual table modules
+ *
+ * [FTS3 and FTS4](https://www.sqlite.org/fts3.html) are SQLite virtual table modules
* that allows full-text searches to be performed on a set of documents.
- * <p>
- * An FTS entity table always has a column named <code>rowid</code> that is the equivalent of an
- * <code>INTEGER PRIMARY KEY</code> index. Therefore, an FTS entity can only have a single field
- * annotated with {@link PrimaryKey}, it must be named <code>rowid</code> and must be of
- * <code>INTEGER</code> affinity. The field can be optionally omitted in the class but can still be
+ *
+ * An FTS entity table always has a column named `rowid` that is the equivalent of an
+ * `INTEGER PRIMARY KEY` index. Therefore, an FTS entity can only have a single field
+ * annotated with [PrimaryKey], it must be named `rowid` and must be of
+ * `INTEGER` affinity. The field can be optionally omitted in the class but can still be
* used in queries.
- * <p>
- * All fields in an FTS entity are of <code>TEXT</code> affinity, except the for the 'rowid' field.
- * <p>
+ *
+ * All fields in an FTS entity are of `TEXT` affinity, except the for the 'rowid' field.
+ *
* Example:
- * <pre>
- * {@literal @}Entity
- * {@literal @}Fts3
- * public class Mail {
- * {@literal @}PrimaryKey
- * {@literal @}ColumnInfo(name = "rowid")
- * private final int rowId;
- * private final String subject;
- * private final String body;
*
- * public Mail(int rowId, String subject, String body) {
- * this.rowId = rowId;
- * this.subject = subject;
- * this.body = body;
- * }
+ * ```
+ * @Entity
+ * @Fts3
+ * data class Mail (
+ * @PrimaryKey
+ * @ColumnInfo(name = "rowid")
+ * val rowId: Int,
+ * val subject: String,
+ * val body: String
+ * )
+ * ```
*
- * public String getRowId() {
- * return rowId;
- * }
- * public String getSubject() {
- * return subject;
- * }
- * public void getBody() {
- * return body;
- * }
- * }
- * </pre>
- *
- * @see Entity
- * @see Dao
- * @see Database
- * @see PrimaryKey
- * @see ColumnInfo
+ * @see [Entity]
+ * @see [Dao]
+ * @see [Database]
+ * @see [PrimaryKey]
+ * @see [ColumnInfo]
*/
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
@RequiresApi(16)
-public @interface Fts3 {
+public annotation class Fts3(
/**
* The tokenizer to be used in the FTS table.
- * <p>
- * The default value is {@link FtsOptions#TOKENIZER_SIMPLE}. Tokenizer arguments can be defined
- * with {@link #tokenizerArgs()}.
- * <p>
+ *
+ * The default value is [FtsOptions.TOKENIZER_SIMPLE]. Tokenizer arguments can be defined
+ * with [tokenizerArgs].
+ *
* If a custom tokenizer is used, the tokenizer and its arguments are not verified at compile
* time.
*
+ * See [SQLite tokenizers documentation](https://www.sqlite.org/fts3.html#tokenizer) for more
+ * details.
+ *
* @return The tokenizer to use on the FTS table. Built-in available tokenizers are
- * {@link FtsOptions#TOKENIZER_SIMPLE}, {@link FtsOptions#TOKENIZER_PORTER} and
- * {@link FtsOptions#TOKENIZER_UNICODE61}.
- * @see #tokenizerArgs()
- * @see <a href="https://www.sqlite.org/fts3.html#tokenizer">SQLite tokernizers
- * documentation</a>
+ * [FtsOptions.TOKENIZER_SIMPLE], [FtsOptions.TOKENIZER_PORTER] and
+ * [FtsOptions.TOKENIZER_UNICODE61].
+ * @see [tokenizerArgs]
*/
- String tokenizer() default TOKENIZER_SIMPLE;
+ val tokenizer: String = TOKENIZER_SIMPLE,
/**
* Optional arguments to configure the defined tokenizer.
@@ -106,10 +86,9 @@
* additional separator when using the {@link FtsOptions#TOKENIZER_UNICODE61} tokenizer.
* <p>
* The available arguments that can be defined depend on the tokenizer defined, see the
- * <a href="https://www.sqlite.org/fts3.html#tokenizer">SQLite tokernizers documentation</a> for
- * details.
+ * [SQLite tokernizers documentation](https://www.sqlite.org/fts3.html#tokenizer) for details.
*
* @return A list of tokenizer arguments strings.
*/
- String[] tokenizerArgs() default {};
-}
+ val tokenizerArgs: Array<String> = []
+)
diff --git a/room/room-common/src/main/java/androidx/room/Fts4.kt b/room/room-common/src/main/java/androidx/room/Fts4.kt
index 510ef92..7255265 100644
--- a/room/room-common/src/main/java/androidx/room/Fts4.kt
+++ b/room/room-common/src/main/java/androidx/room/Fts4.kt
@@ -14,186 +14,168 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import static androidx.room.FtsOptions.TOKENIZER_SIMPLE;
+import kotlin.reflect.KClass
-import androidx.annotation.RequiresApi;
-import androidx.room.FtsOptions.MatchInfo;
-import androidx.room.FtsOptions.Order;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import androidx.annotation.RequiresApi
+import androidx.room.FtsOptions.TOKENIZER_SIMPLE
+import androidx.room.FtsOptions.MatchInfo
+import androidx.room.FtsOptions.Order
/**
- * Marks an {@link Entity} annotated class as a FTS4 entity. This class will have a mapping SQLite
+ * Marks an [Entity] annotated class as a FTS4 entity. This class will have a mapping SQLite
* FTS4 table in the database.
- * <p>
- * <a href="https://www.sqlite.org/fts3.html">FTS3 and FTS4</a> are SQLite virtual table modules
+ *
+ * [FTS3 and FTS4] (https://www.sqlite.org/fts3.html) are SQLite virtual table modules
* that allows full-text searches to be performed on a set of documents.
- * <p>
- * An FTS entity table always has a column named <code>rowid</code> that is the equivalent of an
- * <code>INTEGER PRIMARY KEY</code> index. Therefore, an FTS entity can only have a single field
- * annotated with {@link PrimaryKey}, it must be named <code>rowid</code> and must be of
- * <code>INTEGER</code> affinity. The field can be optionally omitted in the class but can still be
+ *
+ * An FTS entity table always has a column named `rowid` that is the equivalent of an
+ * `INTEGER PRIMARY KEY` index. Therefore, an FTS entity can only have a single field
+ * annotated with [PrimaryKey], it must be named `rowid` and must be of
+ * `INTEGER` affinity. The field can be optionally omitted in the class but can still be
* used in queries.
- * <p>
- * All fields in an FTS entity are of <code>TEXT</code> affinity, except the for the 'rowid' and
+ *
+ * All fields in an FTS entity are of `TEXT` affinity, except the for the 'rowid' and
* 'languageid' fields.
- * <p>
+ *
* Example:
- * <pre>
- * {@literal @}Entity
- * {@literal @}Fts4
- * public class Mail {
- * {@literal @}PrimaryKey
- * {@literal @}ColumnInfo(name = "rowid")
- * private final int rowId;
- * private final String subject;
- * private final String body;
*
- * public Mail(int rowId, String subject, String body) {
- * this.rowId = rowId;
- * this.subject = subject;
- * this.body = body;
- * }
+ * ```
+ * @Entity
+ * @Fts4
+ * data class Mail (
+ * @PrimaryKey
+ * @ColumnInfo(name = "rowid")
+ * val rowId: Int,
+ * val subject: String,
+ * val body: String
+ * )
+ * ```
*
- * public String getRowId() {
- * return rowId;
- * }
- * public String getSubject() {
- * return subject;
- * }
- * public void getBody() {
- * return body;
- * }
- * }
- * </pre>
- *
- * @see Entity
- * @see Dao
- * @see Database
- * @see PrimaryKey
- * @see ColumnInfo
+ * @see [Entity]
+ * @see [Dao]
+ * @see [Database]
+ * @see [PrimaryKey]
+ * @see [ColumnInfo]
*/
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
@RequiresApi(16)
-public @interface Fts4 {
+public annotation class Fts4(
/**
* The tokenizer to be used in the FTS table.
- * <p>
- * The default value is {@link FtsOptions#TOKENIZER_SIMPLE}. Tokenizer arguments can be defined
- * with {@link #tokenizerArgs()}.
- * <p>
+ *
+ * The default value is [FtsOptions.TOKENIZER_SIMPLE]. Tokenizer arguments can be defined
+ * with [tokenizerArgs].
+ *
* If a custom tokenizer is used, the tokenizer and its arguments are not verified at compile
* time.
*
+ * For details, see [SQLite tokernizers documentation](https://www.sqlite.org/fts3.html#tokenizer)
+ *
* @return The tokenizer to use on the FTS table. Built-in available tokenizers are
- * {@link FtsOptions#TOKENIZER_SIMPLE}, {@link FtsOptions#TOKENIZER_PORTER} and
- * {@link FtsOptions#TOKENIZER_UNICODE61}.
- * @see #tokenizerArgs()
- * @see <a href="https://www.sqlite.org/fts3.html#tokenizer">SQLite tokernizers
- * documentation</a>
+ * [FtsOptions.TOKENIZER_SIMPLE], [FtsOptions.TOKENIZER_PORTER] and
+ * [FtsOptions.TOKENIZER_UNICODE61].
+ * @see [tokenizerArgs]
*/
- String tokenizer() default TOKENIZER_SIMPLE;
+ val tokenizer: String = TOKENIZER_SIMPLE,
/**
* Optional arguments to configure the defined tokenizer.
- * <p>
+ *
* Tokenizer arguments consist of an argument name, followed by an "=" character, followed by
- * the option value. For example, <code>separators=.</code> defines the dot character as an
- * additional separator when using the {@link FtsOptions#TOKENIZER_UNICODE61} tokenizer.
- * <p>
+ * the option value. For example, `separators=.` defines the dot character as an
+ * additional separator when using the [FtsOptions.TOKENIZER_UNICODE61] tokenizer.
+ *
* The available arguments that can be defined depend on the tokenizer defined, see the
- * <a href="https://www.sqlite.org/fts3.html#tokenizer">SQLite tokernizers documentation</a> for
- * details.
+ * [SQLite tokenizers documentation](https://www.sqlite.org/fts3.html#tokenizer) for details.
*
* @return A list of tokenizer arguments strings.
*/
- String[] tokenizerArgs() default {};
+ val tokenizerArgs: Array<String> = [],
/**
* The external content entity who's mapping table will be used as content for the FTS table.
- * <p>
+ *
* Declaring this value makes the mapping FTS table of this entity operate in "external content"
* mode. In such mode the FTS table does not store its own content but instead uses the data in
* the entity mapped table defined in this value. This option allows FTS4 to forego storing the
* text being indexed which can be used to achieve significant space savings.
- * <p>
+ *
* In "external mode" the content table and the FTS table need to be synced. Room will create
* the necessary triggers to keep the tables in sync. Therefore, all write operations should
* be performed against the content entity table and not the FTS table.
- * <p>
+ *
* The content sync triggers created by Room will be removed before migrations are executed and
* are re-created once migrations are complete. This prevents the triggers from interfering with
* migrations but means that if data needs to be migrated then write operations might need to be
* done in both the FTS and content tables.
*
+ * See the [External Content FTS4 Tables](https://www.sqlite.org/fts3.html#_external_content_fts4_tables_)
+ * documentation for details.
+ *
* @return The external content entity.
- * @see <a href="https://www.sqlite.org/fts3.html#_external_content_fts4_tables_">External
- * Content FTS4 Tables</a>
*/
- Class<?> contentEntity() default Object.class;
+ val contentEntity: KClass<*> = Any::class,
/**
* The column name to be used as 'languageid'.
- * <p>
+ *
* Allows the FTS4 extension to use the defined column name to specify the language stored in
- * each row. When this is defined a field of type <code>INTEGER</code> with the same name must
+ * each row. When this is defined a field of type `INTEGER` with the same name must
* exist in the class.
- * <p>
+ *
* FTS queries are affected by defining this option, see
- * <a href=https://www.sqlite.org/fts3.html#the_languageid_option>the languageid= option
- * documentation</a> for details.
+ * [the languageid= option documentation](https://www.sqlite.org/fts3.html#the_languageid_option)
+ * for details.
*
* @return The column name to be used as 'languageid'.
*/
- String languageId() default "";
-
+ val languageId: String = "",
/**
* The FTS version used to store text matching information.
- * <p>
- * The default value is {@link MatchInfo#FTS4}. Disk space consumption can be reduced by
- * setting this option to FTS3, see
- * <a href=https://www.sqlite.org/fts3.html#the_matchinfo_option>the matchinfo= option
- * documentation</a> for details.
*
- * @return The match info version, either {@link MatchInfo#FTS4} or {@link MatchInfo#FTS3}.
+ * The default value is [MatchInfo.FTS4]. Disk space consumption can be reduced by
+ * setting this option to FTS3, see
+ * [the matchinfo= option documentation](https://www.sqlite.org/fts3.html#the_matchinfo_option)
+ * for details.
+ *
+ * @return The match info version, either [MatchInfo.FTS4] or [MatchInfo.FTS3].
*/
- MatchInfo matchInfo() default MatchInfo.FTS4;
+ val matchInfo: MatchInfo = MatchInfo.FTS4,
/**
* The list of column names on the FTS table that won't be indexed.
*
+ * For details, see the
+ * [notindexed= option documentation](https://www.sqlite.org/fts3.html#the_notindexed_option).
+ *
* @return A list of column names that will not be indexed by the FTS extension.
- * @see <a href="https://www.sqlite.org/fts3.html#the_notindexed_option">The notindexed= option
- * documentation</a>
*/
- String[] notIndexed() default {};
+ val notIndexed: Array<String> = [],
/**
* The list of prefix sizes to index.
*
+ * For details,
+ * [the prefix= option documentation](https://www.sqlite.org/fts3.html#the_prefix_option).
+ *
* @return A list of non-zero positive prefix sizes to index.
- * @see <a href="https://www.sqlite.org/fts3.html#the_prefix_option">The prefix= option
- * documentation</a>
*/
- int[] prefix() default {};
+ val prefix: IntArray = [],
/**
* The preferred 'rowid' order of the FTS table.
- * <p>
- * The default value is {@link Order#ASC}. If many queries are run against the FTS table use
- * <code>ORDER BY row DESC</code> then it may improve performance to set this option to
- * {@link Order#DESC}, enabling the FTS module to store its data in a way that optimizes
- * returning results in descending order by rowid.
*
- * @return The preferred order, either {@link Order#ASC} or {@link Order#DESC}.
+ * The default value is [Order.ASC]. If many queries are run against the FTS table use
+ * `ORDER BY row DESC` then it may improve performance to set this option to
+ * [Order.DESC], enabling the FTS module to store its data in a way that optimizes
+ * returning results in descending order by `rowid`.
+ *
+ * @return The preferred order, either [Order.ASC] or [Order.DESC].
*/
- Order order() default Order.ASC;
-}
+ val order: Order = Order.ASC
+)
diff --git a/room/room-common/src/main/java/androidx/room/FtsOptions.kt b/room/room-common/src/main/java/androidx/room/FtsOptions.kt
index 472d4ff..109d38a 100644
--- a/room/room-common/src/main/java/androidx/room/FtsOptions.kt
+++ b/room/room-common/src/main/java/androidx/room/FtsOptions.kt
@@ -14,83 +14,81 @@
* limitations under the License.
*/
-package androidx.room;
+@file:JvmName("FtsOptions")
-import androidx.annotation.RequiresApi;
+package androidx.room
+
+import androidx.annotation.RequiresApi
/**
- * Available option values that can be used with {@link Fts3} & {@link Fts4}.
+ * Available option values that can be used with [Fts3] & [Fts4].
*/
-public class FtsOptions {
-
- /**
- * The name of the default tokenizer used on FTS tables.
- *
- * @see Fts4#tokenizer()
- * @see Fts4#tokenizerArgs()
- */
- public static final String TOKENIZER_SIMPLE = "simple";
-
- /**
- * The name of the tokenizer based on the Porter Stemming Algorithm.
- *
- * @see Fts4#tokenizer()
- * @see Fts4#tokenizerArgs()
- */
- public static final String TOKENIZER_PORTER = "porter";
-
- /**
- * The name of a tokenizer implemented by the ICU library.
- * <p>
- * Not available in certain Android builds (e.g. vendor).
- *
- * @see Fts4#tokenizer()
- * @see Fts4#tokenizerArgs()
- */
- public static final String TOKENIZER_ICU = "icu";
-
- /**
- * The name of the tokenizer that extends the {@link #TOKENIZER_SIMPLE} tokenizer
- * according to rules in Unicode Version 6.1.
- *
- * @see Fts4#tokenizer()
- * @see Fts4#tokenizerArgs()
- */
- @RequiresApi(21)
- public static final String TOKENIZER_UNICODE61 = "unicode61";
-
- public enum MatchInfo {
+public object FtsOptions {
+ public enum class MatchInfo {
/**
* Text matching info as version 3 of the extension module.
*
- * @see Fts4#matchInfo()
+ * @see Fts4.matchInfo
*/
FTS3,
/**
* Text matching info as version 4 of the extension module.
*
- * @see Fts4#matchInfo()
+ * @see Fts4.matchInfo
*/
FTS4
}
- public enum Order {
+ public enum class Order {
/**
* Ascending returning order.
*
- * @see Fts4#order()
+ * @see Fts4.order
*/
ASC,
/**
* Descending returning order.
*
- * @see Fts4#order()
+ * @see Fts4.order
*/
DESC
}
- private FtsOptions() {
- }
+ /**
+ * The name of the default tokenizer used on FTS tables.
+ *
+ * @see Fts4.tokenizer
+ * @see Fts4.tokenizerArgs
+ */
+ public const val TOKENIZER_SIMPLE: String = "simple"
+
+ /**
+ * The name of the tokenizer based on the Porter Stemming Algorithm.
+ *
+ * @see Fts4.tokenizer
+ * @see Fts4.tokenizerArgs
+ */
+ public const val TOKENIZER_PORTER: String = "porter"
+
+ /**
+ * The name of a tokenizer implemented by the ICU library.
+ *
+ * Not available in certain Android builds (e.g. vendor).
+ *
+ * @see Fts4.tokenizer
+ * @see Fts4.tokenizerArgs
+ */
+ public const val TOKENIZER_ICU: String = "icu"
+
+ /**
+ * The name of the tokenizer that extends the [TOKENIZER_SIMPLE] tokenizer
+ * according to rules in Unicode Version 6.1.
+ *
+ * @see Fts4.tokenizer
+ * @see Fts4.tokenizerArgs
+ */
+ @RequiresApi(21)
+ public const val TOKENIZER_UNICODE61: String = "unicode61"
}
diff --git a/room/room-common/src/main/java/androidx/room/Ignore.kt b/room/room-common/src/main/java/androidx/room/Ignore.kt
index 011b949..f6af62f0 100644
--- a/room/room-common/src/main/java/androidx/room/Ignore.kt
+++ b/room/room-common/src/main/java/androidx/room/Ignore.kt
@@ -14,20 +14,14 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
* Ignores the marked element from Room's processing logic.
- * <p>
+ *
* This annotation can be used in multiple places where Room processor runs. For instance, you can
- * add it to a field of an {@link Entity} and Room will not persist that field.
+ * add it to a field of an [Entity] and Room will not persist that field.
*/
-@Target({ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR})
-@Retention(RetentionPolicy.CLASS)
-public @interface Ignore {
-}
+@Target(AnnotationTarget.FUNCTION, AnnotationTarget.FIELD, AnnotationTarget.CONSTRUCTOR)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Ignore
diff --git a/room/room-common/src/main/java/androidx/room/Index.kt b/room/room-common/src/main/java/androidx/room/Index.kt
index 04fe4e8..a3cf7bb 100644
--- a/room/room-common/src/main/java/androidx/room/Index.kt
+++ b/room/room-common/src/main/java/androidx/room/Index.kt
@@ -14,70 +14,66 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
- * Declares an index on an Entity.
- * see: <a href="https://sqlite.org/lang_createindex.html">SQLite Index Documentation</a>
- * <p>
+ * Declares an index on an [Entity].
+ * see: [SQLite Index Documentation](https://sqlite.org/lang_createindex.html)
+ *
* Adding an index usually speeds up your SELECT queries but will slow down other queries like
* INSERT or UPDATE. You should be careful when adding indices to ensure that this additional cost
* is worth the gain.
- * <p>
- * There are 2 ways to define an index in an {@link Entity}. You can either set
- * {@link ColumnInfo#index()} property to index individual fields or define composite indices via
- * {@link Entity#indices()}.
- * <p>
- * If an indexed field is embedded into another Entity via {@link Embedded}, it is <b>NOT</b>
- * added as an index to the containing {@link Entity}. If you want to keep it indexed, you must
- * re-declare it in the containing {@link Entity}.
- * <p>
- * Similarly, if an {@link Entity} extends another class, indices from the super classes are
- * <b>NOT</b> inherited. You must re-declare them in the child {@link Entity} or set
- * {@link Entity#inheritSuperIndices()} to {@code true}.
+ *
+ * There are 2 ways to define an index in an [Entity]. You can either set
+ * [ColumnInfo.index] property to index individual fields or define composite indices via
+ * [Entity.indices].
+ *
+ * If an indexed field is embedded into another Entity via [Embedded], it is **NOT**
+ * added as an index to the containing [Entity]. If you want to keep it indexed, you must
+ * re-declare it in the containing [Entity].
+ *
+ * Similarly, if an [Entity] extends another class, indices from the super classes are
+ * **NOT** inherited. You must re-declare them in the child [Entity] or set
+ * [Entity.inheritSuperIndices] to `true`.
* */
-@Target({})
-@Retention(RetentionPolicy.CLASS)
-public @interface Index {
+@Target(allowedTargets = []) // Complex annotation target
+@Retention(AnnotationRetention.BINARY)
+public annotation class Index(
/**
* List of column names in the Index.
- * <p>
+ *
* The order of columns is important as it defines when SQLite can use a particular index.
- * See <a href="https://www.sqlite.org/optoverview.html">SQLite documentation</a> for details on
+ * See [SQLite documentation](https://www.sqlite.org/optoverview.html) for details on
* index usage in the query optimizer.
*
- * @return The list of column names in the Index.
+ * @return The list of column names in the [Index].
*/
- String[] value();
+ vararg val value: String,
/**
* List of column sort orders in the Index.
- * <p>
- * The number of entries in the array should be equal to size of columns in {@link #value()}.
- * <p>
- * The default order of all columns in the index is {@link Order#ASC}.
- * <p>
+ *
+ * The number of entries in the array should be equal to size of columns in [value].
+ *
+ * The default order of all columns in the index is [Order.ASC].
+ *
* Note that there is no value in providing a sort order on a single-column index. Column sort
* order of an index are relevant on multi-column indices and specifically in those that are
* considered 'covering indices', for such indices specifying an order can have performance
* improvements on queries containing ORDER BY clauses. See
- * <a href="https://www.sqlite.org/queryplanner.html#_sorting_by_index">SQLite documentation</a>
+ * [SQLite documentation](https://www.sqlite.org/queryplanner.html#_sorting_by_index)
* for details on sorting by index and the usage of the sort order by the query optimizer.
- * <p>
+ *
* As an example, consider a table called 'Song' with two columns, 'name' and 'length'. If a
- * covering index is created for it: <code>CREATE INDEX `song_name_length` on `Song`
- * (`name` ASC, `length` DESC)</code>, then a query containing an ORDER BY clause with matching
+ * covering index is created for it: `CREATE INDEX `song_name_length` on `Song`
+ * (`name` ASC, `length` DESC)`, then a query containing an ORDER BY clause with matching
* order of the index will be able to avoid a table scan by using the index, but a mismatch in
* order won't. Therefore the columns order of the index should be the same as the most
* frequently executed query with sort order.
*
* @return The list of column sort orders in the Index.
*/
- Order[] orders() default {};
+ val orders: Array<Order> = [],
/**
* Name of the index. If not set, Room will set it to the list of columns joined by '_' and
@@ -88,27 +84,27 @@
*
* @return The name of the index.
*/
- String name() default "";
+ val name: String = "",
/**
* If set to true, this will be a unique index and any duplicates will be rejected.
*
* @return True if index is unique. False by default.
*/
- boolean unique() default false;
-
- enum Order {
+ val unique: Boolean = false
+) {
+ public enum class Order {
/**
* Ascending returning order.
*
- * @see Index#orders()
+ * @see Index.orders
*/
ASC,
/**
* Descending returning order.
*
- * @see Index#orders()
+ * @see Index.orders
*/
DESC
}
diff --git a/room/room-common/src/main/java/androidx/room/Insert.kt b/room/room-common/src/main/java/androidx/room/Insert.kt
index 5f40e8b..8fe2cf7 100644
--- a/room/room-common/src/main/java/androidx/room/Insert.kt
+++ b/room/room-common/src/main/java/androidx/room/Insert.kt
@@ -14,99 +14,101 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import kotlin.reflect.KClass
/**
- * Marks a method in a {@link Dao} annotated class as an insert method.
- * <p>
+ * Marks a method in a [Dao] annotated class as an insert method.
+ *
* The implementation of the method will insert its parameters into the database.
- * <p>
- * All of the parameters of the Insert method must either be classes annotated with {@link Entity}
+ *
+ * All of the parameters of the Insert method must either be classes annotated with [Entity]
* or collections/array of it.
- * <p>
+ *
* Example:
- * <pre>
- * {@literal @}Dao
+ *
+ * ```
+ * @Dao
* public interface MusicDao {
- * {@literal @}Insert(onConflict = OnConflictStrategy.REPLACE)
- * public void insertSongs(Song... songs);
+ * @Insert(onConflict = OnConflictStrategy.REPLACE)
+ * public fun insertSongs(varargs songs: Song)
*
- * {@literal @}Insert
- * public void insertBoth(Song song1, Song song2);
+ * @Insert
+ * public fun insertBoth(song1: Song, song2: Song)
*
- * {@literal @}Insert
- * public void insertAlbumWithSongs(Album album, List<Song> songs);
+ * @Insert
+ * public fun insertAlbumWithSongs(album: Album, songs: List<Song>);
* }
- * </pre>
- * If the target entity is specified via {@link #entity()} then the parameters can be of arbitrary
+ * ```
+ *
+ * If the target entity is specified via [entity] then the parameters can be of arbitrary
* POJO types that will be interpreted as partial entities. For example:
- * <pre>
- * {@literal @}Entity
- * public class Playlist {
- * {@literal @}PrimaryKey(autoGenerate = true)
- * long playlistId;
- * String name;
- * {@literal @}Nullable
- * String description
- * {@literal @}ColumnInfo(defaultValue = "normal")
- * String category;
- * {@literal @}ColumnInfo(defaultValue = "CURRENT_TIMESTAMP")
- * String createdTime;
- * {@literal @}ColumnInfo(defaultValue = "CURRENT_TIMESTAMP")
- * String lastModifiedTime;
- * }
*
- * public class NameAndDescription {
- * String name;
- * String description
- * }
+ * ```
+ * @Entity
+ * data class Playlist (
+ * @PrimaryKey(autoGenerate = true)
+ * val playlistId: Long,
+ * val name: String,
+ * val description: String?,
*
- * {@literal @}Dao
+ * @ColumnInfo(defaultValue = "normal")
+ * val category: String,
+ *
+ * @ColumnInfo(defaultValue = "CURRENT_TIMESTAMP")
+ * val createdTime: String,
+ *
+ * @ColumnInfo(defaultValue = "CURRENT_TIMESTAMP")
+ * val lastModifiedTime: String
+ * )
+ *
+ * data class NameAndDescription (
+ * val name: String,
+ * val description: String
+ * )
+ *
+ * @Dao
* public interface PlaylistDao {
- * {@literal @}Insert(entity = Playlist.class)
- * public void insertNewPlaylist(NameAndDescription nameDescription);
+ * @Insert(entity = Playlist::class)
+ * public fun insertNewPlaylist(nameDescription: NameAndDescription);
* }
- * </pre>
+ * ```
*
- * @see Update
- * @see Delete
+ * @see [Update]
+ * @see [Delete]
*/
-@Target({ElementType.METHOD})
-@Retention(RetentionPolicy.CLASS)
-public @interface Insert {
+@Target(AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Insert(
/**
* The target entity of the insert method.
- * <p>
+ *
* When this is declared, the insert method parameters are interpreted as partial entities when
* the type of the parameter differs from the target. The POJO class that represents the entity
* must contain all of the non-null fields without default values of the target entity.
- * <p>
- * If the target entity contains a {@link PrimaryKey} that is auto generated, then the POJO
+ *
+ * If the target entity contains a [PrimaryKey] that is auto generated, then the POJO
* class doesn't need an equal primary key field, otherwise primary keys must also be present
* in the POJO.
- * <p>
+ *
* By default the target entity is interpreted by the method parameters.
*
* @return the target entity of the insert method or none if the method should use the
* parameter type entities.
*/
- Class<?> entity() default Object.class;
+ val entity: KClass<*> = Any::class,
/**
* What to do if a conflict happens.
- * <p>
- * Use {@link OnConflictStrategy#ABORT} (default) to roll back the transaction on conflict.
- * Use {@link OnConflictStrategy#REPLACE} to replace the existing rows with the new rows.
- * Use {@link OnConflictStrategy#IGNORE} to keep the existing rows.
*
- * @return How to handle conflicts. Defaults to {@link OnConflictStrategy#ABORT}.
+ * Use [OnConflictStrategy.ABORT] (default) to roll back the transaction on conflict.
+ * Use [OnConflictStrategy.REPLACE] to replace the existing rows with the new rows.
+ * Use [OnConflictStrategy.IGNORE] to keep the existing rows.
+ *
+ * @return How to handle conflicts. Defaults to [OnConflictStrategy.ABORT].
*/
@OnConflictStrategy
- int onConflict() default OnConflictStrategy.ABORT;
-}
+ val onConflict: Int = OnConflictStrategy.ABORT
+)
diff --git a/room/room-common/src/main/java/androidx/room/Junction.kt b/room/room-common/src/main/java/androidx/room/Junction.kt
index deb8537..3673696 100644
--- a/room/room-common/src/main/java/androidx/room/Junction.kt
+++ b/room/room-common/src/main/java/androidx/room/Junction.kt
@@ -14,72 +14,72 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import kotlin.reflect.KClass
/**
* Declares a junction to be used for joining a relationship.
- * <p>
- * If a {@link Relation} should use an associative table (also know as junction table or join
+ *
+ * If a [Relation] should use an associative table (also know as junction table or join
* table) then you can use this annotation to reference such table. This is useful for fetching
* many-to-many relations.
- * <pre>
- * {@literal @}Entity(primaryKeys = {"pId", "sId"})
+ *
+ * ```
+ * @Entity(primaryKeys = {"pId", "sId"})
* public class PlaylistSongXRef {
- * int pId;
- * int sId;
+ * val pId: Int,
+ * val sId: Int
* }
* public class PlaylistWithSongs {
- * {@literal @}Embedded
- * Playlist playlist;
- * {@literal @}Relation(
+ * @Embedded
+ * val playlist: Playlist
+ * @Relation(
* parentColumn = "playlistId",
- * entity = Song.class,
+ * entity = Song::class,
* entityColumn = "songId",
- * associateBy = {@literal @}Junction(
- * value = PlaylistSongXRef.class,
+ * associateBy = @Junction(
+ * value = PlaylistSongXRef::class,
* parentColumn = "pId",
* entityColumn = "sId")
* )
- * List<String> songs;
+ * val songs: List<String>
* }
- * {@literal @}Dao
- * public interface MusicDao {
- * {@literal @}Query("SELECT * FROM Playlist")
- * List<PlaylistWithSongs> getAllPlaylistsWithSongs();
- * }
- * </pre>
- * <p>
- * In the above example the many-to-many relationship between {@code Song} and {@code Playlist} has
- * an associative table defined by the entity {@code PlaylistSongXRef}.
*
- * @see Relation
+ * @Dao
+ * public interface MusicDao {
+ * @Query("SELECT * FROM Playlist")
+ * val getAllPlaylistsWithSongs(): List<PlaylistWithSongs>
+ * }
+ * ```
+ *
+ * In the above example the many-to-many relationship between `Song` and `Playlist` has
+ * an associative table defined by the entity `PlaylistSongXRef`.
+ *
+ * @see [Relation]
*/
-@Target({})
-@Retention(RetentionPolicy.CLASS)
-public @interface Junction {
+@Target(allowedTargets = []) // Complex annotation target
+@Retention(AnnotationRetention.BINARY)
+public annotation class Junction(
/**
* An entity or database view to be used as a junction table when fetching the
* relating entities.
*
* @return The entity or database view to be used as a junction table.
*/
- Class<?> value();
+ val value: KClass<*>,
/**
- * The junction column that will be used to match against the {@link Relation#parentColumn()}.
- * <p>
- * If not specified it defaults to {@link Relation#parentColumn()}.
+ * The junction column that will be used to match against the [Relation.parentColumn].
+ *
+ * If not specified it defaults to [Relation.parentColumn].
*/
- String parentColumn() default "";
+ val parentColumn: String = "",
/**
- * The junction column that will be used to match against the {@link Relation#entityColumn()}.
- * <p>
- * If not specified it defaults to {@link Relation#entityColumn()}.
+ * The junction column that will be used to match against the [Relation.entityColumn].
+ *
+ * If not specified it defaults to [Relation.entityColumn].
*/
- String entityColumn() default "";
-}
+ val entityColumn: String = ""
+)
diff --git a/room/room-common/src/main/java/androidx/room/MapInfo.kt b/room/room-common/src/main/java/androidx/room/MapInfo.kt
index 549d1f5..4a17d362 100644
--- a/room/room-common/src/main/java/androidx/room/MapInfo.kt
+++ b/room/room-common/src/main/java/androidx/room/MapInfo.kt
@@ -14,54 +14,50 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
* Declares which column(s) are used to build a map or multimap return value in a {@link Dao}
* query method.
- * <p>
+ *
* This annotation is required when the key or value of the Map is a single column of one of the
* built in types (primitives, boxed primitives, enum, String, byte[], ByteBuffer) or a type with a
* converter (e.g. Date, UUID, etc).
- * <p>
+ *
* The use of this annotation provides clarity on which column should be used in retrieving
* information required by the return type.
- * <p>
- * Example:
- * <pre>
- * {@literal @}MapInfo(keyColumn = "artistName", valueColumn = "songName")
- * {@literal @}Query("SELECT * FROM Artist JOIN Song ON Artist.artistName = Song.artist")
- * Map<String, List<String>> getArtistNameToSongNames();
*
- * {@literal @}MapInfo(valueColumn = "songCount")
- * {@literal @}Query("SELECT *, COUNT(mSongId) as songCount FROM Artist JOIN Song ON
+ * Example:
+ *
+ * ```
+ * @MapInfo(keyColumn = "artistName", valueColumn = "songName")
+ * @Query("SELECT * FROM Artist JOIN Song ON Artist.artistName = Song.artist")
+ * fun getArtistNameToSongNames(): Map<String, List<String>>
+ *
+ * @MapInfo(valueColumn = "songCount")
+ * @Query("SELECT *, COUNT(mSongId) as songCount FROM Artist JOIN Song ON
* Artist.artistName = Song.artist GROUP BY artistName")
- * Map<Artist, Integer> getArtistAndSongCounts();
- * </pre>
- * <p>
+ * fun getArtistAndSongCounts(): Map<Artist, Integer>
+ * ```
+ *
* To use the @MapInfo annotation, you must provide either the key column name, value column
- * name, or both, based on the {@link Dao}'s method return type. Column(s) specified in the
+ * name, or both, based on the [Dao]'s method return type. Column(s) specified in the
* provided @MapInfo annotation must be present in the query result.
*/
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.CLASS)
-public @interface MapInfo {
+@Target(AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class MapInfo(
/**
* The name of the column to be used for the map's keys.
*
* @return The key column name.
*/
- String keyColumn() default "";
+ val keyColumn: String = "",
/**
* The name of the column to be used for the map's values.
*
* @return The value column name.
*/
- String valueColumn() default "";
-}
+ val valueColumn: String = ""
+)
diff --git a/room/room-common/src/main/java/androidx/room/OnConflictStrategy.kt b/room/room-common/src/main/java/androidx/room/OnConflictStrategy.kt
index 9aeb78c..dcce625 100644
--- a/room/room-common/src/main/java/androidx/room/OnConflictStrategy.kt
+++ b/room/room-common/src/main/java/androidx/room/OnConflictStrategy.kt
@@ -13,54 +13,57 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package androidx.room
-package androidx.room;
-
-import androidx.annotation.IntDef;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
+import androidx.annotation.IntDef
+import androidx.room.OnConflictStrategy.Companion.ABORT
+import androidx.room.OnConflictStrategy.Companion.FAIL
+import androidx.room.OnConflictStrategy.Companion.IGNORE
+import androidx.room.OnConflictStrategy.Companion.REPLACE
+import androidx.room.OnConflictStrategy.Companion.ROLLBACK
/**
* Set of conflict handling strategies for various {@link Dao} methods.
*/
-@Retention(RetentionPolicy.CLASS)
-@IntDef({OnConflictStrategy.REPLACE, OnConflictStrategy.ROLLBACK, OnConflictStrategy.ABORT,
- OnConflictStrategy.FAIL, OnConflictStrategy.IGNORE})
-public @interface OnConflictStrategy {
- /**
- * OnConflict strategy constant to replace the old data and continue the transaction.
- * <p>
- * An {@link Insert} DAO method that returns the inserted rows ids will never return -1 since
- * this strategy will always insert a row even if there is a conflict.
- */
- int REPLACE = 1;
- /**
- * OnConflict strategy constant to rollback the transaction.
- *
- * @deprecated Does not work with Android's current SQLite bindings. Use {@link #ABORT} to
- * roll back the transaction.
- */
- @Deprecated
- int ROLLBACK = 2;
- /**
- * OnConflict strategy constant to abort the transaction. <em>The transaction is rolled
- * back.</em>
- */
- int ABORT = 3;
- /**
- * OnConflict strategy constant to fail the transaction.
- *
- * @deprecated Does not work as expected. The transaction is rolled back. Use {@link #ABORT}.
- */
- @Deprecated
- int FAIL = 4;
- /**
- * OnConflict strategy constant to ignore the conflict.
- * <p>
- * An {@link Insert} DAO method that returns the inserted rows ids will return -1 for rows
- * that are not inserted since this strategy will ignore the row if there is a conflict.
- */
- int IGNORE = 5;
-
+@Retention(AnnotationRetention.BINARY)
+@Suppress("DEPRECATION")
+@IntDef(REPLACE, ROLLBACK, ABORT, FAIL, IGNORE)
+public annotation class OnConflictStrategy {
+ public companion object {
+ /**
+ * OnConflict strategy constant to replace the old data and continue the transaction.
+ *
+ * An [Insert] DAO method that returns the inserted rows ids will never return -1 since
+ * this strategy will always insert a row even if there is a conflict.
+ */
+ public const val REPLACE: Int = 1
+ /**
+ * OnConflict strategy constant to rollback the transaction.
+ *
+ * @deprecated Does not work with Android's current SQLite bindings. Use [ABORT] to
+ * roll back the transaction.
+ */
+ @Deprecated("Use ABORT instead.")
+ public const val ROLLBACK: Int = 2
+ /**
+ * OnConflict strategy constant to abort the transaction. *The transaction is rolled
+ * back.*
+ */
+ public const val ABORT: Int = 3
+ /**
+ * OnConflict strategy constant to fail the transaction.
+ *
+ * @deprecated Does not work as expected. The transaction is rolled back. Use
+ * [ABORT].
+ */
+ @Deprecated("Use ABORT instead.")
+ public const val FAIL: Int = 4
+ /**
+ * OnConflict strategy constant to ignore the conflict.
+ *
+ * An [Insert] DAO method that returns the inserted rows ids will return -1 for rows
+ * that are not inserted since this strategy will ignore the row if there is a conflict.
+ */
+ public const val IGNORE: Int = 5
+ }
}
diff --git a/room/room-common/src/main/java/androidx/room/PrimaryKey.kt b/room/room-common/src/main/java/androidx/room/PrimaryKey.kt
index aac96ad..8b88bc8 100644
--- a/room/room-common/src/main/java/androidx/room/PrimaryKey.kt
+++ b/room/room-common/src/main/java/androidx/room/PrimaryKey.kt
@@ -14,45 +14,40 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
- * Marks a field in an {@link Entity} as the primary key.
- * <p>
- * If you would like to define a composite primary key, you should use {@link Entity#primaryKeys()}
+ * Marks a field in an [Entity] as the primary key.
+ *
+ * If you would like to define a composite primary key, you should use [Entity.primaryKeys]
* method.
- * <p>
- * Each {@link Entity} must declare a primary key unless one of its super classes declares a
- * primary key. If both an {@link Entity} and its super class defines a {@code PrimaryKey}, the
- * child's {@code PrimaryKey} definition will override the parent's {@code PrimaryKey}.
- * <p>
- * If {@code PrimaryKey} annotation is used on a {@link Embedded} field, all columns inherited
+ *
+ * Each [Entity] must declare a primary key unless one of its super classes declares a
+ * primary key. If both an [Entity] and its super class defines a [PrimaryKey], the
+ * child's [PrimaryKey] definition will override the parent's [PrimaryKey].
+ *
+ * If `PrimaryKey` annotation is used on a [Embedded] field, all columns inherited
* from that embedded field becomes the composite primary key (including its grand children
* fields).
*/
-@Target({ElementType.FIELD, ElementType.METHOD})
-@Retention(RetentionPolicy.CLASS)
-public @interface PrimaryKey {
+@Target(AnnotationTarget.FIELD, AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class PrimaryKey(
/**
* Set to true to let SQLite generate the unique id.
- * <p>
- * When set to {@code true}, the SQLite type affinity for the field should be {@code INTEGER}.
- * <p>
- * If the field type is {@code long} or {@code int} (or its TypeConverter converts it to a
- * {@code long} or {@code int}), {@link Insert} methods treat {@code 0} as not-set while
+ *
+ * When set to `true`, the SQLite type affinity for the field should be `INTEGER`.
+ *
+ * If the field type is `Long` or `Int` (or its TypeConverter converts it to a
+ * `Long` or `Int`), [Insert] methods treat `0` as not-set while
* inserting the item.
- * <p>
- * If the field's type is {@link Integer} or {@link Long} (or its TypeConverter converts it to
- * an {@link Integer} or a {@link Long}), {@link Insert} methods treat {@code null} as
+ *
+ * If the field's type is [Integer] or [Long] (or its TypeConverter converts it to
+ * an [Integer] or [Long]), [Insert] methods treat `null` as
* not-set while inserting the item.
*
* @return Whether the primary key should be auto-generated by SQLite or not. Defaults
* to false.
*/
- boolean autoGenerate() default false;
-}
+ val autoGenerate: Boolean = false
+)
diff --git a/room/room-common/src/main/java/androidx/room/ProvidedAutoMigrationSpec.kt b/room/room-common/src/main/java/androidx/room/ProvidedAutoMigrationSpec.kt
index ee63b76..da65762 100644
--- a/room/room-common/src/main/java/androidx/room/ProvidedAutoMigrationSpec.kt
+++ b/room/room-common/src/main/java/androidx/room/ProvidedAutoMigrationSpec.kt
@@ -14,22 +14,16 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
* Marks a class as an auto migration spec that will be provided to Room at runtime.
- * <p>
+ *
* An instance of a class annotated with this annotation has to be provided to Room using
- * {@code Room.databaseBuilder.addAutoMigrationSpec(AutoMigrationSpec)}. Room will verify that
- * the spec is provided in the builder configuration and if not, an
- * {@link IllegalArgumentException} will be thrown.
+ * `Room.databaseBuilder.addAutoMigrationSpec(AutoMigrationSpec)`. Room will verify that
+ * the spec is provided in the builder configuration and if not, an [IllegalArgumentException]
+ * will be thrown.
*/
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface ProvidedAutoMigrationSpec {
-}
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class ProvidedAutoMigrationSpec
diff --git a/room/room-common/src/main/java/androidx/room/ProvidedTypeConverter.kt b/room/room-common/src/main/java/androidx/room/ProvidedTypeConverter.kt
index fa83bdc..1838019 100644
--- a/room/room-common/src/main/java/androidx/room/ProvidedTypeConverter.kt
+++ b/room/room-common/src/main/java/androidx/room/ProvidedTypeConverter.kt
@@ -14,21 +14,15 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
* Marks a class as a type converter that will be provided to Room at runtime.
* If Room uses the annotated type converter class, it will verify that it is provided in the
* builder and if not, will throw an exception.
* An instance of a class annotated with this annotation has to be provided to Room using
- * {@code Room.databaseBuilder.addTypeConverter(Object)}
+ * `Room.databaseBuilder.addTypeConverter(Object)`
*/
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface ProvidedTypeConverter {
-}
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class ProvidedTypeConverter
diff --git a/room/room-common/src/main/java/androidx/room/Query.kt b/room/room-common/src/main/java/androidx/room/Query.kt
index 68015fa..3872468 100644
--- a/room/room-common/src/main/java/androidx/room/Query.kt
+++ b/room/room-common/src/main/java/androidx/room/Query.kt
@@ -14,126 +14,128 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
- * Marks a method in a {@link Dao} annotated class as a query method.
- * <p>
+ * Marks a method in a `Dao` annotated class as a query method.
+ *
* The value of the annotation includes the query that will be run when this method is called. This
- * query is <b>verified at compile time</b> by Room to ensure that it compiles fine against the
+ * query is **verified at compile time** by Room to ensure that it compiles fine against the
* database.
- * <p>
+ *
* The arguments of the method will be bound to the bind arguments in the SQL statement. See
- * <href="https://www.sqlite.org/c3ref/bind_blob.html">SQLite's binding documentation</> for
- * details of bind arguments in SQLite.
- * <p>
- * Room only supports named bind parameter {@code :name} to avoid any confusion between the
+ * [SQLite's binding documentation](https://www.sqlite.org/c3ref/bind_blob.html) for details of bind
+ * arguments in SQLite.
+ *
+ * Room only supports named bind parameter `:name` to avoid any confusion between the
* method parameters and the query bind parameters.
- * <p>
+ *
* Room will automatically bind the parameters of the method into the bind arguments. This is done
* by matching the name of the parameters to the name of the bind arguments.
- * <pre>
- * {@literal @}Query("SELECT * FROM song WHERE release_year = :year")
- * public abstract List<Song> findSongsByReleaseYear(int year);
- * </pre>
- * <p>
+ *
+ * ```
+ * @Query("SELECT * FROM song WHERE release_year = :year")
+ * public abstract fun findSongsByReleaseYear(year: Int): List<Song>
+ * ```
+ *
* As an extension over SQLite bind arguments, Room supports binding a list of parameters to the
* query. At runtime, Room will build the correct query to have matching number of bind arguments
* depending on the number of items in the method parameter.
- * <pre>
- * {@literal @}Query("SELECT * FROM song WHERE id IN(:songIds)")
- * public abstract List<Song> findByIds(long[] songIds);
- * </pre>
- * For the example above, if the {@code songIds} is an array of 3 elements, Room will run the
- * query as: {@code SELECT * FROM song WHERE id IN(?, ?, ?)} and bind each item in the
- * {@code songIds} array into the statement. One caveat of this type of binding is that only 999
- * items can be bound to the query, this is a limitation of SQLite (
- * <href="https://www.sqlite.org/limits.html">see Section 9 of SQLite Limits</>).
- * <p>
- * There are 4 type of statements supported in {@code Query} methods: SELECT, INSERT, UPDATE, and
+ *
+ * ```
+ * @Query("SELECT * FROM song WHERE id IN(:songIds)")
+ * public abstract fun findByIds(songIds: Array<Long>): List<Song>
+ * ```
+ *
+ * For the example above, if the `songIds` is an array of 3 elements, Room will run the
+ * query as: `SELECT * FROM song WHERE id IN(?, ?, ?)` and bind each item in the
+ * `songIds` array into the statement. One caveat of this type of binding is that only 999
+ * items can be bound to the query, this is a limitation of SQLite
+ * [see Section 9 of SQLite Limits](https://www.sqlite.org/limits.html)
+ *
+ * There are 4 type of statements supported in `Query` methods: SELECT, INSERT, UPDATE, and
* DELETE.
- * <p>
+ *
* For SELECT queries, Room will infer the result contents from the method's return type and
* generate the code that will automatically convert the query result into the method's return
* type. For single result queries, the return type can be any data object (also known as POJOs).
- * For queries that return multiple values, you can use {@link java.util.List} or {@code Array}.
- * In addition to these, any query may return {@link android.database.Cursor Cursor} or any query
- * result can be wrapped in a {@link androidx.lifecycle.LiveData LiveData}.
- * <p>
- * INSERT queries can return {@code void} or {@code long}. If it is a {@code long}, the value is the
+ * For queries that return multiple values, you can use [java.util.List] or `Array`.
+ * In addition to these, any query may return [android.database.Cursor] or any query
+ * result can be wrapped in a [androidx.lifecycle.LiveData].
+ *
+ * INSERT queries can return `void` or `Long`. If it is a `Long`, the value is the
* SQLite rowid of the row inserted by this query. Note that queries which insert multiple rows
- * cannot return more than one rowid, so avoid such statements if returning {@code long}.
- * <p>
- * UPDATE or DELETE queries can return {@code void} or {@code int}. If it is an {@code int},
+ * cannot return more than one rowid, so avoid such statements if returning `Long`.
+ *
+ * UPDATE or DELETE queries can return `void` or `Int`. If it is an `Int`,
* the value is the number of rows affected by this query.
- * <p>
- * <b>Flow</b>
- * <p>
- * If you are using Kotlin, you can also return {@code Flow<T>} from query methods. This creates a
- * {@code Flow<T>} object that emits the results of the query and re-dispatches the query every
+ *
+ * **Flow**
+ *
+ * If you are using Kotlin, you can also return `Flow<T>` from query methods. This creates a
+ * `Flow<T>` object that emits the results of the query and re-dispatches the query every
* time the data in the queried table changes.
- * <p>
- * Note that querying a table with a return type of {@code Flow<T>} always returns the first row
+ *
+ * Note that querying a table with a return type of `Flow<T>` always returns the first row
* in the result set, rather than emitting all of the rows in sequence. To observe changes over
- * multiple rows in a table, use a return type of {@code Flow<List<T>>} instead.
- * <p>
+ * multiple rows in a table, use a return type of `Flow<List<T>>` instead.
+ *
* Keep nullability in mind when choosing a return type, as it affects how the query method handles
* empty tables:
- * <ul>
- * <li> <p>When the return type is {@code Flow<T>}, querying an empty table throws a null pointer
+ *
+ * * When the return type is `Flow<T>`, querying an empty table throws a null pointer
* exception.
- * <li> <p>When the return type is {@code Flow<T?>}, querying an empty table emits a null value.
- * <li> <p>When the return type is {@code Flow<List<T>>}, querying an empty table emits an empty
- * list. </ul>
- * <p>
- * <b>RxJava2</b>
- * <p>
- * If you are using RxJava2, you can also return {@code Flowable<T>} or
- * {@code Publisher<T>} from query methods. Since Reactive Streams does not allow {@code null}, if
- * the query returns a nullable type, it will not dispatch anything if the value is {@code null}
- * (like fetching an {@link Entity} row that does not exist).
- * You can return {@code Flowable<T[]>} or {@code Flowable<List<T>>} to workaround this limitation.
- * <p>
- * Both {@code Flowable<T>} and {@code Publisher<T>} will observe the database for changes and
+ * * When the return type is `Flow<T?>`, querying an empty table emits a null value.
+ * * When the return type is `Flow<List<T>>`, querying an empty table emits an empty
+ * list.
+ *
+ * **RxJava2**
+ *
+ * If you are using RxJava2, you can also return `Flowable<T>` or
+ * `Publisher<T>` from query methods. Since Reactive Streams does not allow `null`, if
+ * the query returns a nullable type, it will not dispatch anything if the value is `null`
+ * (like fetching an [Entity] row that does not exist).
+ * You can return [Flowable<T[]>] or [Flowable<List<T>>] to workaround this limitation.
+ *
+ * Both `Flowable<T>` and `Publisher<T>` will observe the database for changes and
* re-dispatch if data changes. If you want to query the database without observing changes, you can
- * use {@code Maybe<T>} or {@code Single<T>}. If a {@code Single<T>} query returns {@code null},
- * Room will throw {@link androidx.room.EmptyResultSetException EmptyResultSetException}.
- * <p>
+ * use `Maybe<T>` or `Single<T>`. If a `Single<T>` query returns `null`,
+ * Room will throw [androidx.room.EmptyResultSetException].
+ *
* Additionally if the statement is an INSERT, UPDATE or DELETE then the return types,
- * {@code Single<T>}, {@code Maybe<T>} and {@code Completable} are supported.
- * <p>
+ * `Single<T>`, `Maybe<T>` and `Completable` are supported.
+ *
* You can return arbitrary POJOs from your query methods as long as the fields of the POJO match
* the column names in the query result.
- * <p>
+ *
* For example, if you have class:
- * <pre>
- * class SongDuration {
- * String name;
- * {@literal @}ColumnInfo(name = "duration")
- * String length;
- * }
- * </pre>
+ *
+ * ```
+ * data class SongDuration (
+ * val name: String,
+ * @ColumnInfo(name = "duration")
+ * val length: String
+ * )
+ * ```
+ *
* You can write a query like this:
- * <pre>
- * {@literal @}Query("SELECT name, duration FROM song WHERE id = :songId LIMIT 1")
- * public abstract SongDuration findSongDuration(int songId);
- * </pre>
+ *
+ * ```
+ * @Query("SELECT name, duration FROM song WHERE id = :songId LIMIT 1")
+ * public abstract fun findSongDuration(songId: Int): SongDuration
+ * ```
+ *
* And Room will create the correct implementation to convert the query result into a
- * {@code SongDuration} object. If there is a mismatch between the query result and the fields of
+ * `SongDuration` object. If there is a mismatch between the query result and the fields of
* the POJO, and as long as there is at least 1 field match, Room prints a
- * {@link RoomWarnings#CURSOR_MISMATCH} warning and sets as many fields as it can.
+ * [RoomWarnings.CURSOR_MISMATCH] warning and sets as many fields as it can.
*/
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.CLASS)
-public @interface Query {
+@Target(AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Query(
/**
* The SQLite query to be run.
* @return The query to be run.
*/
- String value();
-}
+ val value: String
+)
diff --git a/room/room-common/src/main/java/androidx/room/RawQuery.kt b/room/room-common/src/main/java/androidx/room/RawQuery.kt
index a80b713..54ebfd3 100644
--- a/room/room-common/src/main/java/androidx/room/RawQuery.kt
+++ b/room/room-common/src/main/java/androidx/room/RawQuery.kt
@@ -14,156 +14,154 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import kotlin.reflect.KClass
/**
- * Marks a method in a {@link Dao} annotated class as a raw query method where you can pass the
- * query as a {@link androidx.sqlite.db.SupportSQLiteQuery SupportSQLiteQuery}.
- * <pre>
- * {@literal @}Dao
+ * Marks a method in a [Dao] annotated class as a raw query method where you can pass the
+ * query as a [androidx.sqlite.db.SupportSQLiteQuery].
+ *
+ * ```
+ * @Dao
* interface RawDao {
- * {@literal @}RawQuery
- * Song getSongViaQuery(SupportSQLiteQuery query);
+ * @RawQuery
+ * getSongViaQuery(query: SupportSQLiteQuery): Song
* }
*
* // Usage of RawDao
- * SimpleSQLiteQuery query = new SimpleSQLiteQuery(
+ * val query = SimpleSQLiteQuery(
* "SELECT * FROM Song WHERE id = ? LIMIT 1",
- * new Object[]{ songId});
- * Song song = rawDao.getSongViaQuery(query);
- * </pre>
- * <p>
+ * arrayOf<Any>(songId)
+ * )
+ * val song = rawDao.getSongViaQuery(query)
+ * ```
+ *
* Room will generate the code based on the return type of the function and failure to
* pass a proper query will result in a runtime failure or an undefined result.
- * <p>
- * If you know the query at compile time, you should always prefer {@link Query} since it validates
+ *
+ * If you know the query at compile time, you should always prefer [Query] since it validates
* the query at compile time and also generates more efficient code since Room can compute the
* query result at compile time (e.g. it does not need to account for possibly missing columns in
* the response).
- * <p>
- * On the other hand, {@code RawQuery} serves as an escape hatch where you can build your own
+ *
+ * On the other hand, `RawQuery` serves as an escape hatch where you can build your own
* SQL query at runtime but still use Room to convert it into objects.
- * <p>
- * {@code RawQuery} methods must return a non-void type. If you want to execute a raw query that
- * does not return any value, use {@link androidx.room.RoomDatabase#query
- * RoomDatabase#query} methods.
- * <p>
+ *
+ * `RawQuery` methods must return a non-void type. If you want to execute a raw query that
+ * does not return any value, use [androidx.room.RoomDatabase.query] methods.
+ *
* RawQuery methods can only be used for read queries. For write queries, use
- * {@link androidx.room.RoomDatabase#getOpenHelper
- * RoomDatabase.getOpenHelper().getWritableDatabase()}.
- * <p>
- * <b>Observable Queries:</b>
- * <p>
- * {@code RawQuery} methods can return observable types but you need to specify which tables are
- * accessed in the query using the {@link #observedEntities()} field in the annotation.
- * <pre>
- * {@literal @}Dao
+ * [androidx.room.RoomDatabase.getOpenHelper].
+ *
+ * **Observable Queries:**
+ *
+ * `RawQuery` methods can return observable types but you need to specify which tables are
+ * accessed in the query using the [observedEntities] field in the annotation.
+ *
+ * ```
+ * @Dao
* interface RawDao {
- * {@literal @}RawQuery(observedEntities = Song.class)
- * LiveData<List<Song>> getSongs(SupportSQLiteQuery query);
+ * @RawQuery(observedEntities = Song::class)
+ * fun getSongs(query: SupportSQLiteQuery): LiveData<List<Song>>
* }
*
* // Usage of RawDao
- * LiveData<List<Song>> liveSongs = rawDao.getSongs(
- * new SimpleSQLiteQuery("SELECT * FROM song ORDER BY name DESC"));
- * </pre>
- * <b>Returning POJOs:</b>
- * <p>
- * RawQueries can also return plain old java objects, similar to {@link Query} methods.
- * <pre>
- * public class NameAndReleaseYear {
- * final String name;
- * {@literal @}ColumnInfo(name = "release_year")
- * final int year;
+ * val liveSongs = rawDao.getSongs(
+ * SimpleSQLiteQuery("SELECT * FROM song ORDER BY name DESC")
+ * )
+ * ```
*
- * public NameAndReleaseYear(String name, int year) {
- * this.name = name;
- * this.year = year;
- * }
- * }
+ * **Returning POJOs:**
*
- * {@literal @}Dao
+ * RawQueries can also return plain old java objects, similar to [Query] methods.
+ *
+ * ```
+ * data class NameAndReleaseYear (
+ * val name: String,
+ * @ColumnInfo(name = "release_year")
+ * val year: Int
+ * )
+ *
+ * @Dao
* interface RawDao {
- * {@literal @}RawQuery
- * NameAndReleaseYear getNameAndReleaseYear(SupportSQLiteQuery query);
+ * @RawQuery
+ * fun getNameAndReleaseYear(query: SupportSQLiteQuery): NameAndReleaseYear
* }
*
* // Usage of RawDao
- * NameAndReleaseYear result = rawDao.getNameAndReleaseYear(
- * new SimpleSQLiteQuery("SELECT * FROM song WHERE id = ?", new Object[]{songId}))
- * </pre>
- * <p>
- * <b>POJOs with Embedded Fields:</b>
- * <p>
- * {@code RawQuery} methods can return POJOs that include {@link Embedded} fields as well.
- * <pre>
- * public class SongAndArtist {
- * {@literal @}Embedded
- * public Song song;
- * {@literal @}Embedded
- * public Artist artist;
- * }
+ * val result: NameAndReleaseYear = rawDao.getNameAndReleaseYear(
+ * SimpleSQLiteQuery("SELECT * FROM song WHERE id = ?", arrayOf<Any>(songId)))
+ * ```
*
- * {@literal @}Dao
+ * **POJOs with Embedded Fields:**
+ *
+ * `RawQuery` methods can return POJOs that include [Embedded] fields as well.
+ * ```
+ * data class SongAndArtist (
+ * @Embedded
+ * val song: Song,
+ * @Embedded
+ * val artist: Artist
+ * )
+ *
+ * @Dao
* interface RawDao {
- * {@literal @}RawQuery
- * SongAndArtist getSongAndArtist(SupportSQLiteQuery query);
+ * @RawQuery
+ * fun getSongAndArtist(query: SupportSQLiteQuery): SongAndArtist
* }
*
* // Usage of RawDao
- * SongAndArtist result = rawDao.getSongAndArtist(
- * new SimpleSQLiteQuery("SELECT * FROM Song, Artist WHERE Song.artistId = Artist.id LIMIT 1"))
- * </pre>
+ * val result: = rawDao.getSongAndArtist(
+ * SimpleSQLiteQuery("SELECT * FROM Song, Artist WHERE Song.artistId = Artist.id LIMIT 1"))
+ * ```
*
- * <b>Relations:</b>
- * <p>
- * {@code RawQuery} return types can also be objects with {@link Relation Relations}.
- * <pre>
- * public class AlbumAndSongs {
- * {@literal @}Embedded
- * public Album album;
- * {@literal @}Relation(parentColumn = "id", entityColumn = "albumId")
- * public List<Song> pets;
+ * **Relations:**
+ *
+ * `RawQuery` return types can also be objects with [Relation].
+ * ```
+ * data class AlbumAndSongs {
+ * @Embedded
+ * public val album: Album,
+ * @Relation(parentColumn = "id", entityColumn = "albumId")
+ * public val pets: List<Song>
* }
*
- * {@literal @}Dao
+ * @Dao
* interface RawDao {
- * {@literal @}RawQuery
- * List<AlbumAndSongs> getAlbumAndSongs(SupportSQLiteQuery query);
+ * @RawQuery
+ * fun getAlbumAndSongs(query: SupportSQLiteQuery): List<AlbumAndSongs>
* }
*
* // Usage of RawDao
- * List<AlbumAndSongs> result = rawDao.getAlbumAndSongs(
- * new SimpleSQLiteQuery("SELECT * FROM album"));
- * </pre>
+ * val result: = rawDao.getAlbumAndSongs(
+ * SimpleSQLiteQuery("SELECT * FROM album")
+ * ): List<AlbumAndSongs>
+ * ```
*/
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.CLASS)
-public @interface RawQuery {
+@Target(AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class RawQuery(
/**
* Denotes the list of entities which are accessed in the provided query and should be observed
* for invalidation if the query is observable.
- * <p>
- * The listed classes should either be annotated with {@link Entity} or they should reference to
- * at least 1 Entity (via {@link Embedded} or {@link Relation}).
- * <p>
+ *
+ * The listed classes should either be annotated with [Entity] or they should reference to
+ * at least 1 [Entity] (via [Embedded] or [Relation]).
+ *
* Providing this field in a non-observable query has no impact.
- * <pre>
- * {@literal @}Dao
+ *
+ * ```
+ * @Dao
* interface RawDao {
- * {@literal @}RawQuery(observedEntities = Song.class)
- * LiveData<List<User>> getUsers(String query);
+ * @RawQuery(observedEntities = Song::class)
+ * fun getUsers(query: String): LiveData<List<User>>
* }
- * LiveData<List<Song>> liveSongs = rawDao.getUsers(
- * "SELECT * FROM song ORDER BY name DESC");
- * </pre>
+ * val liveSongs: = rawDao.getUsers(
+ * "SELECT * FROM song ORDER BY name DESC")
+ * ```
*
* @return List of entities that should invalidate the query if changed.
*/
- Class<?>[] observedEntities() default {};
-}
+ val observedEntities: Array<KClass<*>> = []
+)
diff --git a/room/room-common/src/main/java/androidx/room/Relation.kt b/room/room-common/src/main/java/androidx/room/Relation.kt
index 558735b..0a52a55 100644
--- a/room/room-common/src/main/java/androidx/room/Relation.kt
+++ b/room/room-common/src/main/java/androidx/room/Relation.kt
@@ -14,130 +14,133 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import kotlin.reflect.KClass
/**
* A convenience annotation which can be used in a POJO to automatically fetch relation entities.
* When the POJO is returned from a query, all of its relations are also fetched by Room.
*
- * <pre>
- * {@literal @}Entity
- * public class Song {
- * {@literal @} PrimaryKey
- * int songId;
- * int albumId;
- * String name;
+ * ```
+ * @Entity
+ * data class Song (
+ * @PrimaryKey
+ * val songId: Int,
+ * val albumId: Int,
+ * val name: String
* // other fields
- * }
- * public class AlbumNameAndAllSongs {
- * int id;
- * String name;
- * {@literal @}Relation(parentColumn = "id", entityColumn = "albumId")
- * List<Song> songs;
- * }
+ * )
*
- * {@literal @}Dao
+ * data class AlbumNameAndAllSongs (
+ * val id: Int,
+ * val name: String,
+ * @Relation(parentColumn = "id", entityColumn = "albumId")
+ * val songs: List<Song>
+ * )
+ *
+ * @Dao
* public interface MusicDao {
- * {@literal @}Query("SELECT id, name FROM Album")
- * List<AlbumNameAndAllSongs> loadAlbumAndSongs();
+ * @Query("SELECT id, name FROM Album")
+ * fun loadAlbumAndSongs(): List<AlbumNameAndAllSongs>
* }
- * </pre>
- * <p>
+ * ```
+ *
* For a one-to-many or many-to-many relationship, the type of the field annotated with
- * {@code Relation} must be a {@link java.util.List} or {@link java.util.Set}.
- * <p>
- * By default, the {@link Entity} type is inferred from the return type.
- * If you would like to return a different object, you can specify the {@link #entity()} property
- * in the annotation.
- * <pre>
- * public class Album {
- * int id;
- * // other fields
- * }
- * public class SongNameAndId {
- * int songId;
- * String name;
- * }
- * public class AlbumAllSongs {
- * {@literal @}Embedded
- * Album album;
- * {@literal @}Relation(parentColumn = "id", entityColumn = "albumId", entity = Song.class)
- * List<SongNameAndId> songs;
- * }
- * {@literal @}Dao
- * public interface MusicDao {
- * {@literal @}Query("SELECT * from Album")
- * List<AlbumAllSongs> loadAlbumAndSongs();
- * }
- * </pre>
- * <p>
- * In the example above, {@code SongNameAndId} is a regular POJO but all of fields are fetched
- * from the {@code entity} defined in the {@code @Relation} annotation (<i>Song</i>).
- * {@code SongNameAndId} could also define its own relations all of which would also be fetched
- * automatically.
- * <p>
- * If you would like to specify which columns are fetched from the child {@link Entity}, you can
- * use {@link #projection()} property in the {@code Relation} annotation.
- * <pre>
- * public class AlbumAndAllSongs {
- * {@literal @}Embedded
- * Album album;
- * {@literal @}Relation(
- * parentColumn = "id",
- * entityColumn = "albumId",
- * entity = Song.class,
- * projection = {"name"})
- * List<String> songNames;
- * }
- * </pre>
- * <p>
- * If the relationship is defined by an associative table (also know as junction table) then you can
- * use {@link #associateBy()} to specify it. This is useful for fetching many-to-many relations.
- * <p>
- * Note that {@code @Relation} annotation can be used only in POJO classes, an {@link Entity} class
- * cannot have relations. This is a design decision to avoid common pitfalls in {@link Entity}
- * setups. You can read more about it in the main
- * <href="https://developer.android.com/training/data-storage/room/referencing-data#understand-no-object-references">
- * Room documentation</>. When loading data, you can simply work around this limitation by creating
- * POJO classes that extend the {@link Entity}.
+ * `Relation` must be a [java.util.List] or [java.util.Set].
*
- * @see Junction
+ * By default, the [Entity] type is inferred from the return type.
+ * If you would like to return a different object, you can specify the [entity] property
+ * in the annotation.
+ *
+ * ```
+ * data class Album (
+ * val id: Int
+ * // other fields
+ * )
+ *
+ * data class SongNameAndId (
+ * val songId: Int,
+ * val name: String
+ * )
+ *
+ * data class AlbumAllSongs (
+ * @Embedded
+ * val album: Album,
+ * @Relation(parentColumn = "id", entityColumn = "albumId", entity = Song.class)
+ * val songs: List<SongNameAndId>
+ * )
+ *
+ * @Dao
+ * public interface MusicDao {
+ * @Query("SELECT * from Album")
+ * val loadAlbumAndSongs(): List<AlbumAllSongs>
+ * }
+ * ```
+ *
+ * In the example above, `SongNameAndId` is a regular POJO but all of fields are fetched
+ * from the `entity` defined in the `@Relation` annotation _Song_.
+ * `SongNameAndId` could also define its own relations all of which would also be fetched
+ * automatically.
+ *
+ * If you would like to specify which columns are fetched from the child [Entity], you can
+ * use [projection] property in the `Relation` annotation.
+ *
+ * ```
+ * data class AlbumAndAllSongs (
+ * @Embedded
+ * val album: Album,
+ * @Relation(
+ * parentColumn = "id",
+ * entityColumn = "albumId",
+ * entity = Song.class,
+ * projection = {"name"})
+ * val songNames: List<String>
+ * )
+ * ```
+ *
+ * If the relationship is defined by an associative table (also know as junction table) then you can
+ * use [associateBy] to specify it. This is useful for fetching many-to-many relations.
+ *
+ * Note that `@Relation` annotation can be used only in POJO classes, an [Entity] class
+ * cannot have relations. This is a design decision to avoid common pitfalls in [Entity]
+ * setups. You can read more about it in the main
+ * [Room documentation](https://developer.android.com/training/data-storage/room/referencing-data#understand-no-object-references).
+ * When loading data, you can simply work around this limitation by creating
+ * POJO classes that extend the [Entity].
+ *
+ * @see [Junction]
*/
-@Target({ElementType.FIELD, ElementType.METHOD})
-@Retention(RetentionPolicy.CLASS)
-public @interface Relation {
+@Target(AnnotationTarget.FIELD, AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Relation(
/**
* The entity or view to fetch the item from. You don't need to set this if the entity or view
* matches the type argument in the return type.
*
* @return The entity or view to fetch from. By default, inherited from the return type.
*/
- Class<?> entity() default Object.class;
+ val entity: KClass<*> = Any::class,
/**
* Reference column in the parent POJO.
- * <p>
+ *
* In a one-to-one or one-to-many relation, this value will be matched against the column
- * defined in {@link #entityColumn()}. In a many-to-many using {@link #associateBy()} then
- * this value will be matched against the {@link Junction#parentColumn()}
+ * defined in [entityColumn]. In a many-to-many using [associateBy] then
+ * this value will be matched against the [Junction.parentColumn]
*
* @return The column reference in the parent object.
*/
- String parentColumn();
+ val parentColumn: String,
/**
- * The column to match in the {@link #entity()}.
- * <p>
+ * The column to match in the [entity].
+ *
* In a one-to-one or one-to-many relation, this value will be matched against the column
- * defined in {@link #parentColumn()} ()}. In a many-to-many using {@link #associateBy()} then
- * this value will be matched against the {@link Junction#entityColumn()}
+ * defined in [parentColumn]. In a many-to-many using [associateBy] then
+ * this value will be matched against the [Junction.entityColumn].
*/
- String entityColumn();
+ val entityColumn: String,
/**
* The entity or view to be used as a associative table (also known as a junction table) when
@@ -148,14 +151,14 @@
*
* @see Junction
*/
- Junction associateBy() default @Junction(Object.class);
+ val associateBy: Junction = Junction(Any::class),
/**
* If sub columns should be fetched from the entity, you can specify them using this field.
- * <p>
+ *
* By default, inferred from the the return type.
*
- * @return The list of columns to be selected from the {@link #entity()}.
+ * @return The list of columns to be selected from the [entity].
*/
- String[] projection() default {};
-}
+ val projection: Array<String> = []
+)
diff --git a/room/room-common/src/main/java/androidx/room/RenameColumn.kt b/room/room-common/src/main/java/androidx/room/RenameColumn.kt
index 9d07032..f52f790 100644
--- a/room/room-common/src/main/java/androidx/room/RenameColumn.kt
+++ b/room/room-common/src/main/java/androidx/room/RenameColumn.kt
@@ -14,54 +14,47 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
- * Repeatable annotation declaring the renamed columns in the {@link AutoMigration#to} version of
+ * Repeatable annotation declaring the renamed columns in the [AutoMigration.to] version of
* an auto migration.
*
* @see AutoMigration
*/
-@Repeatable(RenameColumn.Entries.class)
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface RenameColumn {
+@JvmRepeatable(RenameColumn.Entries::class)
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class RenameColumn(
/**
- * Name of the table in the {@link AutoMigration#from} version of the database the renamed
- * column is found in. The name in {@link AutoMigration#from} version is used in case the table
- * was renamed in the {@link AutoMigration#to} version.
+ * Name of the table in the [AutoMigration.from] version of the database the renamed
+ * column is found in. The name in [AutoMigration.from] version is used in case the table
+ * was renamed in the [AutoMigration.to] version.
*
* @return Name of the table
*/
- String tableName();
+ val tableName: String,
/**
- * Name of the column in the {@link AutoMigration#from} version of the database.
+ * Name of the column in the [AutoMigration.from] version of the database.
*
* @return Name of the column.
*/
- String fromColumnName();
+ val fromColumnName: String,
/**
- * Name of the column in the {@link AutoMigration#to} version of the database.
+ * Name of the column in the [AutoMigration.to] version of the database.
*
* @return Name of the column.
*/
- String toColumnName();
-
+ val toColumnName: String,
+) {
/**
- * Container annotation for the repeatable annotation {@link RenameColumn}.
+ * Container annotation for the repeatable annotation [RenameColumn].
*/
- @Target(ElementType.TYPE)
- @Retention(RetentionPolicy.CLASS)
- @interface Entries {
- RenameColumn[] value();
- }
+ @Target(AnnotationTarget.CLASS)
+ @Retention(AnnotationRetention.BINARY)
+ public annotation class Entries(
+ vararg val value: RenameColumn
+ )
}
-
diff --git a/room/room-common/src/main/java/androidx/room/RenameTable.kt b/room/room-common/src/main/java/androidx/room/RenameTable.kt
index b9c9aef..2783e86 100644
--- a/room/room-common/src/main/java/androidx/room/RenameTable.kt
+++ b/room/room-common/src/main/java/androidx/room/RenameTable.kt
@@ -14,45 +14,38 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Repeatable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
+package androidx.room
/**
* Repeatable annotation declaring the renamed tables in the new version of an auto migration.
*
- * @see AutoMigration
+ * @see [AutoMigration]
*
*/
-@Repeatable(RenameTable.Entries.class)
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface RenameTable {
+@JvmRepeatable(RenameTable.Entries::class)
+@Target(AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class RenameTable(
/**
- * Name of the table in the {@link AutoMigration#from} version of the database.
+ * Name of the table in the [AutoMigration.from] version of the database.
*
* @return Name of the table to rename from.
*/
- String fromTableName();
+ val fromTableName: String,
/**
- * Name of the table in the {@link AutoMigration#to} version of the database.
+ * Name of the table in the [AutoMigration.to] version of the database.
*
* @return Name of the table to rename to.
*/
- String toTableName();
-
+ val toTableName: String,
+) {
/**
- * Container annotation for the repeatable annotation {@link RenameTable}.
+ * Container annotation for the repeatable annotation [RenameTable].
*/
- @Target(ElementType.TYPE)
- @Retention(RetentionPolicy.CLASS)
- @interface Entries {
- RenameTable[] value();
- }
+ @Target(AnnotationTarget.CLASS)
+ @Retention(AnnotationRetention.BINARY)
+ public annotation class Entries(
+ vararg val value: RenameTable
+ )
}
diff --git a/room/room-common/src/main/java/androidx/room/RewriteQueriesToDropUnusedColumns.kt b/room/room-common/src/main/java/androidx/room/RewriteQueriesToDropUnusedColumns.kt
index b6a7f63..27a65fe 100644
--- a/room/room-common/src/main/java/androidx/room/RewriteQueriesToDropUnusedColumns.kt
+++ b/room/room-common/src/main/java/androidx/room/RewriteQueriesToDropUnusedColumns.kt
@@ -14,60 +14,57 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
- * When present, {@link RewriteQueriesToDropUnusedColumns} annotation will cause Room to
- * rewrite your {@link Query} methods such that only the columns that are used in the response are
+ * When present, [RewriteQueriesToDropUnusedColumns] annotation will cause Room to
+ * rewrite your [Query] methods such that only the columns that are used in the response are
* queried from the database.
- * <p>
+ *
* This annotation is useful if you don't need all columns returned in a query but also don't
* want to spell out their names in the query projection.
- * <p>
- * For example, if you have a {@code User} class with 10 fields and want to return only
- * the {@code name} and {@code lastName} fields in a POJO, you could write the query like this:
*
- * <pre>
- * {@literal @}Dao
+ * For example, if you have a `User` class with 10 fields and want to return only
+ * the `name` and `lastName` fields in a POJO, you could write the query like this:
+ *
+ * ```
+ * @Dao
* interface MyDao {
- * {@literal @Query("SELECT * FROM User")}
- * {@literal public List<NameAndLastName> getAll();}
+ * @Query("SELECT * FROM User")
+ * public fun getAll(): List<NameAndLastName>
* }
- * class NameAndLastName {
- * public String name;
- * public String lastName;
- * }
- * </pre>
- * <p>
- * Normally, Room would print a {@link RoomWarnings#CURSOR_MISMATCH} warning since the query result
+ *
+ * data class NameAndLastName (
+ * val name: String,
+ * val lastName: String
+ * )
+ * ```
+ *
+ * Normally, Room would print a [RoomWarnings.CURSOR_MISMATCH] warning since the query result
* has additional columns that are not used in the response. You can annotate the method with
- * {@link RewriteQueriesToDropUnusedColumns} to inform Room to rewrite your query at compile time to
+ * [RewriteQueriesToDropUnusedColumns] to inform Room to rewrite your query at compile time to
* avoid fetching extra columns.
- * <pre>
- * {@literal @}Dao
+ *
+ * ```
+ * @Dao
* interface MyDao {
- * {@literal @RewriteQueriesToDropUnusedColumns}
- * {@literal @Query("SELECT * FROM User")}
- * {@literal public List<NameAndLastName> getAll();}
+ * @RewriteQueriesToDropUnusedColumns
+ * @Query("SELECT * FROM User")
+ * fun getAll(): List<NameAndLastName>
* }
- * </pre>
- * At compile time, Room will convert this query to {@code SELECT name, lastName FROM (SELECT *
- * FROM User)} which gets flattened by <b>Sqlite</b> to {@code SELECT name, lastName FROM User}.
- * <p>
- * When the annotation is used on a {@link Dao} method annotated with {@link Query}, it will only
- * affect that query. You can put the annotation on the {@link Dao} annotated class/interface or
- * the {@link Database} annotated class where it will impact all methods in the dao / database
+ * ```
+ *
+ * At compile time, Room will convert this query to `SELECT name, lastName FROM (SELECT *
+ * FROM User)` which gets flattened by **Sqlite** to `SELECT name, lastName FROM User`.
+ *
+ * When the annotation is used on a [Dao] method annotated with [Query], it will only
+ * affect that query. You can put the annotation on the [Dao] annotated class/interface or
+ * the [Database] annotated class where it will impact all methods in the dao / database
* respectively.
- * <p>
+ *
* Note that Room will not rewrite the query if it has multiple columns that have the same name as
* it does not yet have a way to distinguish which one is necessary.
*/
-@Target({ElementType.METHOD, ElementType.TYPE})
-@Retention(RetentionPolicy.CLASS)
-public @interface RewriteQueriesToDropUnusedColumns {
-}
+@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class RewriteQueriesToDropUnusedColumns
diff --git a/room/room-common/src/main/java/androidx/room/RoomMasterTable.kt b/room/room-common/src/main/java/androidx/room/RoomMasterTable.kt
index 9b1fffb..0cdd520 100644
--- a/room/room-common/src/main/java/androidx/room/RoomMasterTable.kt
+++ b/room/room-common/src/main/java/androidx/room/RoomMasterTable.kt
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+@file:JvmName("RoomMasterTable")
-package androidx.room;
+package androidx.room
-import androidx.annotation.RestrictTo;
+import androidx.annotation.RestrictTo
/**
* Schema information about Room's master table.
@@ -25,34 +26,30 @@
*/
@SuppressWarnings("WeakerAccess")
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
-public class RoomMasterTable {
+public object RoomMasterTable {
/**
* The master table where room keeps its metadata information.
*/
- public static final String TABLE_NAME = "room_master_table";
+ public const val TABLE_NAME: String = "room_master_table"
+
// must match the runtime property Room#MASTER_TABLE_NAME
- public static final String NAME = "room_master_table";
- private static final String COLUMN_ID = "id";
- private static final String COLUMN_IDENTITY_HASH = "identity_hash";
- public static final String DEFAULT_ID = "42";
+ public const val NAME: String = "room_master_table"
+ private const val COLUMN_ID: String = "id"
+ private const val COLUMN_IDENTITY_HASH: String = "identity_hash"
+ public const val DEFAULT_ID: String = "42"
- public static final String CREATE_QUERY = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " ("
- + COLUMN_ID + " INTEGER PRIMARY KEY,"
- + COLUMN_IDENTITY_HASH + " TEXT)";
+ public const val CREATE_QUERY: String = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME +
+ " (" + COLUMN_ID + " INTEGER PRIMARY KEY," + COLUMN_IDENTITY_HASH + " TEXT)"
- public static final String READ_QUERY = "SELECT " + COLUMN_IDENTITY_HASH
- + " FROM " + TABLE_NAME + " WHERE "
- + COLUMN_ID + " = " + DEFAULT_ID + " LIMIT 1";
+ public const val READ_QUERY: String = "SELECT " + COLUMN_IDENTITY_HASH + " FROM " +
+ TABLE_NAME + " WHERE " + COLUMN_ID + " = " + DEFAULT_ID + " LIMIT 1"
/**
* We don't escape here since we know what we are passing.
*/
- public static String createInsertQuery(String hash) {
- return "INSERT OR REPLACE INTO " + TABLE_NAME + " ("
- + COLUMN_ID + "," + COLUMN_IDENTITY_HASH + ")"
- + " VALUES(" + DEFAULT_ID + ", '" + hash + "')";
- }
-
- private RoomMasterTable() {
+ @JvmStatic
+ public fun createInsertQuery(hash: String): String {
+ return "INSERT OR REPLACE INTO " + TABLE_NAME + " (" + COLUMN_ID + "," +
+ COLUMN_IDENTITY_HASH + ")" + " VALUES(" + DEFAULT_ID + ", '" + hash + "')"
}
}
diff --git a/room/room-common/src/main/java/androidx/room/RoomWarnings.kt b/room/room-common/src/main/java/androidx/room/RoomWarnings.kt
index df8868b..c529915 100644
--- a/room/room-common/src/main/java/androidx/room/RoomWarnings.kt
+++ b/room/room-common/src/main/java/androidx/room/RoomWarnings.kt
@@ -13,188 +13,190 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-package androidx.room;
+package androidx.room
/**
* The list of warnings that are produced by Room.
- * <p>
- * You can use these values inside a {@link SuppressWarnings} annotation to disable the warnings.
+ *
+ * You can use these values inside a [SuppressWarnings] annotation to disable the warnings.
*/
// If you change this, don't forget to change androidx.room.vo.Warning
-@SuppressWarnings({"unused", "WeakerAccess"})
-public class RoomWarnings {
- /**
- * The warning dispatched by Room when the return value of a {@link Query} method does not
- * exactly match the fields in the query result.
- */
- public static final String CURSOR_MISMATCH = "ROOM_CURSOR_MISMATCH";
+@SuppressWarnings("unused", "WeakerAccess")
+public open class RoomWarnings {
+ public companion object {
+ /**
+ * The warning dispatched by Room when the return value of a [Query] method does not
+ * exactly match the fields in the query result.
+ */
+ public const val CURSOR_MISMATCH: String = "ROOM_CURSOR_MISMATCH"
- /**
- * The warning dispatched by Room when the object in the provided method's multimap return
- * type does not implement equals() and hashCode().
- */
- public static final String DOES_NOT_IMPLEMENT_EQUALS_HASHCODE =
- "ROOM_TYPE_DOES_NOT_IMPLEMENT_EQUALS_HASHCODE";
+ /**
+ * The warning dispatched by Room when the object in the provided method's multimap return
+ * type does not implement equals() and hashCode().
+ */
+ public const val DOES_NOT_IMPLEMENT_EQUALS_HASHCODE: String =
+ "ROOM_TYPE_DOES_NOT_IMPLEMENT_EQUALS_HASHCODE"
- /**
- * Reported when Room cannot verify database queries during compilation due to lack of
- * tmp dir access in JVM.
- */
- public static final String MISSING_JAVA_TMP_DIR = "ROOM_MISSING_JAVA_TMP_DIR";
+ /**
+ * Reported when Room cannot verify database queries during compilation due to lack of
+ * tmp dir access in JVM.
+ */
+ public const val MISSING_JAVA_TMP_DIR: String = "ROOM_MISSING_JAVA_TMP_DIR"
- /**
- * Reported when Room cannot verify database queries during compilation. This usually happens
- * when it cannot find the SQLite JDBC driver on the host machine.
- * <p>
- * Room can function without query verification but its functionality will be limited.
- */
- public static final String CANNOT_CREATE_VERIFICATION_DATABASE =
- "ROOM_CANNOT_CREATE_VERIFICATION_DATABASE";
+ /**
+ * Reported when Room cannot verify database queries during compilation. This usually
+ * happens when it cannot find the SQLite JDBC driver on the host machine.
+ *
+ * Room can function without query verification but its functionality will be limited.
+ */
+ public const val CANNOT_CREATE_VERIFICATION_DATABASE: String =
+ "ROOM_CANNOT_CREATE_VERIFICATION_DATABASE"
- /**
- * Reported when an {@link Entity} field that is annotated with {@link Embedded} has a
- * sub field which is annotated with {@link PrimaryKey} but the {@link PrimaryKey} is dropped
- * while composing it into the parent object.
- */
- public static final String PRIMARY_KEY_FROM_EMBEDDED_IS_DROPPED =
- "ROOM_EMBEDDED_PRIMARY_KEY_IS_DROPPED";
+ /**
+ * Reported when an [Entity] field that is annotated with [Embedded] has a
+ * sub field which is annotated with [PrimaryKey] but the [PrimaryKey] is dropped
+ * while composing it into the parent object.
+ */
+ public const val PRIMARY_KEY_FROM_EMBEDDED_IS_DROPPED: String =
+ "ROOM_EMBEDDED_PRIMARY_KEY_IS_DROPPED"
- /**
- * Reported when an {@link Entity} field that is annotated with {@link Embedded} has a
- * sub field which has a {@link ColumnInfo} annotation with {@code index = true}.
- * <p>
- * You can re-define the index in the containing {@link Entity}.
- */
- public static final String INDEX_FROM_EMBEDDED_FIELD_IS_DROPPED =
- "ROOM_EMBEDDED_INDEX_IS_DROPPED";
+ /**
+ * Reported when an [Entity] field that is annotated with [Embedded] has a
+ * sub field which has a [ColumnInfo] annotation with `index = true`.
+ *
+ * You can re-define the index in the containing [Entity].
+ */
+ public const val INDEX_FROM_EMBEDDED_FIELD_IS_DROPPED: String =
+ "ROOM_EMBEDDED_INDEX_IS_DROPPED"
- /**
- * Reported when an {@link Entity} that has a {@link Embedded}d field whose type is another
- * {@link Entity} and that {@link Entity} has some indices defined.
- * These indices will NOT be created in the containing {@link Entity}. If you want to preserve
- * them, you can re-define them in the containing {@link Entity}.
- */
- public static final String INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED =
- "ROOM_EMBEDDED_ENTITY_INDEX_IS_DROPPED";
+ /**
+ * Reported when an [Entity] that has a [Embedded] field whose type is another
+ * [Entity] and that [Entity] has some indices defined.
+ * These indices will NOT be created in the containing [Entity]. If you want to preserve
+ * them, you can re-define them in the containing [Entity].
+ */
+ public const val INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED: String =
+ "ROOM_EMBEDDED_ENTITY_INDEX_IS_DROPPED"
- /**
- * Reported when an {@link Entity}'s parent declares an {@link Index}. Room does not
- * automatically inherit these indices to avoid hidden costs or unexpected constraints.
- * <p>
- * If you want your child class to have the indices of the parent, you must re-declare
- * them in the child class. Alternatively, you can set {@link Entity#inheritSuperIndices()}
- * to {@code true}.
- */
- public static final String INDEX_FROM_PARENT_IS_DROPPED =
- "ROOM_PARENT_INDEX_IS_DROPPED";
+ /**
+ * Reported when an [Entity]'s parent declares an [Index]. Room does not
+ * automatically inherit these indices to avoid hidden costs or unexpected constraints.
+ *
+ * If you want your child class to have the indices of the parent, you must re-declare
+ * them in the child class. Alternatively, you can set [Entity.inheritSuperIndices]
+ * to `true`.
+ */
+ public const val INDEX_FROM_PARENT_IS_DROPPED: String =
+ "ROOM_PARENT_INDEX_IS_DROPPED"
- /**
- * Reported when an {@link Entity} inherits a field from its super class and the field has a
- * {@link ColumnInfo} annotation with {@code index = true}.
- * <p>
- * These indices are dropped for the {@link Entity} and you would need to re-declare them if
- * you want to keep them. Alternatively, you can set {@link Entity#inheritSuperIndices()}
- * to {@code true}.
- */
- public static final String INDEX_FROM_PARENT_FIELD_IS_DROPPED =
- "ROOM_PARENT_FIELD_INDEX_IS_DROPPED";
+ /**
+ * Reported when an [Entity] inherits a field from its super class and the field has a
+ * [ColumnInfo] annotation with `index = true`.
+ *
+ * These indices are dropped for the [Entity] and you would need to re-declare them if
+ * you want to keep them. Alternatively, you can set [Entity.inheritSuperIndices]
+ * to `true`.
+ */
+ public const val INDEX_FROM_PARENT_FIELD_IS_DROPPED: String =
+ "ROOM_PARENT_FIELD_INDEX_IS_DROPPED"
- /**
- * Reported when a {@link Relation} {@link Entity}'s SQLite column type does not match the type
- * in the parent. Room will still do the matching using {@code String} representations.
- */
- public static final String RELATION_TYPE_MISMATCH = "ROOM_RELATION_TYPE_MISMATCH";
+ /**
+ * Reported when a [Relation] [Entity]'s SQLite column type does not match the type
+ * in the parent. Room will still do the matching using `String` representations.
+ */
+ public const val RELATION_TYPE_MISMATCH: String = "ROOM_RELATION_TYPE_MISMATCH"
- /**
- * Reported when a `room.schemaLocation` argument is not provided into the annotation processor.
- * You can either set {@link Database#exportSchema()} to {@code false} or provide
- * `room.schemaLocation` to the annotation processor. You are strongly adviced to provide it
- * and also commit them into your version control system.
- */
- public static final String MISSING_SCHEMA_LOCATION = "ROOM_MISSING_SCHEMA_LOCATION";
+ /**
+ * Reported when a `room.schemaLocation` argument is not provided into the annotation
+ * processor.
+ * You can either set [Database.exportSchema] to `false` or provide
+ * `room.schemaLocation` to the annotation processor. You are strongly advised to provide it
+ * and also commit them into your version control system.
+ */
+ public const val MISSING_SCHEMA_LOCATION: String = "ROOM_MISSING_SCHEMA_LOCATION"
- /**
- * When there is a foreign key from Entity A to Entity B, it is a good idea to index the
- * reference columns in B, otherwise, each modification on Entity A will trigger a full table
- * scan on Entity B.
- * <p>
- * If Room cannot find a proper index in the child entity (Entity B in this case), Room will
- * print this warning.
- */
- public static final String MISSING_INDEX_ON_FOREIGN_KEY_CHILD =
- "ROOM_MISSING_FOREIGN_KEY_CHILD_INDEX";
+ /**
+ * When there is a foreign key from Entity A to Entity B, it is a good idea to index the
+ * reference columns in B, otherwise, each modification on Entity A will trigger a full table
+ * scan on Entity B.
+ *
+ * If Room cannot find a proper index in the child entity (Entity B in this case), Room will
+ * print this warning.
+ */
+ public const val MISSING_INDEX_ON_FOREIGN_KEY_CHILD: String =
+ "ROOM_MISSING_FOREIGN_KEY_CHILD_INDEX"
- /**
- * Reported when a junction entity whose column is used in a `@Relation` field with a
- * `@Junction` does not contain an index. If the column is not covered by any index then a
- * full table scan might be performed when resolving the relationship.
- * <p>
- * It is recommended that columns on entities used as junctions contain indices, otherwise Room
- * will print this warning.
- */
- public static final String MISSING_INDEX_ON_JUNCTION = "MISSING_INDEX_ON_JUNCTION";
+ /**
+ * Reported when a junction entity whose column is used in a `@Relation` field with a
+ * `@Junction` does not contain an index. If the column is not covered by any index then a
+ * full table scan might be performed when resolving the relationship.
+ *
+ * It is recommended that columns on entities used as junctions contain indices, otherwise Room
+ * will print this warning.
+ */
+ public const val MISSING_INDEX_ON_JUNCTION: String = "MISSING_INDEX_ON_JUNCTION"
- /**
- * Reported when a POJO has multiple constructors, one of which is a no-arg constructor. Room
- * will pick that one by default but will print this warning in case the constructor choice is
- * important. You can always guide Room to use the right constructor using the @Ignore
- * annotation.
- */
- public static final String DEFAULT_CONSTRUCTOR = "ROOM_DEFAULT_CONSTRUCTOR";
+ /**
+ * Reported when a POJO has multiple constructors, one of which is a no-arg constructor. Room
+ * will pick that one by default but will print this warning in case the constructor choice is
+ * important. You can always guide Room to use the right constructor using the @Ignore
+ * annotation.
+ */
+ public const val DEFAULT_CONSTRUCTOR: String = "ROOM_DEFAULT_CONSTRUCTOR"
- /**
- * Reported when a @Query method returns a POJO that has relations but the method is not
- * annotated with @Transaction. Relations are run as separate queries and if the query is not
- * run inside a transaction, it might return inconsistent results from the database.
- */
- public static final String RELATION_QUERY_WITHOUT_TRANSACTION =
- "ROOM_RELATION_QUERY_WITHOUT_TRANSACTION";
+ /**
+ * Reported when a @Query method returns a POJO that has relations but the method is not
+ * annotated with @Transaction. Relations are run as separate queries and if the query is not
+ * run inside a transaction, it might return inconsistent results from the database.
+ */
+ public const val RELATION_QUERY_WITHOUT_TRANSACTION: String =
+ "ROOM_RELATION_QUERY_WITHOUT_TRANSACTION"
- /**
- * Reported when an `@Entity` field's type do not exactly match the getter type.
- * For instance, in the following class:
- * <pre>
- * {@code @}Entity
- * class Foo {
- * ...
- * private Boolean value;
- * public boolean getValue() {
- * return value == null ? false : value;
- * }
- * }
- * </pre>
- *
- * Trying to insert this entity into database will always set {@code value} column to
- * {@code false} when {@code Foo.value} is {@code null} since Room will use the {@code getValue}
- * method to read the value. So even thought the database column is nullable, it will never
- * be inserted as {@code null} if inserted as a {@code Foo} instance.
- */
- public static final String MISMATCHED_GETTER = "ROOM_MISMATCHED_GETTER_TYPE";
+ /**
+ * Reported when an `@Entity` field's type do not exactly match the getter type.
+ * For instance, in the following class:
+ *
+ * ```
+ * @Entity
+ * class Foo {
+ * ...
+ * private val value: Boolean
+ * public fun getValue(): Boolean {
+ * return value == null ? false : value
+ * }
+ * }
+ * ```
+ *
+ * Trying to insert this entity into database will always set `value` column to
+ * `false` when `Foo.value` is `null` since Room will use the `getValue`
+ * method to read the value. So even thought the database column is nullable, it will never
+ * be inserted as `null` if inserted as a `Foo` instance.
+ */
+ public const val MISMATCHED_GETTER: String = "ROOM_MISMATCHED_GETTER_TYPE"
- /**
- * Reported when an `@Entity` field's type do not exactly match the setter type.
- * For instance, in the following class:
- * <pre>
- * {@code @}Entity
- * class Foo {
- * ...
- * private Boolean value;
- * public void setValue(boolean value) {
- * this.value = value;
- * }
- * }
- * </pre>
- *
- * If Room reads this entity from the database, it will always set {@code Foo.value} to
- * {@code false} when the column value is {@code null} since Room will use the {@code setValue}
- * method to write the value.
- */
- public static final String MISMATCHED_SETTER = "ROOM_MISMATCHED_SETTER_TYPE";
-
- /** @deprecated This type should not be instantiated as it contains only static methods. */
- @Deprecated
- @SuppressWarnings("PrivateConstructorForUtilityClass")
- public RoomWarnings() {
+ /**
+ * Reported when an `@Entity` field's type do not exactly match the setter type.
+ * For instance, in the following class:
+ *
+ * ```
+ * @Entity
+ * class Foo {
+ * ...
+ * private val value: Boolean
+ * public fun setValue(value: Boolean) {
+ * this.value = value
+ * }
+ * }
+ * ```
+ *
+ * If Room reads this entity from the database, it will always set `Foo.value` to
+ * `false` when the column value is `null` since Room will use the `setValue`
+ * method to write the value.
+ */
+ public const val MISMATCHED_SETTER: String = "ROOM_MISMATCHED_SETTER_TYPE"
}
+
+ @Deprecated("This type should not be instantiated as it contains only static methods. ")
+ @SuppressWarnings("PrivateConstructorForUtilityClass")
+ public constructor()
}
diff --git a/room/room-common/src/main/java/androidx/room/SkipQueryVerification.kt b/room/room-common/src/main/java/androidx/room/SkipQueryVerification.kt
index ae6aabe..2cda275 100644
--- a/room/room-common/src/main/java/androidx/room/SkipQueryVerification.kt
+++ b/room/room-common/src/main/java/androidx/room/SkipQueryVerification.kt
@@ -14,32 +14,26 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
* Skips database verification for the annotated element.
- * <p>
- * If it is a class annotated with {@link Database}, none of the queries for the database will
+ *
+ * If it is a class annotated with [Database], none of the queries for the database will
* be verified at compile time.
- * <p>
- * If it is a class annotated with {@link Dao}, none of the queries in the Dao class will
+ *
+ * If it is a class annotated with [Dao], none of the queries in the Dao class will
* be verified at compile time.
- * <p>
+ *
* If it is a method in a Dao class, just the method's sql verification will be skipped.
- * <p>
- * If it is a class annotated with {@link DatabaseView}, the SELECT SQL for creating the view will
+ *
+ * If it is a class annotated with [DatabaseView], the SELECT SQL for creating the view will
* not be verified at compile time.
- * <p>
+ *
* You should use this as the last resort if Room cannot properly understand your query and you are
* 100% sure it works. Removing validation may limit the functionality of Room since it won't be
* able to understand the query response.
*/
-@Target({ElementType.METHOD, ElementType.TYPE})
-@Retention(RetentionPolicy.CLASS)
-public @interface SkipQueryVerification {
-}
+@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
+@Retention(AnnotationRetention.BINARY)
+public annotation class SkipQueryVerification
diff --git a/room/room-common/src/main/java/androidx/room/Transaction.kt b/room/room-common/src/main/java/androidx/room/Transaction.kt
index a8eaafc..1a5906d 100644
--- a/room/room-common/src/main/java/androidx/room/Transaction.kt
+++ b/room/room-common/src/main/java/androidx/room/Transaction.kt
@@ -14,75 +14,73 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
- * Marks a method in a {@link Dao} class as a transaction method.
- * <p>
- * When used on a non-abstract method of an abstract {@link Dao} class,
+ * Marks a method in a [Dao] class as a transaction method.
+ *
+ * When used on a non-abstract method of an abstract [Dao] class,
* the derived implementation of the method will execute the super method in a database transaction.
* All the parameters and return types are preserved. The transaction will be marked as successful
* unless an exception is thrown in the method body.
- * <p>
- * Example:
- * <pre>
- * {@literal @}Dao
- * public abstract class SongDao {
- * {@literal @}Insert
- * public abstract void insert(Song song);
- * {@literal @}Delete
- * public abstract void delete(Song song);
- * {@literal @}Transaction
- * public void insertAndDeleteInTransaction(Song newSong, Song oldSong) {
- * // Anything inside this method runs in a single transaction.
- * insert(newSong);
- * delete(oldSong);
- * }
- * }
- * </pre>
- * <p>
- * When used on a {@link Query} method that has a {@code SELECT} statement, the generated code for
- * the Query will be run in a transaction. There are 2 main cases where you may want to do that:
- * <ol>
- * <li>If the result of the query is fairly big, it is better to run it inside a transaction
- * to receive a consistent result. Otherwise, if the query result does not fit into a single
- * {@link android.database.CursorWindow CursorWindow}, the query result may be corrupted due to
- * changes in the database in between cursor window swaps.
- * <li>If the result of the query is a POJO with {@link Relation} fields, these fields are
- * queried separately. To receive consistent results between these queries, you also want
- * to run them in a single transaction.
- * </ol>
- * Example:
- * <pre>
- * class AlbumWithSongs extends Album {
- * {@literal @}Relation(parentColumn = "albumId", entityColumn = "songId")
- * public List<Song> songs;
- * }
*
- * {@literal @}Dao
- * public interface AlbumDao {
- * {@literal @}Transaction {@literal @}Query("SELECT * FROM album")
- * public List<AlbumWithSongs> loadAll();
+ * Example:
+ *
+ * ```
+ * @Dao
+ * abstract class SongDao {
+ * @Insert
+ * abstract fun insert(song: Song)
+ * @Delete
+ * abstract fun delete(song: Song)
+ * @Transaction
+ * fun insertAndDeleteInTransaction(newSong: Song, oldSong: Song) {
+ * // Anything inside this method runs in a single transaction.
+ * insert(newSong)
+ * delete(oldSong)
+ * }
* }
- * </pre>
- * If the query is asynchronous (e.g. returns a {@link androidx.lifecycle.LiveData LiveData}
- * or RxJava {@code Flowable}), the transaction is properly handled when the query is run, not when
+ * ```
+ *
+ * When used on a [Query] method that has a `SELECT` statement, the generated code for
+ * the [Query] will be run in a transaction. There are 2 main cases where you may want to do that:
+ *
+ * * If the result of the query is fairly big, it is better to run it inside a transaction
+ * to receive a consistent result. Otherwise, if the query result does not fit into a single
+ * [android.database.CursorWindow], the query result may be corrupted due to changes in the database
+ * in between cursor window swaps.
+ *
+ * * If the result of the query is a POJO with {@link Relation} fields, these fields are
+ * queried separately. To receive consistent results between these queries, you also want
+ * to run them in a single transaction.
+ *
+ * Example:
+ *
+ * ```
+ * data class AlbumWithSongs : Album (
+ * @Relation(parentColumn = "albumId", entityColumn = "songId")
+ * val songs: List<Song>
+ * )
+ *
+ * @Dao
+ * public interface AlbumDao {
+ * @Transaction
+ * @Query("SELECT * FROM album")
+ * fun loadAll(): List<AlbumWithSongs>
+ * }
+ * ```
+ *
+ * If the query is asynchronous (e.g. returns a [androidx.lifecycle.LiveData]
+ * or RxJava [Flowable]), the transaction is properly handled when the query is run, not when
* the method is called.
- * <p>
- * Putting this annotation on an {@link Insert}, {@link Update} or {@link Delete} method has no
+ *
+ * Putting this annotation on an [Insert], [Update] or [Delete] method has no
* impact because those methods are always run inside a transaction. Similarly, if a method is
- * annotated with {@link Query} but runs an INSERT, UPDATE or DELETE statement, it is automatically
- * wrapped in a transaction and this annotation has no effect.
- * <p>
- * Room will only perform at most one transaction at a time, additional transactions are queued
+ * annotated with [Query] but runs an INSERT, UPDATE or DELETE statement, it is automatically
+ * wrapped in a transaction and this annotation has no effect. Room will only perform at most one
+ * transaction at a time, additional transactions are queued
* and executed on a first come, first serve order.
*/
-@Target({ElementType.METHOD})
-@Retention(RetentionPolicy.CLASS)
-public @interface Transaction {
-}
+@Target(AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Transaction
diff --git a/room/room-common/src/main/java/androidx/room/TypeConverter.kt b/room/room-common/src/main/java/androidx/room/TypeConverter.kt
index 4238fbaef..24a0797 100644
--- a/room/room-common/src/main/java/androidx/room/TypeConverter.kt
+++ b/room/room-common/src/main/java/androidx/room/TypeConverter.kt
@@ -14,38 +14,34 @@
* limitations under the License.
*/
-package androidx.room;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+package androidx.room
/**
* Marks a method as a type converter. A class can have as many @TypeConverter methods as it needs.
- * <p>
- * Each converter method should receive 1 parameter and have non-void return type.
- * <pre>
- * // example converter for java.util.Date
- * public static class Converters {
- * {@literal @}TypeConverter
- * public Date fromTimestamp(Long value) {
- * return value == null ? null : new Date(value);
- * }
*
- * {@literal @}TypeConverter
- * public Long dateToTimestamp(Date date) {
- * if (date == null) {
- * return null;
- * } else {
- * return date.getTime();
+ * Each converter method should receive 1 parameter and have non-void return type.
+ *
+ * ```
+ * // example converter for java.util.Date
+ * public class Converters {
+ * @TypeConverter
+ * public fun fromTimestamp(value: Long): Date {
+ * return value == null ? null : Date(value)
* }
- * }
- *}
- * </pre>
- * @see TypeConverters
+ *
+ * @TypeConverter
+ * public fun dateToTimestamp(date: Date): Long {
+ * if (date == null) {
+ * return null
+ * } else {
+ * return date.getTime()
+ * }
+ * }
+ * }
+ * ```
+ *
+ * @see [TypeConverters]
*/
-@Target({ElementType.METHOD})
-@Retention(RetentionPolicy.CLASS)
-public @interface TypeConverter {
-}
+@Target(AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class TypeConverter
diff --git a/room/room-common/src/main/java/androidx/room/TypeConverters.kt b/room/room-common/src/main/java/androidx/room/TypeConverters.kt
index 04ea7c7..3bd2fbf 100644
--- a/room/room-common/src/main/java/androidx/room/TypeConverters.kt
+++ b/room/room-common/src/main/java/androidx/room/TypeConverters.kt
@@ -14,48 +14,48 @@
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import kotlin.reflect.KClass
/**
* Specifies additional type converters that Room can use. The TypeConverter is added to the scope
* of the element so if you put it on a class / interface, all methods / fields in that class will
* be able to use the converters.
*
- * <p>
* TypeConverters can only be used to convert columns / fields, hence cannot be used by a method
* with a row return value such as DAO methods that query rows.
*
- * <ul>
- * <li>If you put it on a {@link Database}, all Daos and Entities in that database will be able to
+ * * If you put it on a [Database], all Daos and Entities in that database will be able to
* use it.
- * <li>If you put it on a {@link Dao}, all methods in the Dao will be able to use it.
- * <li>If you put it on an {@link Entity}, all fields of the Entity will be able to use it.
- * <li>If you put it on a POJO, all fields of the POJO will be able to use it.
- * <li>If you put it on an {@link Entity} field, only that field will be able to use it.
- * <li>If you put it on a {@link Dao} method, all parameters of the method will be able to use it.
- * <li>If you put it on a {@link Dao} method parameter, just that field will be able to use it.
- * </ul>
- * @see TypeConverter
+ * * If you put it on a [Dao], all methods in the Dao will be able to use it.
+ * * If you put it on an [Entity], all fields of the Entity will be able to use it.
+ * * If you put it on a POJO, all fields of the POJO will be able to use it.
+ * * If you put it on an [Entity] field, only that field will be able to use it.
+ * * If you put it on a [Dao] method, all parameters of the method will be able to use it.
+ * * If you put it on a [Dao] method parameter, just that field will be able to use it.
+ *
+ * @see [TypeConverter]
*/
-@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE, ElementType.FIELD})
-@Retention(RetentionPolicy.CLASS)
-public @interface TypeConverters {
+@Target(
+ AnnotationTarget.FUNCTION,
+ AnnotationTarget.VALUE_PARAMETER,
+ AnnotationTarget.FIELD,
+ AnnotationTarget.CLASS
+)
+@Retention(AnnotationRetention.BINARY)
+public annotation class TypeConverters(
/**
* The list of type converter classes. If converter methods are not static, Room will create
* an instance of these classes.
*
* @return The list of classes that contains the converter methods.
*/
- Class<?>[] value() default {};
+ vararg val value: KClass<*> = [],
/**
* Configure whether Room can use various built in converters for common types.
- * See {@link BuiltInTypeConverters} for details.
+ * See [BuiltInTypeConverters] for details.
*/
- BuiltInTypeConverters builtInTypeConverters() default @BuiltInTypeConverters;
-}
+ val builtInTypeConverters: BuiltInTypeConverters = BuiltInTypeConverters()
+)
diff --git a/room/room-common/src/main/java/androidx/room/Update.kt b/room/room-common/src/main/java/androidx/room/Update.kt
index 3046d7b..b60a2ab 100644
--- a/room/room-common/src/main/java/androidx/room/Update.kt
+++ b/room/room-common/src/main/java/androidx/room/Update.kt
@@ -13,95 +13,98 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package androidx.room;
+package androidx.room
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
+import kotlin.reflect.KClass
/**
- * Marks a method in a {@link Dao} annotated class as an update method.
- * <p>
+ * Marks a method in a [Dao] annotated class as an update method.
+ *
* The implementation of the method will update its parameters in the database if they already
* exists (checked by primary keys). If they don't already exists, this option will not change the
* database.
- * <p>
- * All of the parameters of the Update method must either be classes annotated with {@link Entity}
+ *
+ * All of the parameters of the Update method must either be classes annotated with [Entity]
* or collections/array of it.
- * <p>
+ *
* Example:
- * <pre>
- * {@literal @}Dao
+ *
+ * ```
+ * @Dao
* public interface MusicDao {
- * {@literal @}Update
- * public void updateSong(Song);
+ * @Update
+ * fun updateSong(song: Song)
*
- * {@literal @}Update
- * public int updateSongs(List<Song> songs);
+ * @Update
+ * fun updateSongs(songs: List<Song>): Int
* }
- * </pre>
- * If the target entity is specified via {@link #entity()} then the parameters can be of arbitrary
+ * ```
+ *
+ * If the target entity is specified via [entity] then the parameters can be of arbitrary
* POJO types that will be interpreted as partial entities. For example:
- * <pre>
- * {@literal @}Entity
- * public class Playlist {
- * {@literal @}PrimaryKey(autoGenerate = true)
- * long playlistId;
- * String name;
- * {@literal @}ColumnInfo(defaultValue = "")
- * String description
- * {@literal @}ColumnInfo(defaultValue = "normal")
- * String category;
- * {@literal @}ColumnInfo(defaultValue = "CURRENT_TIMESTAMP")
- * String createdTime;
- * {@literal @}ColumnInfo(defaultValue = "CURRENT_TIMESTAMP")
- * String lastModifiedTime;
- * }
*
- * public class PlaylistCategory {
- * long playlistId;
- * String category;
- * String lastModifiedTime
- * }
+ * ```
+ * @Entity
+ * data class Playlist (
+ * @PrimaryKey(autoGenerate = true)
+ * val playlistId: Long,
+ * val name: String,
+ * @ColumnInfo(defaultValue = "")
+ * val description: String,
+ * @ColumnInfo(defaultValue = "normal")
+ * val category: String,
+ * @ColumnInfo(defaultValue = "CURRENT_TIMESTAMP")
+ * val createdTime: String,
+ * @ColumnInfo(defaultValue = "CURRENT_TIMESTAMP")
+ * val lastModifiedTime: String
+ * )
*
- * {@literal @}Dao
+ * data class PlaylistCategory (
+ * val playlistId: Long,
+ * val category: String,
+ * val lastModifiedTime: String
+ * )
+ *
+ * @Dao
* public interface PlaylistDao {
- * {@literal @}Update(entity = Playlist.class)
- * public void updateCategory(PlaylistCategory... category);
+ * @Update(entity = Playlist::class)
+ * fun updateCategory(varargs category: Category)
* }
- * </pre>
+ * ```
*
- * @see Insert
- * @see Delete
+ * @see [Insert]
+ * @see [Delete]
*/
-@Retention(RetentionPolicy.CLASS)
-public @interface Update {
+@Target(AnnotationTarget.FUNCTION)
+@Retention(AnnotationRetention.BINARY)
+public annotation class Update(
/**
* The target entity of the update method.
- * <p>
+ *
* When this is declared, the update method parameters are interpreted as partial entities when
* the type of the parameter differs from the target. The POJO class that represents the entity
* must contain a subset of the fields of the target entity along with its primary keys.
- * <p>
+ *
* Only the columns represented by the partial entity fields will be updated if an entity with
* equal primary key is found.
- * <p>
+ *
* By default the target entity is interpreted by the method parameters.
*
* @return the target entity of the update method or none if the method should use the
* parameter type entities.
*/
- Class<?> entity() default Object.class;
+ val entity: KClass<*> = Any::class,
/**
* What to do if a conflict happens.
- * <p>
- * Use {@link OnConflictStrategy#ABORT} (default) to roll back the transaction on conflict.
- * Use {@link OnConflictStrategy#REPLACE} to replace the existing rows with the new rows.
- * Use {@link OnConflictStrategy#IGNORE} to keep the existing rows.
*
- * @return How to handle conflicts. Defaults to {@link OnConflictStrategy#ABORT}.
+ * Use [OnConflictStrategy.ABORT] (default) to roll back the transaction on conflict.
+ * Use [OnConflictStrategy.REPLACE] to replace the existing rows with the new rows.
+ * Use [OnConflictStrategy.IGNORE] to keep the existing rows.
+ *
+ * @return How to handle conflicts. Defaults to [OnConflictStrategy.ABORT].
*/
@OnConflictStrategy
- int onConflict() default OnConflictStrategy.ABORT;
-}
+ val onConflict: Int = OnConflictStrategy.ABORT
+)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/InsertionMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/InsertionMethodProcessor.kt
index 4b81209..4a8a750 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/InsertionMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/InsertionMethodProcessor.kt
@@ -19,8 +19,7 @@
package androidx.room.processor
import androidx.room.Insert
-import androidx.room.OnConflictStrategy.IGNORE
-import androidx.room.OnConflictStrategy.REPLACE
+import androidx.room.OnConflictStrategy
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
import androidx.room.vo.InsertionMethod
@@ -41,7 +40,7 @@
val onConflict = annotation?.value?.onConflict ?: OnConflictProcessor.INVALID_ON_CONFLICT
context.checker.check(
- onConflict in REPLACE..IGNORE,
+ onConflict in OnConflictStrategy.REPLACE..OnConflictStrategy.IGNORE,
executableElement, ProcessorErrors.INVALID_ON_CONFLICT_VALUE
)
diff --git a/room/room-compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt b/room/room-compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt
index 9156f3b..da05155 100644
--- a/room/room-compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt
+++ b/room/room-compiler/src/main/kotlin/androidx/room/processor/UpdateMethodProcessor.kt
@@ -16,8 +16,7 @@
package androidx.room.processor
-import androidx.room.OnConflictStrategy.IGNORE
-import androidx.room.OnConflictStrategy.REPLACE
+import androidx.room.OnConflictStrategy
import androidx.room.Update
import androidx.room.compiler.processing.XMethodElement
import androidx.room.compiler.processing.XType
@@ -38,7 +37,7 @@
val onConflict = annotation?.value?.onConflict ?: OnConflictProcessor.INVALID_ON_CONFLICT
context.checker.check(
- onConflict in REPLACE..IGNORE,
+ onConflict in OnConflictStrategy.REPLACE..OnConflictStrategy.IGNORE,
executableElement, ProcessorErrors.INVALID_ON_CONFLICT_VALUE
)