DBFlowDatabase.awaitTransact( + modelQueriable: Q, + crossinline queriableFunction: Q.() -> R) = suspendCancellableCoroutine{ continuation -> + com.dbflow5.coroutines.constructCoroutine(continuation, this) { queriableFunction(modelQueriable) } +} + +inline fun constructCoroutine(continuation: CancellableContinuation , + databaseDefinition: DBFlowDatabase, + crossinline fn: () -> R) { + val transaction = databaseDefinition.beginTransactionAsync { fn() } + .success { _, result -> continuation.resume(result) } + .error { _, throwable -> + if (continuation.isCancelled) return@error + continuation.resumeWithException(throwable) + }.build() + transaction.execute() + + continuation.invokeOnCancellation { + if (continuation.isCancelled) { + transaction.cancel() + } + } +} + + +/** + * Description: Puts a [Model] operation inside a coroutine. Inside the [queriableFunction] + * execute the db operation. + */ +suspend inline fun M.awaitSave(databaseDefinition: DBFlowDatabase) = suspendCancellableCoroutine { continuation -> + constructCoroutine(continuation, databaseDefinition) { save(databaseDefinition) } +} + +/** + * Description: Puts a [Model] operation inside a coroutine. Inside the [queriableFunction] + * execute the db operation. + */ +suspend inline fun M.awaitInsert(databaseDefinition: DBFlowDatabase) = suspendCancellableCoroutine { continuation -> + constructCoroutine(continuation, databaseDefinition) { insert(databaseDefinition) } +} + +/** + * Description: Puts a [Model] operation inside a coroutine. Inside the [queriableFunction] + * execute the db operation. + */ +suspend inline fun M.awaitDelete(databaseDefinition: DBFlowDatabase) = suspendCancellableCoroutine { continuation -> + constructCoroutine(continuation, databaseDefinition) { delete(databaseDefinition) } +} + +/** + * Description: Puts a [Model] operation inside a coroutine. Inside the [queriableFunction] + * execute the db operation. + */ +suspend inline fun M.awaitUpdate(databaseDefinition: DBFlowDatabase) = suspendCancellableCoroutine { continuation -> + constructCoroutine(continuation, databaseDefinition) { update(databaseDefinition) } +} + +/** + * Description: Puts a [Model] operation inside a coroutine. Inside the [queriableFunction] + * execute the db operation. + */ +suspend inline fun M.awaitLoad(databaseDefinition: DBFlowDatabase) = suspendCancellableCoroutine { continuation -> + constructCoroutine(continuation, databaseDefinition) { load(databaseDefinition) } +} + +/** + * Description: Puts the [Collection] inside a [FastStoreModelTransaction] coroutine. + */ +suspend inline fun > M.awaitSave(databaseDefinition: DBFlowDatabase) = suspendCancellableCoroutine { continuation -> + constructFastCoroutine(continuation, databaseDefinition) { fastSave() } +} + +/** + * Description: Puts the [Collection] inside a [FastStoreModelTransaction] coroutine. + */ +suspend inline fun > M.awaitInsert(databaseDefinition: DBFlowDatabase) = suspendCancellableCoroutine { continuation -> + constructFastCoroutine(continuation, databaseDefinition) { fastInsert() } +} + +/** + * Description: Puts the [Collection] inside a [FastStoreModelTransaction] coroutine. + */ +suspend inline fun > M.awaitUpdate(databaseDefinition: DBFlowDatabase) = suspendCancellableCoroutine { continuation -> + constructFastCoroutine(continuation, databaseDefinition) { fastUpdate() } +} + +/** + * Description: Puts the [Collection] inside a [FastStoreModelTransaction] coroutine. + */ +suspend inline fun > M.awaitDelete(databaseDefinition: DBFlowDatabase) = suspendCancellableCoroutine { continuation -> + constructFastCoroutine(continuation, databaseDefinition) { fastDelete() } +} + + +inline fun constructFastCoroutine(continuation: CancellableContinuation , + databaseDefinition: DBFlowDatabase, + crossinline fn: () -> FastStoreModelTransaction.Builder ) { + val transaction = databaseDefinition.beginTransactionAsync(fn().build()) + .success { _, result -> continuation.resume(result) } + .error { _, throwable -> + if (continuation.isCancelled) return@error + continuation.resumeWithException(throwable) + }.build() + transaction.execute() + + continuation.invokeOnCancellation { + transaction.cancel() + } +} \ No newline at end of file diff --git a/dbflow-core/build.gradle b/dbflow-core/build.gradle deleted file mode 100644 index 8a3deae9b..000000000 --- a/dbflow-core/build.gradle +++ /dev/null @@ -1,8 +0,0 @@ -apply plugin: 'java' - -project.ext.artifactId = bt_name - -targetCompatibility = JavaVersion.VERSION_1_7 -sourceCompatibility = JavaVersion.VERSION_1_7 - -apply from: '../java-artifacts.gradle' \ No newline at end of file diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/StringUtils.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/StringUtils.java deleted file mode 100644 index 5079697fb..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/StringUtils.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.raizlabs.android.dbflow; - -/** - * Description: Provides handy method for strings - */ -public class StringUtils { - - /** - * @return true if the string is not null, empty string "", or the length is greater than 0 - */ - public static boolean isNotNullOrEmpty(String inString) { - return inString != null && !inString.equals("") && inString.length() > 0; - } - - /** - * @return true if the string is null, empty string "", or the length is less than equal to 0 - */ - public static boolean isNullOrEmpty(String inString) { - return inString == null || inString.equals("") || inString.length() <= 0; - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Column.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Column.java deleted file mode 100644 index e5b88f9cd..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Column.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Marks a field as corresponding to a column in the DB. - * When adding new columns or changing names, you need to define a new {@link Migration}. - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.FIELD) -public @interface Column { - - /** - * @return The name of the column. The default is the field name. - */ - String name() default ""; - - /** - * @return An optional column length - */ - int length() default -1; - - /** - * @return Marks the field as having a specified collation to use in it's creation. - */ - Collate collate() default Collate.NONE; - - /** - * @return Adds a default value for this column when saving. This is a string representation - * of the value. - * Note this will place it in when saving - * to the DB because we cannot know the intention of missing data from a query. - */ - String defaultValue() default ""; - - /** - * @return If private, by default this is get{Name}() for "name". To define a custom one, this method specifies the name - * of the method only, and not any specific params. So for "getAnotherName()" you would use "AnotherName" as the param. - */ - String getterName() default ""; - - /** - * @return If private, by default this is set{Name}() for "name". To define a custom one, this method specifies the name - * of the method only, and not any specific params. So for "setAnotherName(String name)" you would use "AnotherName" as the param. - * The params must align exactly to an expected setter, otherwise a compile error ensues. - */ - String setterName() default ""; - - /** - * @return A custom type converter that's only used for this field. It will be created and used in - * the Adapter associated with this table. - */ - Class extends com.raizlabs.android.dbflow.converter.TypeConverter> typeConverter() default com.raizlabs.android.dbflow.converter.TypeConverter.class; - -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnIgnore.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnIgnore.java deleted file mode 100644 index 100771bdd..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnIgnore.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: An annotation used to ignore a column in the {@link Table#allFields()} instance. - */ -@Retention(RetentionPolicy.CLASS) -@Target(ElementType.FIELD) -public @interface ColumnIgnore { -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnMap.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnMap.java deleted file mode 100644 index 95524fca7..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnMap.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Maps an arbitrary object and its corresponding fields into a set of columns. It is similar - * to {@link ForeignKey} except it's not represented in the DB hierarchy. - */ -@Retention(RetentionPolicy.CLASS) -@Target(ElementType.FIELD) -public @interface ColumnMap { - - /** - * Defines explicit references for a composite {@link ColumnMap} definition. - * - * @return override explicit usage of all fields and provide custom references. - */ - ColumnMapReference[] references() default {}; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnMapReference.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnMapReference.java deleted file mode 100644 index c944d5be4..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ColumnMapReference.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Allows a {@link ColumnMap} to specify a reference override for its fields. Anything not - * defined here will not be used. - */ -@Retention(RetentionPolicy.CLASS) -@Target(ElementType.FIELD) -public @interface ColumnMapReference { - - /** - * @return The local column name that will be referenced in the DB - */ - String columnName(); - - /** - * @return The column name in the referenced table - */ - String columnMapFieldName(); - - /** - * @return Specify the {@link NotNull} annotation here and it will get pasted into the reference definition. - */ - NotNull notNull() default @NotNull(onNullConflict = ConflictAction.NONE); -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Database.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Database.java deleted file mode 100644 index 293edacb0..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Database.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Creates a new database to use in the application. - * - * If we specify one DB, then all models do not need to specify a DB. As soon as we specify two, then each - * model needs to define what DB it points to. - *
- *- * Models will specify which DB it belongs to, - * but they currently can only belong to one DB. - *
- */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.SOURCE) -public @interface Database { - - /** - * @return The current version of the DB. Increment it to trigger a DB update. - */ - int version(); - - /** - * @deprecated use DatabaseConfig.databaseName() to change the name. - */ - @Deprecated - String name() default ""; - - /** - * @deprecated use DatabaseConfig.extension() to change the extension. - */ - @Deprecated - String databaseExtension() default ""; - - /** - * @deprecated use DatabaseConfig.inMemoryBuilder() instead. - */ - @Deprecated - boolean inMemory() default false; - - /** - * @return If true, SQLite will throw exceptions when {@link ForeignKey} constraints are not respected. - * Default is false and will not throw exceptions. - */ - boolean foreignKeyConstraintsEnforced() default false; - - /** - * @return Checks for consistency in the DB, if true it will recopy over the prepackage database. - */ - boolean consistencyCheckEnabled() default false; - - /** - * @return Keeps a backup for whenever the database integrity fails a "PRAGMA quick_check(1)" that will - * replace the corrupted DB - */ - boolean backupEnabled() default false; - - /** - * @return Global default insert conflict that can be applied to any table when it leaves - * its {@link ConflictAction} as NONE. - */ - ConflictAction insertConflict() default ConflictAction.NONE; - - /** - * @return Global update conflict that can be applied to any table when it leaves its - * {@link ConflictAction} as NONE - */ - ConflictAction updateConflict() default ConflictAction.NONE; - - /** - * @return Marks all generated classes within this database with this character. For example - * "TestTable" becomes "TestTable$Table" for a "$" separator. - * @deprecated Generated class files will become '_' only in next major release. - */ - @Deprecated - String generatedClassSeparator() default "_"; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ForeignKey.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ForeignKey.java deleted file mode 100644 index fb82d308c..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ForeignKey.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.FIELD) -public @interface ForeignKey { - - /** - * Defines explicit references for a composite {@link ForeignKey} definition. This is no longer required - * as the library will auto-generate references for you based on the other table's primary keys. - * - * @return the set of explicit references if you wish to have different values than default generated. - */ - ForeignKeyReference[] references() default {}; - - /** - * @return Default false. When this column is a {@link ForeignKey} and table object, - * returning true will save the model before adding the fields to save as a foreign key. - * If false, we expect the field to not change and must save the model manually outside - * of the ModelAdapter before saving the child class. - */ - boolean saveForeignKeyModel() default false; - - /** - * @return Default false. When this column is a {@link ForeignKey} and table object, - * returning true will delte the model before deleting its enclosing child class. - * If false, we expect the field to not change and must delete the model manually outside - * of the ModelAdapter before saving the child class. - */ - boolean deleteForeignKeyModel() default false; - - /** - * @return Replaces legacy ForeignKeyContainer, this method instructs the code generator to only - * populate the model with the {@link ForeignKeyReference} defined in this field. This skips - * the Select retrieval convenience. - */ - boolean stubbedRelationship() default false; - - /** - * @return If true, during a transaction, FK constraints are not violated immediately until the resulting transaction commits. - * This is useful for out of order foreign key operations. - * @see Deferred Foreign Key Constraints - */ - boolean deferred() default false; - - /** - * @return an optional table class that this reference points to. It's only used if the field - * is NOT a Model class. - */ - Class> tableClass() default Object.class; - - /** - * Defines {@link ForeignKeyAction} action to be performed - * on delete of referenced record. Defaults to {@link ForeignKeyAction#NO_ACTION}. Used only when - * columnType is {@link ForeignKey}. - * - * @return {@link ForeignKeyAction} - */ - ForeignKeyAction onDelete() default ForeignKeyAction.NO_ACTION; - - /** - * Defines {@link ForeignKeyAction} action to be performed - * on update of referenced record. Defaults to {@link ForeignKeyAction#NO_ACTION}. Used only when - * columnType is {@link ForeignKey}. - * - * @return {@link ForeignKeyAction} - */ - ForeignKeyAction onUpdate() default ForeignKeyAction.NO_ACTION; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ForeignKeyReference.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ForeignKeyReference.java deleted file mode 100644 index 7cb343b33..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ForeignKeyReference.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Description: Used inside of {@link ForeignKey#references()}, describes the - * local column name, type, and referencing table column name. - * - * Note: the type of the local column must match the - * column type of the referenced column. By using a field as a Model object, - * you will need to ensure the same types are used. - */ -@Retention(RetentionPolicy.SOURCE) -public @interface ForeignKeyReference { - - /** - * @return The local column name that will be referenced in the DB - */ - String columnName(); - - /** - * @return The column name in the referenced table - */ - String foreignKeyColumnName(); - - /** - * @return Specify the {@link NotNull} annotation here and it will get pasted into the reference definition. - */ - NotNull notNull() default @NotNull(onNullConflict = ConflictAction.NONE); -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Index.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Index.java deleted file mode 100644 index 7939773e1..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Index.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Creates an index for a specified {@link Column}. A single column can belong to multiple - * indexes within the same table if you wish. - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.FIELD) -public @interface Index { - - /** - * @return The set of index groups that this index belongs to. - */ - int[] indexGroups() default {}; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/IndexGroup.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/IndexGroup.java deleted file mode 100644 index b4eb07548..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/IndexGroup.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: - */ -@Target(ElementType.ANNOTATION_TYPE) -@Retention(RetentionPolicy.SOURCE) -public @interface IndexGroup { - - int GENERIC = -1; - - /** - * @return The number that each contained {@link Index} points to, so they can be combined into a single index. - * If {@link #GENERIC}, this will assume a generic index that covers the whole table. - */ - int number() default GENERIC; - - /** - * @return The name of this index. It must be unique from other {@link IndexGroup}. - */ - String name(); - - /** - * @return If true, this will disallow duplicate values to be inserted into the table. - */ - boolean unique() default false; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/InheritedColumn.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/InheritedColumn.java deleted file mode 100644 index 158ec83ec..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/InheritedColumn.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Allows {@link Table} to inherit fields from other objects to make it part of the DB table. - */ -@Target(ElementType.ANNOTATION_TYPE) -@Retention(RetentionPolicy.SOURCE) -public @interface InheritedColumn { - - /** - * @return The column annotation as if it was part of the class - */ - Column column(); - - /** - * @return The field name that an inherited column uses. It must match exactly case-by-case to the field you're referencing. - * If the field is private, the {@link Column} allows you to define getter and setters for it. - */ - String fieldName(); - - /** - * @return If specified other than {@link ConflictAction#NONE}, then we assume {@link NotNull}. - */ - ConflictAction nonNullConflict() default ConflictAction.NONE; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/InheritedPrimaryKey.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/InheritedPrimaryKey.java deleted file mode 100644 index 954e992e1..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/InheritedPrimaryKey.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Allows you to specify a non-Column to be inherited and used as a {@link PrimaryKey} - */ -@Target(ElementType.ANNOTATION_TYPE) -@Retention(RetentionPolicy.SOURCE) -public @interface InheritedPrimaryKey { - - /** - * @return The primary key annotation as if it was part of the class - */ - PrimaryKey primaryKey(); - - /** - * @return The column annotation as if it was part of the class - */ - Column column(); - - /** - * @return The field name that an inherited column uses. It must match exactly case-by-case to the field you're referencing. - * If the field is private, the {@link PrimaryKey} allows you to define getter and setters for it. - */ - String fieldName(); -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ManyToMany.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ManyToMany.java deleted file mode 100644 index 731c7ca2a..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ManyToMany.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Builds a many-to-many relationship with another {@link Table}. Only one table needs to specify - * the annotation and its assumed that they use primary keys only. The generated - * class will contain an auto-incrementing primary key by default. - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.TYPE) -public @interface ManyToMany { - - /** - * @return The other table class by which this will get merged. - */ - Class> referencedTable(); - - /** - * @return A name that we use as the column name for the referenced table in the - * generated ManyToMany table class. - */ - String referencedTableColumnName() default ""; - - /** - * @return A name that we use as the column name for this specific table's name. - */ - String thisTableColumnName() default ""; - - /** - * @return By default, we generate an auto-incrementing {@link Long} {@link PrimaryKey}. - * If false, all {@link PrimaryKey} of the corresponding tables will be placed as {@link ForeignKey} and {@link PrimaryKey} - * of the generated table instead of using an autoincrementing Long {@link PrimaryKey}. - */ - boolean generateAutoIncrement() default true; - - /** - * @return by default, we append {selfTable}{generatedClassSeparator}{referencedTable} or "User_Follower", - * for example. If you want different name, change this. - */ - String generatedTableClassName() default ""; - - /** - * @return by default the Models referenced here are not saved prior to saving this - * object for obvious efficiency reasons. - * @see ForeignKey#saveForeignKeyModel() - */ - boolean saveForeignKeyModels() default false; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Migration.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Migration.java deleted file mode 100644 index 56af5bfad..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Migration.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Marks a Migration class to be included in DB construction. The class using this annotation - * must implement the Migration interface. - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.TYPE) -public @interface Migration { - - /** - * @return The version the migration will trigger at. - */ - int version(); - - /** - * @return Specify the database class that this migration belongs to. - */ - Class> database(); - - /** - * @return If number greater than -1, the migrations from the same {@link #version()} get ordered from - * highest to lowest. if they are the same priority, there is no telling which one is executed first. The - * annotation processor will process in order it finds the classes. - */ - int priority() default -1; - -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ModelCacheField.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ModelCacheField.java deleted file mode 100644 index 9bd97db3f..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ModelCacheField.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: marks a single field as a ModelCache creator that is used in the corresponding ModelAdapter. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.SOURCE) -public @interface ModelCacheField { -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ModelView.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ModelView.java deleted file mode 100644 index 67e43f24b..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ModelView.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import com.raizlabs.android.dbflow.sql.Query; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Author: andrewgrosner - * Description: Marks a class as being an SQL VIEW definition. It must extend BaseModelView and have - * a single public, static, final field that is annotated with {@link ModelViewQuery} and be a {@link Query}. - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.TYPE) -public @interface ModelView { - - /** - * @return The name of this view. Default is the class name. - */ - String name() default ""; - - /** - * @return The class of the database this corresponds to. - */ - Class> database(); - - - /** - * @return When true, all public, package-private , non-static, and non-final fields of the reference class are considered as {@link com.raizlabs.android.dbflow.annotation.Column} . - * The only required annotated field becomes The {@link PrimaryKey} - * or {@link PrimaryKey#autoincrement()}. - */ - boolean allFields() default false; - - /** - * @return The higher the number, the order by which the creation of this class gets called. - * Useful for creating ones that depend on another {@link ModelView}. - */ - int priority() default 0; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ModelViewQuery.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ModelViewQuery.java deleted file mode 100644 index 351d4d7ec..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/ModelViewQuery.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import com.raizlabs.android.dbflow.sql.Query; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Represents a field that is a {@link Query}. This is only meant to be used as a query - * reference in {@link ModelView}. This is so the annotation processor knows how to access the query of - * the view. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.SOURCE) -public @interface ModelViewQuery { -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/MultiCacheField.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/MultiCacheField.java deleted file mode 100644 index 31006644d..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/MultiCacheField.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Marks a field as the IMultiKeyCacheModel that we use to convert multiple fields into - * a single key for caching. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.SOURCE) -public @interface MultiCacheField { -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/MultipleManyToMany.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/MultipleManyToMany.java deleted file mode 100644 index d57b2acee..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/MultipleManyToMany.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Provides ability to add multiple {@link ManyToMany} annotations at once. - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.TYPE) -public @interface MultipleManyToMany { - - ManyToMany[] value(); -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/NotNull.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/NotNull.java deleted file mode 100644 index 982af7fb6..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/NotNull.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Specifies that a {@link Column} is not null. - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.SOURCE) -public @interface NotNull { - - /** - * Defines how to handle conflicts for not null column - * - * @return a {@link com.raizlabs.android.dbflow.annotation.ConflictAction} enum - */ - ConflictAction onNullConflict() default ConflictAction.FAIL; - -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/OneToMany.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/OneToMany.java deleted file mode 100644 index 175a8cadf..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/OneToMany.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.util.List; - -/** - * Description: Describes a 1-many relationship. It applies to some method that returns a {@link List} of Model objects. - * This annotation can handle loading, deleting, and saving when the current data changes. By default it will call the - * associated method when the containing class operates. - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.SOURCE) -public @interface OneToMany { - - /** - * The method to apply the OneToMany to. - */ - enum Method { - - /** - * Load this relationship when the parent model loads from the database. This is called before the OnLoadFromCursor - * method, but after other columns load. - */ - LOAD, - - /** - * Inserts code to delete the results returned from the List relationship when the parent model is deleted. - */ - DELETE, - - /** - * Inserts code to save the list of models when the parent model is saved. - */ - SAVE, - - /** - * Shorthand to support all options. - */ - ALL - } - - /** - * @return The methods you wish to call it from. By default it's loaded out of the DB. - */ - Method[] methods() default Method.LOAD; - - /** - * @return The name of the list variable to use. If is left blank, we will remove the "get" and then decapitalize the remaining name. - */ - String variableName() default ""; - - /** - * @return If true, the underlying variable that we use is private, requiring us to provide - * a setter for it. - * @deprecated has no effect on the visibility of the call since we now autodetect visibility. - */ - @Deprecated - boolean isVariablePrivate() default false; - - /** - * @return If true, the code generated for this relationship done as efficiently as possible. - * It will not work on nested relationships, caching, and other code that requires overriding of BaseModel or Model operations. - */ - boolean efficientMethods() default true; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/PrimaryKey.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/PrimaryKey.java deleted file mode 100644 index 2d2521412..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/PrimaryKey.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.FIELD) -public @interface PrimaryKey { - - /** - * Specifies if the column is autoincrementing or not - */ - boolean autoincrement() default false; - - /** - * Specifies the column to be treated as a ROWID but is not an {@link #autoincrement()}. This - * overrides {@link #autoincrement()} and is mutually exclusive. - */ - boolean rowID() default false; - - /** - * @return When true, we simple do {columnName} > 0 when checking for it's existence if {@link #autoincrement()} - * is true. If not, we do a full database SELECT exists. - */ - boolean quickCheckAutoIncrement() default false; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/QueryModel.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/QueryModel.java deleted file mode 100644 index d7295582e..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/QueryModel.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Marks a Model class as NOT a {@link Table}, but generates code for retrieving data from a - * generic query - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.TYPE) -public @interface QueryModel { - - /** - * @return Specify the class of the database to use. - */ - Class> database(); - - /** - * @return If true, all accessible, non-static, and non-final fields are treated as valid fields. - * @see Table#allFields() - */ - boolean allFields() default false; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Table.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Table.java deleted file mode 100644 index 106e37aed..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Table.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Author: andrewgrosner - * Description: Marks a class as being a table for only ONE DB. It must implement the Model interface and all fields MUST be package private. - * This will generate a $Table and $Adapter class. The $Table class generates static final column name variables to reference in queries. - * The $Adapter class defines how to retrieve and store this object as well as other methods for acting on model objects in the database. - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.TYPE) -public @interface Table { - - int DEFAULT_CACHE_SIZE = 25; - - /** - * @return Specifies a different name for the table than the name of the Model class. - */ - String name() default ""; - - /** - * @return Specify the database class that this table belongs to. It must have the {@link Database} annotation. - */ - Class> database(); - - /** - * @return Specify the general conflict algorithm used by this table when updating records. - */ - ConflictAction updateConflict() default ConflictAction.NONE; - - /** - * @return Specify the general insert conflict algorithm used by this table. - */ - ConflictAction insertConflict() default ConflictAction.NONE; - - /** - * @return An optional {@link ConflictAction} that we append to creation for conflict handling in PK. - */ - ConflictAction primaryKeyConflict() default ConflictAction.NONE; - - /** - * @return When true, all public, package-private , non-static, and non-final fields of the reference class are considered as {@link com.raizlabs.android.dbflow.annotation.Column} . - * The only required annotated field becomes The {@link PrimaryKey} - * or {@link PrimaryKey#autoincrement()}. - */ - boolean allFields() default false; - - /** - * @return If true, all private boolean fields will use "is" instead of "get" for its getter and - * "set" without the "is" if it starts with "is" - */ - boolean useBooleanGetterSetters() default true; - - /** - * @return If true, caching mechanism is enabled. This works for single primary key tables. For - * multi-primary key tables, IMultiKeyCacheModel interface is required to specify the caching key. - */ - boolean cachingEnabled() default false; - - /** - * @return If true, we throw away checks for column indexing and simply assume that the cursor returns - * all our columns in order. This may provide a slight performance boost. - */ - boolean orderedCursorLookUp() default false; - - /** - * @return When true, we reassign the corresponding Model's fields to default values when loading - * from cursor. If false, we assign values only if present in Cursor. - */ - boolean assignDefaultValuesFromCursor() default true; - - /** - * @return When false, this table gets generated and associated with database, however it will not immediately - * get created upon startup. This is useful for keeping around legacy tables for migrations. - */ - boolean createWithDatabase() default true; - - /** - * @return The cache size for this Table. - */ - int cacheSize() default 25; - - /** - * @return Declares a set of UNIQUE columns with the corresponding {@link ConflictAction}. A {@link Column} - * will point to this group using {@link Unique#uniqueGroups()} - */ - UniqueGroup[] uniqueColumnGroups() default {}; - - /** - * @return The set of INDEX clauses that specific columns can define to belong to, using the {@link Index} annotation. - * The generated Index properties belong to the corresponding property class to this table. - */ - IndexGroup[] indexGroups() default {}; - - /** - * @return A set of inherited accessible fields not necessarily defined as columns in the super class of this table. - * Each must be accessible via: public, package private, or protected or getter/setters. - */ - InheritedColumn[] inheritedColumns() default {}; - - /** - * @return A set of inherited accessible fields not necessarily defined as columns in the super class of this table. - * Each must be accessible via: public, package private, or protected or getter/setters. - */ - InheritedPrimaryKey[] inheritedPrimaryKeys() default {}; - -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/TypeConverter.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/TypeConverter.java deleted file mode 100644 index a99bfaa57..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/TypeConverter.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Author: andrewgrosner - * Description: Marks a class as being a TypeConverter. A type converter will turn a non-model, non-SQLiteTyped class into - * a valid database type. - */ -@Retention(RetentionPolicy.CLASS) -@Target(ElementType.TYPE) -public @interface TypeConverter { - - /** - * @return Specify a set of subclasses by which the {@link TypeConverter} registers for. For - * each one, this will create a new instance of the converter. - */ - Class>[] allowedSubtypes() default {}; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Unique.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Unique.java deleted file mode 100644 index 35e762e79..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/Unique.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Marks the field as unique, meaning its value cannot be repeated. It is, however, - * NOT a primary key. - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.FIELD) -public @interface Unique { - - /** - * @return if field is unique. If false, we expect {@link #uniqueGroups()} to be specified.` - */ - boolean unique() default true; - - /** - * @return Marks a unique field as part of a unique group. For every unique number entered, - * it will generate a UNIQUE() column statement. - */ - int[] uniqueGroups() default {}; - - /** - * Defines how to handle conflicts for a unique column - * - * @return a {@link com.raizlabs.android.dbflow.annotation.ConflictAction} enum - */ - ConflictAction onUniqueConflict() default ConflictAction.FAIL; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/UniqueGroup.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/UniqueGroup.java deleted file mode 100644 index b307ed387..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/UniqueGroup.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.raizlabs.android.dbflow.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: - */ -@Target(ElementType.ANNOTATION_TYPE) -@Retention(RetentionPolicy.SOURCE) -public @interface UniqueGroup { - - /** - * @return The number that columns point to to use this group - */ - int groupNumber(); - - /** - * @return The conflict action that this group takes. - */ - ConflictAction uniqueConflict() default ConflictAction.FAIL; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/ContentProvider.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/ContentProvider.java deleted file mode 100644 index e3a8548dd..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/ContentProvider.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.raizlabs.android.dbflow.annotation.provider; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Defines a Content Provider that gets generated. - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.SOURCE) -public @interface ContentProvider { - - /** - * @return The authority URI for this provider. - */ - String authority(); - - /** - * @return The class of the database this belongs to - */ - Class> database(); - - /** - * @return The base content uri String to use for all paths - */ - String baseContentUri() default ""; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/ContentUri.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/ContentUri.java deleted file mode 100644 index 1b12491e2..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/ContentUri.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.raizlabs.android.dbflow.annotation.provider; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Defines the URI for a content provider. - */ -@Target({ElementType.FIELD, ElementType.METHOD}) -@Retention(RetentionPolicy.SOURCE) -public @interface ContentUri { - - /** - * Provides some handy constants for defining a {@link #type()} - */ - class ContentType { - - public static final String VND_MULTIPLE = "vnd.android.cursor.dir/"; - - public static final String VND_SINGLE = "vnd.android.cursor.item/"; - } - - /** - * Defines the path segment that we use when we specify "#" in the path. - */ - @interface PathSegment { - - /** - * @return The number segment this corresponds to. - */ - int segment(); - - /** - * @return The column name that this segment will use. - */ - String column(); - } - - /** - * @return the path of this ContentUri. ex: notes/#, notes/1, etc. Must be unique within a {@link TableEndpoint} - */ - String path(); - - /** - * @return The type of content that this uri is associated with. Ex: {@link ContentType#VND_SINGLE} - */ - String type(); - - /** - * @return If the path defines "#", then we use these numbers to find them in the same order as - * where column. - */ - PathSegment[] segments() default {}; - - /** - * @return false if you wish to not allow queries from the specified URI. - */ - boolean queryEnabled() default true; - - /** - * @return false if you wish to prevent inserts. - */ - boolean insertEnabled() default true; - - /** - * @return false if you wish to prevent deletion. - */ - boolean deleteEnabled() default true; - - /** - * @return false if you wish to prevent updates. - */ - boolean updateEnabled() default true; - -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/Notify.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/Notify.java deleted file mode 100644 index e678d8dae..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/Notify.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.raizlabs.android.dbflow.annotation.provider; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Annotates a method part of {@link com.raizlabs.android.dbflow.annotation.provider.TableEndpoint} - * that gets called back when changed. The method must return a Uri or an array of Uri[] to notify changed on - * the content provider. - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.METHOD) -public @interface Notify { - - enum Method { - INSERT, - UPDATE, - DELETE - } - - /** - * @return The {@link com.raizlabs.android.dbflow.annotation.provider.Notify.Method} notify - */ - Method method(); - - /** - * @return Registers itself for the following paths. If a specific path is called for the specified - * method, the method this annotation corresponds to will be called. - */ - String[] paths() default {}; -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/TableEndpoint.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/TableEndpoint.java deleted file mode 100644 index 7251708f0..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/annotation/provider/TableEndpoint.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.raizlabs.android.dbflow.annotation.provider; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Description: Defines an endpoint that gets placed inside of a {@link com.raizlabs.android.dbflow.annotation.provider.ContentProvider} - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.SOURCE) -public @interface TableEndpoint { - - /** - * @return The name of the table this endpoint corresponds to. - */ - String name(); - - /** - * @return When placed in a top-level class, this is required to connect it to a provider. - */ - Class> contentProvider(); -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/BigDecimalConverter.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/BigDecimalConverter.java deleted file mode 100644 index f06249e92..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/BigDecimalConverter.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.raizlabs.android.dbflow.converter; - -import java.math.BigDecimal; - -/** - * Description: Defines how we store and retrieve a {@link java.math.BigDecimal} - */ -public class BigDecimalConverter extends TypeConverter{ - @Override - public String getDBValue(BigDecimal model) { - return model == null ? null : model.toString(); - } - - @Override - public BigDecimal getModelValue(String data) { - return data == null ? null : new BigDecimal(data); - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/BigIntegerConverter.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/BigIntegerConverter.java deleted file mode 100644 index 85826246b..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/BigIntegerConverter.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.raizlabs.android.dbflow.converter; - -import java.math.BigInteger; - -/** - * Description: Defines how we store and retrieve a {@link java.math.BigInteger} - */ -public class BigIntegerConverter extends TypeConverter { - @Override - public String getDBValue(BigInteger model) { - return model == null ? null : model.toString(); - } - - @Override - public BigInteger getModelValue(String data) { - return data == null ? null : new BigInteger(data); - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/BooleanConverter.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/BooleanConverter.java deleted file mode 100644 index d44a0c34e..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/BooleanConverter.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.raizlabs.android.dbflow.converter; - -/** - * Description: Converts a boolean object into an Integer for database storage. - */ -public class BooleanConverter extends TypeConverter { - @Override - public Integer getDBValue(Boolean model) { - return model == null ? null : model ? 1 : 0; - } - - @Override - public Boolean getModelValue(Integer data) { - return data == null ? null : data == 1; - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/CalendarConverter.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/CalendarConverter.java deleted file mode 100644 index 2832262c2..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/CalendarConverter.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.raizlabs.android.dbflow.converter; - -import java.util.Calendar; -import java.util.GregorianCalendar; - -/** - * Author: andrewgrosner - * Description: Defines how we store and retrieve a {@link java.util.Calendar} - */ -@com.raizlabs.android.dbflow.annotation.TypeConverter(allowedSubtypes = {GregorianCalendar.class}) -public class CalendarConverter extends TypeConverter { - - @Override - public Long getDBValue(Calendar model) { - return model == null ? null : model.getTimeInMillis(); - } - - @Override - public Calendar getModelValue(Long data) { - if (data != null) { - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(data); - return calendar; - } else { - return null; - } - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/CharConverter.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/CharConverter.java deleted file mode 100644 index f7bf81692..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/CharConverter.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.raizlabs.android.dbflow.converter; - -/** - * Description: Converts a {@link Character} into a {@link String} for database storage. - */ -public class CharConverter extends TypeConverter { - - @Override - public String getDBValue(Character model) { - return model != null ? new String(new char[]{model}) : null; - } - - @Override - public Character getModelValue(String data) { - return data != null ? data.charAt(0) : null; - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/DateConverter.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/DateConverter.java deleted file mode 100644 index 43475b1e0..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/DateConverter.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.raizlabs.android.dbflow.converter; - -import java.util.Date; - -/** - * Author: andrewgrosner - * Description: Defines how we store and retrieve a {@link java.util.Date} - */ -public class DateConverter extends TypeConverter { - - @Override - public Long getDBValue(Date model) { - return model == null ? null : model.getTime(); - } - - @Override - public Date getModelValue(Long data) { - return data == null ? null : new Date(data); - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/SqlDateConverter.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/SqlDateConverter.java deleted file mode 100644 index b1fa0a7b0..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/SqlDateConverter.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.raizlabs.android.dbflow.converter; - -import java.sql.Date; -import java.sql.Time; -import java.sql.Timestamp; - -/** - * Author: andrewgrosner - * Description: Defines how we store and retrieve a {@link java.sql.Date} - */ -@com.raizlabs.android.dbflow.annotation.TypeConverter(allowedSubtypes = {Time.class, Timestamp.class}) -public class SqlDateConverter extends TypeConverter { - - @Override - public Long getDBValue(Date model) { - return model == null ? null : model.getTime(); - } - - @Override - public Date getModelValue(Long data) { - return data == null ? null : new Date(data); - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/TypeConverter.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/TypeConverter.java deleted file mode 100644 index f755ae0b1..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/TypeConverter.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.raizlabs.android.dbflow.converter; - -/** - * Author: andrewgrosner - * Description: This class is responsible for converting the stored database value into the field value in - * a Model. - */ -@com.raizlabs.android.dbflow.annotation.TypeConverter -public abstract class TypeConverter { - - /** - * Converts the ModelClass into a DataClass - * - * @param model this will be called upon syncing - * @return The DataClass value that converts into a SQLite type - */ - public abstract DataClass getDBValue(ModelClass model); - - /** - * Converts a DataClass from the DB into a ModelClass - * - * @param data This will be called when the model is loaded from the DB - * @return The ModelClass value that gets set in a Model that holds the data class. - */ - public abstract ModelClass getModelValue(DataClass data); -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/UUIDConverter.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/UUIDConverter.java deleted file mode 100644 index dc26fbe3d..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/converter/UUIDConverter.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.raizlabs.android.dbflow.converter; - -import java.util.UUID; - -/** - * Description: Responsible for converting a {@link UUID} to a {@link String}. - * - * @author Andrew Grosner (fuzz) - */ -public class UUIDConverter extends TypeConverter { - - @Override - public String getDBValue(UUID model) { - return model != null ? model.toString() : null; - } - - @Override - public UUID getModelValue(String data) { - if (data == null) { - return null; - } - return UUID.fromString(data); - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/data/Blob.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/data/Blob.java deleted file mode 100644 index b879b7ef1..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/data/Blob.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.raizlabs.android.dbflow.data; - -/** - * Description: Provides a way to support blob format data. - */ -public class Blob { - - private byte[] blob; - - public Blob() { - } - - public Blob(byte[] blob) { - this.blob = blob; - } - - /** - * Sets the underlying blob data. - * - * @param blob The set of bytes to use. - */ - public void setBlob(byte[] blob) { - this.blob = blob; - } - - /** - * @return The blob data. - */ - public byte[] getBlob() { - return blob; - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/sql/QueryBuilder.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/sql/QueryBuilder.java deleted file mode 100644 index ec85bbed2..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/sql/QueryBuilder.java +++ /dev/null @@ -1,328 +0,0 @@ -package com.raizlabs.android.dbflow.sql; - -import java.util.List; -import java.util.regex.Pattern; - -/** - * Description: This is used as a wrapper around {@link StringBuilder} in order to provide more - * database focused methods and to assist in generating queries to the DB using our SQL wrappers. - */ -public class QueryBuilder implements Query { - - private static final char QUOTE = '`'; - - private static final Pattern QUOTE_PATTERN = Pattern.compile(QUOTE + ".*" + QUOTE); - - /** - * This query is backed by a {@link StringBuilder} - */ - protected StringBuilder query = new StringBuilder(); - - /** - * Constructs this item with an empty {@link StringBuilder} - */ - public QueryBuilder() { - super(); - } - - /** - * Constructs this class with the specified String - * - * @param object The string to append - */ - public QueryBuilder(Object object) { - append(object); - } - - /** - * Appends a space to this query - * - * @return This instance - */ - public QueryClass appendSpace() { - return append(" "); - } - - /** - * Appends the string with spaces on the front and end of the string - * - * @param object The object to append - * @return This instance - */ - @SuppressWarnings("unchecked") - public QueryClass appendSpaceSeparated(Object object) { - return (QueryClass) appendSpace().append(object).appendSpace(); - } - - /** - * Appends the string as (string) - * - * @param string The string to append - * @return This instance - */ - @SuppressWarnings("unchecked") - public QueryClass appendParenthesisEnclosed(Object string) { - return (QueryClass) append("(").append(string).append(")"); - } - - /** - * Appends an object to this query - * - * @param object The object to append - * @return This instance - */ - public QueryClass append(Object object) { - query.append(object); - return castThis(); - } - - /** - * Appends the object only if its not null - * - * @param object If not null, its string representation. - * @return This instance - */ - public QueryClass appendOptional(Object object) { - if (object != null) { - append(object); - } - return castThis(); - } - - /** - * Casts the current object to the {@link QueryClass} - * - * @return This casted instance - */ - @SuppressWarnings("unchecked") - protected QueryClass castThis() { - return (QueryClass) this; - } - - /** - * Appends an {@link SQLiteType} to this query based on the class - * passed in. - * - * @param type The Class to look up from {@link SQLiteType} - * @return This instance - */ - public QueryClass appendType(String type) { - return appendSQLiteType(SQLiteType.get(type)); - } - - /** - * Appends the {@link SQLiteType} to this query - * - * @param sqLiteType The {@link SQLiteType} to append - * @return This instance - */ - public QueryClass appendSQLiteType(SQLiteType sqLiteType) { - return append(sqLiteType.name()); - } - - /** - * Appends an array of these objects by joining them with a comma with - * {@link #join(CharSequence, Object[])} - * - * @param objects The array of objects to pass in - * @return This instance - */ - public QueryClass appendArray(Object... objects) { - return append(join(", ", objects)); - } - - /** - * Appends a list of objects by joining them with a comma with - * {@link #join(CharSequence, Iterable)} - * - * @param objects The list of objects to pass in - * @return This instance - */ - public QueryClass appendList(List> objects) { - return append(join(", ", objects)); - } - - /** - * Appends a value only if it's not empty or null - * - * @param name The name of the qualifier - * @param value The value to append after the name - * @return This instance - */ - public QueryClass appendQualifier(String name, String value) { - if (value != null && value.length() > 0) { - if (name != null) { - append(name); - } - appendSpaceSeparated(value); - } - return castThis(); - } - - /** - * Only appends the text if it is not null or empty - * - * @param string The string to append - * @return This instance - */ - public QueryClass appendNotEmpty(String string) { - if (string != null && !string.isEmpty()) { - append(string); - } - return castThis(); - } - - /** - * Appends a quoted string. If the string is the all symbol '*', we do not quote it. - * - * @param string The string to append - * @return This instance - */ - @SuppressWarnings("unchecked") - public QueryClass appendQuoted(String string) { - if (string.equals("*")) - return append(string); - - append(quote(string)); - return castThis(); - } - - /** - * Appends a quoted string if needed. If the string is the all symbol '*', we do not quote it. - * - * @param string The string to append - * @return This instance - */ - @SuppressWarnings("unchecked") - public QueryClass appendQuotedIfNeeded(String string) { - if (string.equals("*")) - return append(string); - - append(quoteIfNeeded(string)); - return castThis(); - } - - /** - * Appends a list of objects by quoting and joining them with a comma with - * {@link #join(CharSequence, Iterable)} - * - * @param objects The list of objects to pass in - * @return This instance - */ - @SuppressWarnings("unchecked") - public QueryClass appendQuotedList(List> objects) { - return appendQuoted(join("`, `", objects)); - } - - /** - * Appends an array of these objects by quoting and joining them with a comma with - * {@link #join(CharSequence, Object[])} - * - * @param objects The array of objects to pass in - * @return This instance - */ - public QueryClass appendQuotedArray(Object... objects) { - return appendQuoted(join("`, `", objects)); - } - - @Override - public String toString() { - return getQuery(); - } - - @Override - public String getQuery() { - return query.toString(); - } - - /** - * @param columnName The column name to use. - * @return A name in quotes. E.G. index => `index` so we can use keywords as column names without fear - * of clashing. - */ - public static String quote(String columnName) { - return QUOTE + columnName.replace(".", "`.`") + QUOTE; - } - - /** - * Quotes the identifier if its not already quoted. - * - * @param name The name of the column or table. - * @return Quoted only once. - */ - public static String quoteIfNeeded(String name) { - if (name != null && !isQuoted(name)) { - return quote(name); - } else { - return name; - } - } - - /** - * Helper method to check if name is quoted. - * - * @param name The name of a column or table. - * @return true if the name is quoted. We may not want to quote something if its already so. - */ - public static boolean isQuoted(String name) { - return (QUOTE_PATTERN.matcher(name).find()); - } - - /** - * Strips quotes out of a identifier if need to do so. - * - * @param name The name ot strip the quotes from. - * @return A non-quoted name. - */ - public static String stripQuotes(String name) { - String ret = name; - if (ret != null && isQuoted(ret)) { - ret = ret.replace("`", ""); - } - return ret; - } - - /** - * Returns a string containing the tokens joined by delimiters. - * - * @param delimiter The text to join the text with. - * @param tokens an array objects to be joined. Strings will be formed from - * the objects by calling object.toString(). - * @return A joined string - */ - public static String join(CharSequence delimiter, Object[] tokens) { - StringBuilder sb = new StringBuilder(); - boolean firstTime = true; - for (Object token : tokens) { - if (firstTime) { - firstTime = false; - } else { - sb.append(delimiter); - } - sb.append(token); - } - return sb.toString(); - } - - /** - * Returns a string containing the tokens joined by delimiters. - * - * @param delimiter The text to join the text with. - * @param tokens an array objects to be joined. Strings will be formed from - * the objects by calling object.toString(). - * @return A joined string - */ - public static String join(CharSequence delimiter, Iterable tokens) { - StringBuilder sb = new StringBuilder(); - boolean firstTime = true; - for (Object token : tokens) { - if (firstTime) { - firstTime = false; - } else { - sb.append(delimiter); - } - sb.append(token); - } - return sb.toString(); - } -} diff --git a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/sql/SQLiteType.java b/dbflow-core/src/main/java/com/raizlabs/android/dbflow/sql/SQLiteType.java deleted file mode 100644 index be56fa2af..000000000 --- a/dbflow-core/src/main/java/com/raizlabs/android/dbflow/sql/SQLiteType.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.raizlabs.android.dbflow.sql; - -import com.raizlabs.android.dbflow.data.Blob; - -import java.util.HashMap; -import java.util.Map; - -/** - * Description: Represents a type that SQLite understands. - */ -public enum SQLiteType { - - /** - * Represents an integer number in the DB. - */ - INTEGER, - - /** - * Represents a floating-point, precise number. - */ - REAL, - - /** - * Represents text. - */ - TEXT, - - /** - * A column defined by {@link byte[]} data. Usually reserved for images or larger pieces of content. - */ - BLOB; - - private static final Map sTypeMap = new HashMap () { - { - put(byte.class.getName(), SQLiteType.INTEGER); - put(short.class.getName(), SQLiteType.INTEGER); - put(int.class.getName(), SQLiteType.INTEGER); - put(long.class.getName(), SQLiteType.INTEGER); - put(float.class.getName(), SQLiteType.REAL); - put(double.class.getName(), SQLiteType.REAL); - put(boolean.class.getName(), SQLiteType.INTEGER); - put(char.class.getName(), SQLiteType.TEXT); - put(byte[].class.getName(), SQLiteType.BLOB); - put(Byte.class.getName(), SQLiteType.INTEGER); - put(Short.class.getName(), SQLiteType.INTEGER); - put(Integer.class.getName(), SQLiteType.INTEGER); - put(Long.class.getName(), SQLiteType.INTEGER); - put(Float.class.getName(), SQLiteType.REAL); - put(Double.class.getName(), SQLiteType.REAL); - put(Boolean.class.getName(), SQLiteType.INTEGER); - put(Character.class.getName(), SQLiteType.TEXT); - put(CharSequence.class.getName(), SQLiteType.TEXT); - put(String.class.getName(), SQLiteType.TEXT); - put(Byte[].class.getName(), SQLiteType.BLOB); - put(Blob.class.getName(), SQLiteType.BLOB); - } - }; - - /** - * Returns the {@link SQLiteType} for this class - * - * @param className The fully qualified class name - * @return The type from the class name - */ - public static SQLiteType get(String className) { - return sTypeMap.get(className); - } - - public static boolean containsClass(String className) { - return sTypeMap.containsKey(className); - } -} diff --git a/dbflow-kotlinextensions/build.gradle b/dbflow-kotlinextensions/build.gradle deleted file mode 100644 index 4de4f19a1..000000000 --- a/dbflow-kotlinextensions/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' - -project.ext.artifactId = bt_name - - -android { - compileSdkVersion Integer.valueOf(dbflow_target_sdk) - buildToolsVersion dbflow_build_tools_version - - defaultConfig { - minSdkVersion dbflow_min_sdk - targetSdkVersion Integer.valueOf(dbflow_target_sdk) - } - buildTypes { - debug { - minifyEnabled false - } - release { - minifyEnabled false - } - } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } -} - -dependencies { - api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api project("${dbflow_project_prefix}dbflow-core") - api project("${dbflow_project_prefix}dbflow") -} - -apply from: '../kotlin-artifacts.gradle' - - diff --git a/dbflow-kotlinextensions/gradle.properties b/dbflow-kotlinextensions/gradle.properties deleted file mode 100644 index bca645ff5..000000000 --- a/dbflow-kotlinextensions/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -bt_name=dbflow-kotlinextensions -bt_packaging=aar -bt_artifact_id=dbflow-kotlinextensions \ No newline at end of file diff --git a/dbflow-kotlinextensions/proguard-rules.pro b/dbflow-kotlinextensions/proguard-rules.pro deleted file mode 100644 index d31a3fb13..000000000 --- a/dbflow-kotlinextensions/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /Users/andrewgrosner/Documents/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/dbflow-kotlinextensions/src/main/AndroidManifest.xml b/dbflow-kotlinextensions/src/main/AndroidManifest.xml deleted file mode 100644 index e1050c1a7..000000000 --- a/dbflow-kotlinextensions/src/main/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/DatabaseExtensions.kt b/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/DatabaseExtensions.kt deleted file mode 100644 index 5c37b9ed4..000000000 --- a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/DatabaseExtensions.kt +++ /dev/null @@ -1,103 +0,0 @@ -package com.raizlabs.android.dbflow.kotlinextensions - -import android.content.ContentValues -import com.raizlabs.android.dbflow.config.DatabaseDefinition -import com.raizlabs.android.dbflow.config.FlowManager.* -import com.raizlabs.android.dbflow.structure.Model -import com.raizlabs.android.dbflow.structure.ModelAdapter -import com.raizlabs.android.dbflow.structure.ModelViewAdapter -import com.raizlabs.android.dbflow.structure.QueryModelAdapter -import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper -import com.raizlabs.android.dbflow.structure.database.transaction.FastStoreModelTransaction.* -import com.raizlabs.android.dbflow.structure.database.transaction.ProcessModelTransaction -import com.raizlabs.android.dbflow.structure.database.transaction.ProcessModelTransaction.ProcessModel -import com.raizlabs.android.dbflow.structure.database.transaction.Transaction - -typealias ProcessFunction- - = (T, DatabaseWrapper) -> Unit - -/** - * Easily get access to its [DatabaseDefinition] directly. - */ -inline fun database() = getDatabase(T::class.java) - -inline fun writableDatabaseForTable() = getWritableDatabaseForTable(T::class.java) - -/** - * Easily get access to its [DatabaseDefinition] directly. - */ -inline fun databaseForTable() = getDatabaseForTable(T::class.java) - -/** - * Easily get its table name. - */ -inline fun tableName() = getTableName(T::class.java) - -/** - * Easily get its [ModelAdapter]. - */ -inline fun modelAdapter() = getModelAdapter(T::class.java) - -/** - * Easily get its [QueryModelAdapter]. - */ -inline fun queryModelAdapter() = getQueryModelAdapter(T::class.java) - -/** - * Easily get its [ModelViewAdapter] - */ -inline fun modelViewAdapter() = getModelViewAdapter(T::class.java) - -/** - * Enables a collection of T objects to easily operate on them within a synchronous database transaction. - */ -inline fun Collection .processInTransaction( - crossinline processFunction: ProcessFunction ) { - databaseForTable ().executeTransaction { db -> forEach { processFunction(it, db) } } -} - -/** - * Places the [Collection] of items on the [ITransactionQueue]. Use the [processFunction] to perform - * an action on each individual [Model]. This happens on a non-UI thread. - */ -inline fun Collection .processInTransactionAsync( - crossinline processFunction: ProcessFunction , - success: Transaction.Success? = null, - error: Transaction.Error? = null, - processListener: ProcessModelTransaction.OnModelProcessListener ? = null) { - databaseForTable ().beginTransactionAsync( - this.processTransaction(processFunction) - .processListener(processListener).build()) - .success(success).error(error).execute() -} - -inline fun Collection .processTransaction( - crossinline processFunction: ProcessFunction ): ProcessModelTransaction.Builder { - return ProcessModelTransaction.Builder (ProcessModel { model, wrapper -> processFunction(model, wrapper) }).addAll(this) -} - -inline fun Collection .fastSave() = saveBuilder(modelAdapter ()).addAll(this) - -inline fun Collection .fastInsert() = insertBuilder(modelAdapter ()).addAll(this) - -inline fun Collection .fastUpdate() = updateBuilder(modelAdapter ()).addAll(this) - -operator fun ContentValues.set(key: String, value: String?) = put(key, value) - -operator fun ContentValues.set(key: String, value: Byte?) = put(key, value) - -operator fun ContentValues.set(key: String, value: Short?) = put(key, value) - -operator fun ContentValues.set(key: String, value: Int?) = put(key, value) - -operator fun ContentValues.set(key: String, value: Long?) = put(key, value) - -operator fun ContentValues.set(key: String, value: Float?) = put(key, value) - -operator fun ContentValues.set(key: String, value: Double?) = put(key, value) - -operator fun ContentValues.set(key: String, value: Boolean?) = put(key, value) - -operator fun ContentValues.set(key: String, value: ByteArray?) = put(key, value) - - - diff --git a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/FlowListExtensions.kt b/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/FlowListExtensions.kt deleted file mode 100644 index 406affaea..000000000 --- a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/FlowListExtensions.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.raizlabs.android.dbflow.kotlinextensions - -import com.raizlabs.android.dbflow.list.IFlowCursorIterator - -operator fun IFlowCursorIterator .get(i: Long): TModel = this.getItem(i) ?: throw IndexOutOfBoundsException("Could not find item at index $i from the cursor.") - -operator fun IFlowCursorIterator .get(i: Int): TModel = this.getItem(i.toLong()) ?: throw IndexOutOfBoundsException("Could not find item at index $i from the cursor.") - - diff --git a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/ModelExtensions.kt b/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/ModelExtensions.kt deleted file mode 100644 index d136fe9b5..000000000 --- a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/ModelExtensions.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.raizlabs.android.dbflow.kotlinextensions - -import com.raizlabs.android.dbflow.structure.AsyncModel -import com.raizlabs.android.dbflow.structure.database.DatabaseWrapper - -inline fun T.save(databaseWrapper: DatabaseWrapper = writableDatabaseForTable ()) = modelAdapter ().save(this, databaseWrapper) - -inline fun T.insert(databaseWrapper: DatabaseWrapper = writableDatabaseForTable ()) = modelAdapter ().insert(this, databaseWrapper) - -inline fun T.update(databaseWrapper: DatabaseWrapper = writableDatabaseForTable ()) = modelAdapter ().update(this, databaseWrapper) - -inline fun T.delete(databaseWrapper: DatabaseWrapper = writableDatabaseForTable ()) = modelAdapter ().delete(this, databaseWrapper) - -inline fun T.exists(databaseWrapper: DatabaseWrapper = writableDatabaseForTable ()) = modelAdapter ().exists(this, databaseWrapper) - -inline fun T.async() = AsyncModel(this) \ No newline at end of file diff --git a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/NameAliasExtensions.kt b/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/NameAliasExtensions.kt deleted file mode 100644 index 915e4917b..000000000 --- a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/NameAliasExtensions.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.raizlabs.android.dbflow.kotlinextensions - -import com.raizlabs.android.dbflow.sql.language.NameAlias - -val String.nameAlias - get() = NameAlias.of(this) - -fun String.`as`(alias: String? = null) = NameAlias.of(this, alias) - diff --git a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/OperatorExtensions.kt b/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/OperatorExtensions.kt deleted file mode 100644 index aeadca011..000000000 --- a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/OperatorExtensions.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.raizlabs.android.dbflow.kotlinextensions - -import com.raizlabs.android.dbflow.annotation.Collate -import com.raizlabs.android.dbflow.sql.language.NameAlias -import com.raizlabs.android.dbflow.sql.language.Operator -import com.raizlabs.android.dbflow.sql.language.OperatorGroup -import com.raizlabs.android.dbflow.sql.language.OperatorGroup.clause -import com.raizlabs.android.dbflow.sql.language.SQLOperator - -fun SQLOperator.clause() = OperatorGroup.clause(this) - -fun NameAlias.op() = Operator.op (this) - -fun String.op(): Operator = nameAlias.op () - -infix fun Operator .collate(collation: Collate) = collate(collation) - -infix fun Operator .collate(collation: String) = collate(collation) - -infix fun Operator .postfix(collation: String) = postfix(collation) - -infix fun Operator.Between .and(value: T?) = and(value) - -infix fun Operator.In .and(value: T?) = and(value) - -infix fun Operator .and(sqlOperator: SQLOperator) = clause(this).and(sqlOperator) - -infix fun Operator .or(sqlOperator: SQLOperator) = clause(this).or(sqlOperator) - -infix fun Operator .andAll(sqlOperator: Collection ) = clause(this).andAll(sqlOperator) - -infix fun Operator .orAll(sqlOperator: Collection ) = clause(this).orAll(sqlOperator) - -infix fun OperatorGroup.and(sqlOperator: SQLOperator) = and(sqlOperator) - -infix fun OperatorGroup.or(sqlOperator: SQLOperator) = or(sqlOperator) - -infix fun OperatorGroup.and(sqlOperator: OperatorGroup) = clause().and(sqlOperator) - -infix fun OperatorGroup.or(sqlOperator: OperatorGroup) = clause().or(sqlOperator) diff --git a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/PropertyExtensions.kt b/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/PropertyExtensions.kt deleted file mode 100644 index 59b4f4162..000000000 --- a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/PropertyExtensions.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.raizlabs.android.dbflow.kotlinextensions - -import com.raizlabs.android.dbflow.sql.language.property.Property -import com.raizlabs.android.dbflow.sql.language.property.PropertyFactory.from -import com.raizlabs.android.dbflow.sql.queriable.ModelQueriable -import kotlin.reflect.KClass - -/** - * Description: Provides some very nice Property class extensions. - */ - -val Int.property - get() = from(this) - -val Char.property - get() = from(this) - -val Double.property - get() = from(this) - -val Long.property - get() = from(this) - -val Float.property - get() = from(this) - -val Short.property - get() = from(this) - -val Byte.property - get() = from(this) - -val T?.property - get() = from(this) - -val ModelQueriable .property - get() = from(this) - -inline fun propertyString(stringRepresentation: String?) = from(T::class.java, stringRepresentation) - -inline fun KClass .allProperty() = Property.allProperty(this.java) \ No newline at end of file diff --git a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/PropertyMethodExtensions.kt b/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/PropertyMethodExtensions.kt deleted file mode 100644 index 31b3d8bff..000000000 --- a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/PropertyMethodExtensions.kt +++ /dev/null @@ -1,124 +0,0 @@ -package com.raizlabs.android.dbflow.kotlinextensions - -import com.raizlabs.android.dbflow.sql.language.BaseModelQueriable -import com.raizlabs.android.dbflow.sql.language.IConditional -import com.raizlabs.android.dbflow.sql.language.Operator -import com.raizlabs.android.dbflow.sql.language.Operator.Between -import com.raizlabs.android.dbflow.sql.language.property.Property - -/** - * Description: Provides property methods in via infix functions. - */ - -infix fun Property .eq(value: T?) = this.eq(value) - -infix fun Property .`is`(value: T?) = this.`is`(value) - -infix fun Property .isNot(value: T?) = this.isNot(value) - -infix fun Property .notEq(value: T?) = this.notEq(value) - -infix fun Property .like(value: String) = this.like(value) - -infix fun Property .glob(value: String) = this.glob(value) - -infix fun Property .greaterThan(value: T) = this.greaterThan(value) - -infix fun Property .greaterThanOrEq(value: T) = this.greaterThanOrEq(value) - -infix fun Property .lessThan(value: T) = this.lessThan(value) - -infix fun Property .lessThanOrEq(value: T) = this.lessThanOrEq(value) - -infix fun Property .between(value: T) = this.between(value) - -infix fun Property .`in`(values: Array ): Operator.In { - return when (values.size) { - 1 -> `in`(values[0]) - else -> this.`in`(values[0], *values.sliceArray(IntRange(1, values.size))) - } -} - -infix fun Property .notIn(values: Array ): Operator.In { - return when (values.size) { - 1 -> notIn(values[0]) - else -> this.notIn(values[0], *values.sliceArray(IntRange(1, values.size))) - } -} - -infix fun Property .`in`(values: Collection ) = this.`in`(values) - -infix fun Property .notIn(values: Collection ) = this.notIn(values) - -infix fun Property .concatenate(value: T) = this.concatenate(value) - -infix fun IConditional.eq(value: IConditional): Operator<*> = this.eq(value) - -infix fun IConditional.`is`(conditional: IConditional): Operator<*> = this.`is`(conditional) - -infix fun IConditional.isNot(conditional: IConditional): Operator<*> = this.isNot(conditional) - -infix fun IConditional.notEq(conditional: IConditional): Operator<*> = this.notEq(conditional) - -infix fun IConditional.like(conditional: IConditional): Operator<*> = this.like(conditional) - -infix fun IConditional.glob(conditional: IConditional): Operator<*> = this.glob(conditional) - -infix fun IConditional.like(value: String): Operator<*> = this.like(value) - -infix fun IConditional.glob(value: String): Operator<*> = this.glob(value) - -infix fun IConditional.greaterThan(conditional: IConditional): Operator<*> = this.greaterThan(conditional) - -infix fun IConditional.greaterThanOrEq(conditional: IConditional): Operator<*> = this.greaterThanOrEq(conditional) - -infix fun IConditional.lessThan(conditional: IConditional): Operator<*> = this.lessThan(conditional) - -infix fun IConditional.lessThanOrEq(conditional: IConditional): Operator<*> = this.lessThanOrEq(conditional) - -infix fun IConditional.between(conditional: IConditional): Between<*> = this.between(conditional) - -infix fun IConditional.`in`(values: Array ): Operator.In<*> { - return when (values.size) { - 1 -> `in`(values[0]) - else -> this.`in`(values[0], *values.sliceArray(IntRange(1, values.size))) - } -} - -infix fun IConditional.notIn(values: Array ): Operator.In<*> { - return when (values.size) { - 1 -> notIn(values[0]) - else -> this.notIn(values[0], *values.sliceArray(IntRange(1, values.size))) - } -} - -infix fun IConditional.`is`(baseModelQueriable: BaseModelQueriable ): Operator<*> = this.`is`(baseModelQueriable) - -infix fun IConditional.eq(baseModelQueriable: BaseModelQueriable ): Operator<*> = this.eq(baseModelQueriable) - -infix fun IConditional.isNot(baseModelQueriable: BaseModelQueriable ): Operator<*> = this.isNot(baseModelQueriable) -infix fun IConditional.notEq(baseModelQueriable: BaseModelQueriable ): Operator<*> = this.notEq(baseModelQueriable) -infix fun IConditional.like(baseModelQueriable: BaseModelQueriable ): Operator<*> = this.like(baseModelQueriable) -infix fun IConditional.glob(baseModelQueriable: BaseModelQueriable ): Operator<*> = this.glob(baseModelQueriable) -infix fun IConditional.greaterThan(baseModelQueriable: BaseModelQueriable ): Operator<*> = this.greaterThan(baseModelQueriable) -infix fun IConditional.greaterThanOrEq(baseModelQueriable: BaseModelQueriable ): Operator<*> = this.greaterThanOrEq(baseModelQueriable) -infix fun IConditional.lessThan(baseModelQueriable: BaseModelQueriable ): Operator<*> = this.lessThan(baseModelQueriable) -infix fun IConditional.lessThanOrEq(baseModelQueriable: BaseModelQueriable ): Operator<*> = this.lessThanOrEq(baseModelQueriable) -infix fun IConditional.between(baseModelQueriable: BaseModelQueriable ): Between<*> = this.between(baseModelQueriable) - -infix fun IConditional.`in`(values: Array >): Operator.In<*> { - return when (values.size) { - 1 -> `in`(values[0]) - else -> this.`in`(values[0], *values.sliceArray(IntRange(1, values.size))) - } -} - -infix fun IConditional.notIn(values: Array >): Operator.In<*> { - return when (values.size) { - 1 -> notIn(values[0]) - else -> this.notIn(values[0], *values.sliceArray(IntRange(1, values.size))) - } -} - -infix fun IConditional.concatenate(conditional: IConditional): Operator<*> = this.concatenate(conditional) - diff --git a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/QueryExtensions.kt b/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/QueryExtensions.kt deleted file mode 100644 index a4a84ee10..000000000 --- a/dbflow-kotlinextensions/src/main/java/com/raizlabs/android/dbflow/kotlinextensions/QueryExtensions.kt +++ /dev/null @@ -1,266 +0,0 @@ -package com.raizlabs.android.dbflow.kotlinextensions - -import com.raizlabs.android.dbflow.annotation.Collate -import com.raizlabs.android.dbflow.sql.Query -import com.raizlabs.android.dbflow.sql.language.BaseModelQueriable -import com.raizlabs.android.dbflow.sql.language.Case -import com.raizlabs.android.dbflow.sql.language.CaseCondition -import com.raizlabs.android.dbflow.sql.language.CompletedTrigger -import com.raizlabs.android.dbflow.sql.language.CursorResult -import com.raizlabs.android.dbflow.sql.language.From -import com.raizlabs.android.dbflow.sql.language.Index -import com.raizlabs.android.dbflow.sql.language.Insert -import com.raizlabs.android.dbflow.sql.language.Join -import com.raizlabs.android.dbflow.sql.language.NameAlias -import com.raizlabs.android.dbflow.sql.language.OrderBy -import com.raizlabs.android.dbflow.sql.language.SQLOperator -import com.raizlabs.android.dbflow.sql.language.SQLite -import com.raizlabs.android.dbflow.sql.language.Select -import com.raizlabs.android.dbflow.sql.language.Set -import com.raizlabs.android.dbflow.sql.language.Transformable -import com.raizlabs.android.dbflow.sql.language.Trigger -import com.raizlabs.android.dbflow.sql.language.TriggerMethod -import com.raizlabs.android.dbflow.sql.language.Update -import com.raizlabs.android.dbflow.sql.language.Where -import com.raizlabs.android.dbflow.sql.language.property.IProperty -import com.raizlabs.android.dbflow.sql.queriable.AsyncQuery -import com.raizlabs.android.dbflow.sql.queriable.ModelQueriable -import com.raizlabs.android.dbflow.sql.queriable.Queriable -import com.raizlabs.android.dbflow.structure.AsyncModel -import com.raizlabs.android.dbflow.structure.Model -import com.raizlabs.android.dbflow.structure.database.transaction.QueryTransaction -import kotlin.reflect.KClass - -/** - * Description: A file containing extensions for adding query syntactic sugar. - */ - -inline val select: Select - get() = SQLite.select() - -inline fun Select.from() = from(T::class.java) - -fun delete(modelClass: KClass ) = SQLite.delete(modelClass.java) - -infix fun Select.from(modelClass: KClass ) = from(modelClass.java) - -infix fun From .whereExists(where: Where ) = where().exists(where) - -infix fun