diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 2ad4c337b..3b59e12fd 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -5,10 +5,10 @@ This document provides general guidelines about how to contribute to the project ## Reporting issues -* Use [github issues](https://github.com/Raizlabs/DBFlow/issues) to report a bug. +* Use [github issues](https://github.com/agrosner/DBFlow/issues) to report a bug. * Before creating a new issue: - * Make sure you are using the [latest release](https://github.com/Raizlabs/DBFlow/releases). - * Check if the issue was [already reported or fixed](https://github.com/Raizlabs/DBFlow/issues?utf8=%E2%9C%93&q=is%3Aissue). Notice that it may not be released yet. + * Make sure you are using the [latest release](https://github.com/agrosner/DBFlow/releases). + * Check if the issue was [already reported or fixed](https://github.com/agrosner/DBFlow/issues?utf8=%E2%9C%93&q=is%3Aissue). Notice that it may not be released yet. * If you found a match add the github "+1" reaction brief comment. This helps prioritize the issues addressing the most common and critical ones first. If possible, add additional information to help us reproduce, and find the issue. Please use your best judgement. * Reporting issues: * Please include the following information to help maintainers to fix the problem faster: @@ -45,6 +45,6 @@ I welcome and encourage all pull requests. It usually will take me within 24-48 We would love to hear your ideas and make discussions about it. * Use github issues to make feature proposals. -* We use `type: feature request` label to mark all [feature request issues](https://github.com/Raizlabs/DBFlow/labels/type%3A%20feature%20request). +* We use `type: feature request` label to mark all [feature request issues](https://github.com/agrosner/DBFlow/labels/type%3A%20feature%20request). * Before submitting your proposal make sure there is no similar feature request. If you find a match, feel free to join the discussion or just or just act with a reaction if you think the feature is worth implementing. * Be as specific as possible providing a precise explanation of the feature so anyone can understand the problem and the benefits of solving it. \ No newline at end of file diff --git a/README.md b/README.md index a7cc9349b..31d582d6f 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ Supports: **Kotlin:** Built using the language, the library is super-concise, null-safe and efficient. +**Coroutines:** Adds coroutine support for queries. + **RX Java:** Enable applications to be reactive by listening to DB changes and ensuring your subscribers are up-to-date. **Paging:** Android architecture component paging library support for queries via `QueryDataSource`. @@ -61,7 +63,7 @@ Add artifacts to your project: // core set of libraries compile "com.github.agrosner.dbflow:core:${dbflow_version}" - compile "com.github.agrosner.dbflow:dbflow:${dbflow_version}" + compile "com.github.agrosner.dbflow:lib:${dbflow_version}" // sql-cipher database encryption (optional) compile "com.github.agrosner.dbflow:sqlcipher:${dbflow_version}" diff --git a/contentprovider/.gitignore b/contentprovider/.gitignore new file mode 100644 index 000000000..796b96d1c --- /dev/null +++ b/contentprovider/.gitignore @@ -0,0 +1 @@ +/build diff --git a/contentprovider/build.gradle b/contentprovider/build.gradle new file mode 100644 index 000000000..23fa310f7 --- /dev/null +++ b/contentprovider/build.gradle @@ -0,0 +1,36 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + +project.ext.artifactId = bt_name + +android { + compileSdkVersion target_sdk + + defaultConfig { + minSdkVersion min_sdk + targetSdkVersion target_sdk + } + + lintOptions { + abortOnError false + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } +} + +dependencies { + api project(':core') + api project(':lib') + api "com.android.support:support-annotations:27.1.1" + api "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" +} + +apply from: '../kotlin-artifacts.gradle' + diff --git a/contentprovider/gradle.properties b/contentprovider/gradle.properties new file mode 100644 index 000000000..1802744c1 --- /dev/null +++ b/contentprovider/gradle.properties @@ -0,0 +1,3 @@ +bt_name=contentprovider +bt_packaging=aar +bt_artifact_id=contentprovider \ No newline at end of file diff --git a/contentprovider/proguard-rules.pro b/contentprovider/proguard-rules.pro new file mode 100644 index 000000000..f1b424510 --- /dev/null +++ b/contentprovider/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# 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 *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/contentprovider/src/main/AndroidManifest.xml b/contentprovider/src/main/AndroidManifest.xml new file mode 100644 index 000000000..2f5f61755 --- /dev/null +++ b/contentprovider/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/BaseContentProvider.kt b/contentprovider/src/main/java/com/dbflow5/provider/BaseContentProvider.kt similarity index 79% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/BaseContentProvider.kt rename to contentprovider/src/main/java/com/dbflow5/provider/BaseContentProvider.kt index 70dd20fc2..ade63b741 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/BaseContentProvider.kt +++ b/contentprovider/src/main/java/com/dbflow5/provider/BaseContentProvider.kt @@ -1,16 +1,16 @@ -package com.raizlabs.dbflow5.provider +package com.dbflow5.provider import android.content.ContentProvider import android.content.ContentValues import android.net.Uri -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.DatabaseHolder -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.transaction.ITransaction +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.DatabaseHolder +import com.dbflow5.config.FlowManager +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.transaction.ITransaction /** - * Description: The base provider class that [com.raizlabs.android.dbflow5.annotation.provider.ContentProvider] + * Description: The base provider class that [com.dbflow5.annotation.provider.ContentProvider] * extend when generated. */ abstract class BaseContentProvider diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/BaseProviderModel.kt b/contentprovider/src/main/java/com/dbflow5/provider/BaseProviderModel.kt similarity index 83% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/BaseProviderModel.kt rename to contentprovider/src/main/java/com/dbflow5/provider/BaseProviderModel.kt index 7ed49524d..aa66e711a 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/BaseProviderModel.kt +++ b/contentprovider/src/main/java/com/dbflow5/provider/BaseProviderModel.kt @@ -1,12 +1,12 @@ -package com.raizlabs.dbflow5.provider +package com.dbflow5.provider import android.content.ContentProvider -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.OperatorGroup -import com.raizlabs.dbflow5.structure.BaseModel -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.config.FlowManager +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.OperatorGroup +import com.dbflow5.structure.BaseModel +import com.dbflow5.structure.Model /** * Description: Provides a base implementation of a [Model] backed @@ -40,7 +40,7 @@ abstract class BaseProviderModel : BaseModel(), ModelProvider { */ override fun exists(wrapper: DatabaseWrapper): Boolean { val cursor = ContentUtils.query(FlowManager.context.contentResolver, - queryUri, modelAdapter.getPrimaryConditionClause(this), "") + queryUri, modelAdapter.getPrimaryConditionClause(this), "") val exists = cursor != null && cursor.count > 0 cursor?.close() return exists @@ -52,7 +52,7 @@ abstract class BaseProviderModel : BaseModel(), ModelProvider { wrapper: DatabaseWrapper, vararg columns: String?): T? { val cursor = ContentUtils.query(FlowManager.context.contentResolver, - queryUri, whereOperatorGroup, orderBy, *columns) + queryUri, whereOperatorGroup, orderBy, *columns) if (cursor != null) { val flowCursor = FlowCursor.from(cursor) if (flowCursor.moveToFirst()) { diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/BaseSyncableProviderModel.kt b/contentprovider/src/main/java/com/dbflow5/provider/BaseSyncableProviderModel.kt similarity index 83% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/BaseSyncableProviderModel.kt rename to contentprovider/src/main/java/com/dbflow5/provider/BaseSyncableProviderModel.kt index 4ef41c4f0..4f3b9a925 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/BaseSyncableProviderModel.kt +++ b/contentprovider/src/main/java/com/dbflow5/provider/BaseSyncableProviderModel.kt @@ -1,12 +1,12 @@ -package com.raizlabs.dbflow5.provider +package com.dbflow5.provider import android.content.ContentProvider -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.OperatorGroup -import com.raizlabs.dbflow5.structure.BaseModel -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.config.FlowManager +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.OperatorGroup +import com.dbflow5.structure.BaseModel +import com.dbflow5.structure.Model /** * Description: Provides a base implementation of a [Model] backed @@ -40,7 +40,7 @@ abstract class BaseSyncableProviderModel : BaseModel(), ModelProvider { wrapper: DatabaseWrapper, vararg columns: String?): T? { val cursor = ContentUtils.query(FlowManager.context.contentResolver, - queryUri, whereOperatorGroup, orderBy, *columns) + queryUri, whereOperatorGroup, orderBy, *columns) cursor?.let { val flowCursor = FlowCursor.from(cursor) if (flowCursor.moveToFirst()) { diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/ContentUtils.kt b/contentprovider/src/main/java/com/dbflow5/provider/ContentUtils.kt similarity index 92% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/ContentUtils.kt rename to contentprovider/src/main/java/com/dbflow5/provider/ContentUtils.kt index e40aa2733..893f5ee26 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/ContentUtils.kt +++ b/contentprovider/src/main/java/com/dbflow5/provider/ContentUtils.kt @@ -1,17 +1,17 @@ -package com.raizlabs.dbflow5.provider +package com.dbflow5.provider import android.content.ContentResolver import android.content.ContentValues import android.content.Context import android.net.Uri -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.annotation.provider.ContentProvider -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.config.modelAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.Operator -import com.raizlabs.dbflow5.query.OperatorGroup +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.annotation.provider.ContentProvider +import com.dbflow5.config.FlowLog +import com.dbflow5.config.modelAdapter +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.Operator +import com.dbflow5.query.OperatorGroup /** * Description: Provides handy wrapper mechanisms for [android.content.ContentProvider] @@ -32,7 +32,7 @@ object ContentUtils { */ @JvmStatic fun buildUriWithAuthority(authority: String, vararg paths: String): Uri = - buildUri(BASE_CONTENT_URI, authority, *paths) + buildUri(BASE_CONTENT_URI, authority, *paths) /** * Constructs an Uri with the specified baseContent uri and authority. Add paths to append to the Uri. @@ -61,7 +61,7 @@ object ContentUtils { */ @JvmStatic fun insert(context: Context, insertUri: Uri, model: TableClass): Uri? = - insert(context.contentResolver, insertUri, model) + insert(context.contentResolver, insertUri, model) /** * Inserts the model into the [android.content.ContentResolver]. Uses the insertUri to resolve @@ -129,7 +129,7 @@ object ContentUtils { bulkInsertUri: Uri, table: Class, models: List): Int = - bulkInsert(context.contentResolver, bulkInsertUri, table, models) + bulkInsert(context.contentResolver, bulkInsertUri, table, models) /** * Updates the model through the [android.content.ContentResolver]. Uses the updateUri to @@ -143,7 +143,7 @@ object ContentUtils { fun update(context: Context, updateUri: Uri, model: TableClass): Int = - update(context.contentResolver, updateUri, model) + update(context.contentResolver, updateUri, model) /** * Updates the model through the [android.content.ContentResolver]. Uses the updateUri to @@ -179,7 +179,7 @@ object ContentUtils { */ @JvmStatic fun delete(context: Context, deleteUri: Uri, model: TableClass): Int = - delete(context.contentResolver, deleteUri, model) + delete(context.contentResolver, deleteUri, model) /** * Deletes the specified model through the [android.content.ContentResolver]. Uses the deleteUri @@ -239,8 +239,8 @@ object ContentUtils { databaseWrapper: DatabaseWrapper, whereConditions: OperatorGroup, orderBy: String, vararg columns: String): List? = - queryList(context.contentResolver, queryUri, table, - databaseWrapper, whereConditions, orderBy, *columns) + queryList(context.contentResolver, queryUri, table, + databaseWrapper, whereConditions, orderBy, *columns) /** @@ -284,8 +284,8 @@ object ContentUtils { databaseWrapper: DatabaseWrapper, whereConditions: OperatorGroup, orderBy: String, vararg columns: String): TableClass? = - querySingle(context.contentResolver, queryUri, table, - databaseWrapper, whereConditions, orderBy, *columns) + querySingle(context.contentResolver, queryUri, table, + databaseWrapper, whereConditions, orderBy, *columns) /** * Queries the [android.content.ContentResolver] with the specified queryUri. It will generate @@ -306,7 +306,7 @@ object ContentUtils { whereConditions: OperatorGroup, orderBy: String, vararg columns: String): TableClass? { val list = queryList(contentResolver, queryUri, table, - databaseWrapper, whereConditions, orderBy, *columns) + databaseWrapper, whereConditions, orderBy, *columns) return list?.let { if (list.isNotEmpty()) list[0] else null } } diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/ModelProvider.kt b/contentprovider/src/main/java/com/dbflow5/provider/ModelProvider.kt similarity index 89% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/ModelProvider.kt rename to contentprovider/src/main/java/com/dbflow5/provider/ModelProvider.kt index 973b6b112..d7b5a1606 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/ModelProvider.kt +++ b/contentprovider/src/main/java/com/dbflow5/provider/ModelProvider.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.provider +package com.dbflow5.provider import android.content.ContentResolver import android.net.Uri -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.Operator -import com.raizlabs.dbflow5.query.OperatorGroup +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.Operator +import com.dbflow5.query.OperatorGroup /** * Description: A base interface for Models that are connected to providers. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/StubContentProvider.kt b/contentprovider/src/main/java/com/dbflow5/provider/StubContentProvider.kt similarity index 96% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/StubContentProvider.kt rename to contentprovider/src/main/java/com/dbflow5/provider/StubContentProvider.kt index d022f42a9..2781a3d04 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/provider/StubContentProvider.kt +++ b/contentprovider/src/main/java/com/dbflow5/provider/StubContentProvider.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.provider +package com.dbflow5.provider /** * Description: diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/StringUtils.kt b/core/src/main/kotlin/com/dbflow5/StringUtils.kt similarity index 95% rename from core/src/main/kotlin/com/raizlabs/dbflow5/StringUtils.kt rename to core/src/main/kotlin/com/dbflow5/StringUtils.kt index 93be569d8..923135a60 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/StringUtils.kt +++ b/core/src/main/kotlin/com/dbflow5/StringUtils.kt @@ -1,8 +1,8 @@ @file:JvmName("StringUtils") -package com.raizlabs.dbflow5 +package com.dbflow5 -import com.raizlabs.dbflow5.sql.SQLiteType +import com.dbflow5.sql.SQLiteType import java.util.regex.Pattern @@ -41,7 +41,7 @@ fun String?.isQuoted(): Boolean = QUOTE_PATTERN.matcher(this).find() * @return A name in quotes. E.G. index => `index` so we can use keywords as column names without fear * of clashing. */ -fun String?.quote(): String = "$QUOTE${this?.replace(".", "`.`")}$QUOTE" +fun String?.quote(): String = "${QUOTE}${this?.replace(".", "`.`")}${QUOTE}" fun String?.quoteIfNeeded() = if (this != null && !isQuoted()) { quote() diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Collate.kt b/core/src/main/kotlin/com/dbflow5/annotation/Collate.kt similarity index 94% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Collate.kt rename to core/src/main/kotlin/com/dbflow5/annotation/Collate.kt index a0248fb66..caed7b309 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Collate.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/Collate.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Represents a SQL Collate method for comparing string columns. diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Column.kt b/core/src/main/kotlin/com/dbflow5/annotation/Column.kt similarity index 95% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Column.kt rename to core/src/main/kotlin/com/dbflow5/annotation/Column.kt index bc5590827..0309cd53a 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Column.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/Column.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation -import com.raizlabs.dbflow5.converter.TypeConverter +import com.dbflow5.converter.TypeConverter import kotlin.reflect.KClass /** diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ColumnIgnore.kt b/core/src/main/kotlin/com/dbflow5/annotation/ColumnIgnore.kt similarity index 83% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ColumnIgnore.kt rename to core/src/main/kotlin/com/dbflow5/annotation/ColumnIgnore.kt index bbd29be3c..a75591c9c 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ColumnIgnore.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/ColumnIgnore.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Description: An annotation used to ignore a column in the [Table.allFields] instance. diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ColumnMap.kt b/core/src/main/kotlin/com/dbflow5/annotation/ColumnMap.kt similarity index 93% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ColumnMap.kt rename to core/src/main/kotlin/com/dbflow5/annotation/ColumnMap.kt index 70955daec..7ca70399e 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ColumnMap.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/ColumnMap.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Description: Maps an arbitrary object and its corresponding fields into a set of columns. It is similar diff --git a/core/src/main/kotlin/com/dbflow5/annotation/ColumnMapReference.kt b/core/src/main/kotlin/com/dbflow5/annotation/ColumnMapReference.kt new file mode 100644 index 000000000..4d0a2aa76 --- /dev/null +++ b/core/src/main/kotlin/com/dbflow5/annotation/ColumnMapReference.kt @@ -0,0 +1,35 @@ +package com.dbflow5.annotation + +import com.dbflow5.converter.TypeConverter +import kotlin.reflect.KClass + +/** + * Description: Allows a [ColumnMap] to specify a reference override for its fields. Anything not + * defined here will not be used. + */ +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.FIELD) +annotation class ColumnMapReference( + /** + * @return The local column name that will be referenced in the DB + */ + val columnName: String, + /** + * @return The column name in the referenced table + */ + val columnMapFieldName: String, + /** + * @return The default value for the reference column. Same as [Column.defaultValue] + */ + val defaultValue: String = "", + + /** + * @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. + */ + val typeConverter: KClass> = TypeConverter::class, + + /** + * @return Specify the [NotNull] annotation here and it will get pasted into the reference definition. + */ + val notNull: NotNull = NotNull(onNullConflict = ConflictAction.NONE)) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ConflictAction.kt b/core/src/main/kotlin/com/dbflow5/annotation/ConflictAction.kt similarity index 98% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ConflictAction.kt rename to core/src/main/kotlin/com/dbflow5/annotation/ConflictAction.kt index 2dbf01cfe..b6a75a3b4 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ConflictAction.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/ConflictAction.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * This is how to resolve null or unique conflicts with a field marked as [NotNull] diff --git a/core/src/main/kotlin/com/dbflow5/annotation/Database.kt b/core/src/main/kotlin/com/dbflow5/annotation/Database.kt new file mode 100644 index 000000000..ce210cfce --- /dev/null +++ b/core/src/main/kotlin/com/dbflow5/annotation/Database.kt @@ -0,0 +1,52 @@ +package com.dbflow5.annotation + +/** + * 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(AnnotationTarget.CLASS, AnnotationTarget.FILE) +@Retention(AnnotationRetention.SOURCE) +annotation class Database( + /** + * @return The current version of the DB. Increment it to trigger a DB update. + */ + val version: Int, + @Deprecated("use DatabaseConfig.databaseName() to change the name.") + val name: String = "", + @Deprecated("use DatabaseConfig.extension() to change the extension.") + val databaseExtension: String = "", + @Deprecated("use DatabaseConfig.inMemoryBuilder() instead.") + val inMemory: Boolean = false, + /** + * @return If true, SQLite will throw exceptions when [ForeignKey] constraints are not respected. + * Default is false and will not throw exceptions. + */ + val foreignKeyConstraintsEnforced: Boolean = false, + /** + * @return Checks for consistency in the DB, if true it will recopy over the prepackage database. + */ + val consistencyCheckEnabled: Boolean = false, + /** + * @return Keeps a backup for whenever the database integrity fails a "PRAGMA quick_check(1)" that will + * replace the corrupted DB + */ + val backupEnabled: Boolean = false, + /** + * @return Global default insert conflict that can be applied to any table when it leaves + * its [ConflictAction] as NONE. + */ + val insertConflict: ConflictAction = ConflictAction.NONE, + /** + * @return Global update conflict that can be applied to any table when it leaves its + * [ConflictAction] as NONE + */ + val updateConflict: ConflictAction = ConflictAction.NONE) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ForeignKey.kt b/core/src/main/kotlin/com/dbflow5/annotation/ForeignKey.kt similarity index 95% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ForeignKey.kt rename to core/src/main/kotlin/com/dbflow5/annotation/ForeignKey.kt index 17f46d6c2..ebd035380 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ForeignKey.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/ForeignKey.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation import kotlin.reflect.KClass @@ -8,45 +8,45 @@ import kotlin.reflect.KClass @Retention(AnnotationRetention.SOURCE) @Target(AnnotationTarget.FIELD) annotation class ForeignKey( - /** + /** * Defines explicit references for a composite [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. */ val references: Array = [], - /** + /** * @return Default false. When this column is a [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. */ val saveForeignKeyModel: Boolean = false, - /** + /** * @return Default false. When this column is a [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. */ val deleteForeignKeyModel: Boolean = false, - /** + /** * @return Replaces legacy ForeignKeyContainer, this method instructs the code generator to only * populate the model with the [ForeignKeyReference] defined in this field. This skips * the Select retrieval convenience. */ val stubbedRelationship: Boolean = 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](http://www.sqlite.org/foreignkeys.html.fk_deferred) */ val deferred: Boolean = false, - /** + /** * @return an optional table class that this reference points to. It's only used if the field * is NOT a Model class. */ val tableClass: KClass<*> = Any::class, - /** + /** * Defines [ForeignKeyAction] action to be performed * on delete of referenced record. Defaults to [ForeignKeyAction.NO_ACTION]. Used only when * columnType is [ForeignKey]. @@ -54,7 +54,7 @@ annotation class ForeignKey( * @return [ForeignKeyAction] */ val onDelete: ForeignKeyAction = ForeignKeyAction.NO_ACTION, - /** + /** * Defines [ForeignKeyAction] action to be performed * on update of referenced record. Defaults to [ForeignKeyAction.NO_ACTION]. Used only when * columnType is [ForeignKey]. diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ForeignKeyAction.kt b/core/src/main/kotlin/com/dbflow5/annotation/ForeignKeyAction.kt similarity index 97% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ForeignKeyAction.kt rename to core/src/main/kotlin/com/dbflow5/annotation/ForeignKeyAction.kt index 8db864044..89d227916 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ForeignKeyAction.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/ForeignKeyAction.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Actions associated with on update and on delete diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ForeignKeyReference.kt b/core/src/main/kotlin/com/dbflow5/annotation/ForeignKeyReference.kt similarity index 96% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ForeignKeyReference.kt rename to core/src/main/kotlin/com/dbflow5/annotation/ForeignKeyReference.kt index 41445685f..0430a075c 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ForeignKeyReference.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/ForeignKeyReference.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Description: Used inside of [ForeignKey.references], describes the diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Index.kt b/core/src/main/kotlin/com/dbflow5/annotation/Index.kt similarity index 90% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Index.kt rename to core/src/main/kotlin/com/dbflow5/annotation/Index.kt index eb32a43e3..1838a9af3 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Index.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/Index.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Description: Creates an index for a specified [Column]. A single column can belong to multiple diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/IndexGroup.kt b/core/src/main/kotlin/com/dbflow5/annotation/IndexGroup.kt similarity index 94% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/IndexGroup.kt rename to core/src/main/kotlin/com/dbflow5/annotation/IndexGroup.kt index 8ec5d3930..172cd9e72 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/IndexGroup.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/IndexGroup.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation const val INDEX_GENERIC = -1 diff --git a/core/src/main/kotlin/com/dbflow5/annotation/InheritedColumn.kt b/core/src/main/kotlin/com/dbflow5/annotation/InheritedColumn.kt new file mode 100644 index 000000000..1c44bd4d1 --- /dev/null +++ b/core/src/main/kotlin/com/dbflow5/annotation/InheritedColumn.kt @@ -0,0 +1,23 @@ +package com.dbflow5.annotation + +import com.dbflow5.annotation.ConflictAction + +/** + * Description: Allows [Table] to inherit fields from other objects to make it part of the DB table. + */ +@Target(AnnotationTarget.ANNOTATION_CLASS) +@Retention(AnnotationRetention.SOURCE) +annotation class InheritedColumn( + /** + * @return The column annotation as if it was part of the class + */ + val 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 [Column] allows you to define getter and setters for it. + */ + val fieldName: String, + /** + * @return If specified other than [ConflictAction.NONE], then we assume [NotNull]. + */ + val nonNullConflict: ConflictAction = ConflictAction.NONE) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/InheritedPrimaryKey.kt b/core/src/main/kotlin/com/dbflow5/annotation/InheritedPrimaryKey.kt similarity index 95% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/InheritedPrimaryKey.kt rename to core/src/main/kotlin/com/dbflow5/annotation/InheritedPrimaryKey.kt index d3e49a1e0..ba4f9b421 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/InheritedPrimaryKey.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/InheritedPrimaryKey.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Description: Allows you to specify a non-Column to be inherited and used as a [PrimaryKey] diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ManyToMany.kt b/core/src/main/kotlin/com/dbflow5/annotation/ManyToMany.kt similarity index 97% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ManyToMany.kt rename to core/src/main/kotlin/com/dbflow5/annotation/ManyToMany.kt index 12e08e522..21d07fd89 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ManyToMany.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/ManyToMany.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation import kotlin.reflect.KClass diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Migration.kt b/core/src/main/kotlin/com/dbflow5/annotation/Migration.kt similarity index 95% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Migration.kt rename to core/src/main/kotlin/com/dbflow5/annotation/Migration.kt index 848d2650b..75de88f25 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Migration.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/Migration.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation import kotlin.reflect.KClass diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ModelCacheField.kt b/core/src/main/kotlin/com/dbflow5/annotation/ModelCacheField.kt similarity index 84% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ModelCacheField.kt rename to core/src/main/kotlin/com/dbflow5/annotation/ModelCacheField.kt index e61277816..e327ce8ca 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ModelCacheField.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/ModelCacheField.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Description: marks a single field as a ModelCache creator that is used in the corresponding ModelAdapter. diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ModelView.kt b/core/src/main/kotlin/com/dbflow5/annotation/ModelView.kt similarity index 89% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ModelView.kt rename to core/src/main/kotlin/com/dbflow5/annotation/ModelView.kt index cac2218be..a7744454a 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ModelView.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/ModelView.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.sql.Query import kotlin.reflect.KClass /** @@ -20,7 +20,7 @@ annotation class ModelView( */ val database: KClass<*>, /** - * @return When true, all public, package-private , non-static, and non-final fields of the reference class are considered as [com.raizlabs.android.dbflow.annotation.Column] . + * @return When true, all public, package-private , non-static, and non-final fields of the reference class are considered as [com.dbflow5.annotation.Column] . * The only required annotated field becomes The [PrimaryKey] * or [PrimaryKey.autoincrement]. */ diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ModelViewQuery.kt b/core/src/main/kotlin/com/dbflow5/annotation/ModelViewQuery.kt similarity index 82% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ModelViewQuery.kt rename to core/src/main/kotlin/com/dbflow5/annotation/ModelViewQuery.kt index 81fcc2ffa..a7419c2fa 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ModelViewQuery.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/ModelViewQuery.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.sql.Query /** * Description: Represents a field that is a [Query]. This is only meant to be used as a query diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/MultiCacheField.kt b/core/src/main/kotlin/com/dbflow5/annotation/MultiCacheField.kt similarity index 85% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/MultiCacheField.kt rename to core/src/main/kotlin/com/dbflow5/annotation/MultiCacheField.kt index 5b14ac649..f025b2c56 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/MultiCacheField.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/MultiCacheField.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Description: Marks a field as the IMultiKeyCacheModel that we use to convert multiple fields into diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/MultipleManyToMany.kt b/core/src/main/kotlin/com/dbflow5/annotation/MultipleManyToMany.kt similarity index 86% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/MultipleManyToMany.kt rename to core/src/main/kotlin/com/dbflow5/annotation/MultipleManyToMany.kt index d91e81e7e..659c32c2c 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/MultipleManyToMany.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/MultipleManyToMany.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Description: Provides ability to add multiple [ManyToMany] annotations at once. diff --git a/core/src/main/kotlin/com/dbflow5/annotation/NotNull.kt b/core/src/main/kotlin/com/dbflow5/annotation/NotNull.kt new file mode 100644 index 000000000..b94e9eb75 --- /dev/null +++ b/core/src/main/kotlin/com/dbflow5/annotation/NotNull.kt @@ -0,0 +1,16 @@ +package com.dbflow5.annotation + +import com.dbflow5.annotation.ConflictAction + +/** + * Description: Specifies that a [Column] is not null. + */ +@Target(AnnotationTarget.FIELD) +@Retention(AnnotationRetention.SOURCE) +annotation class NotNull( + /** + * Defines how to handle conflicts for not null column + * + * @return a [com.dbflow5.annotation.ConflictAction] enum + */ + val onNullConflict: ConflictAction = ConflictAction.FAIL) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/OneToMany.kt b/core/src/main/kotlin/com/dbflow5/annotation/OneToMany.kt similarity index 58% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/OneToMany.kt rename to core/src/main/kotlin/com/dbflow5/annotation/OneToMany.kt index 10a6c4e5c..1720d22b0 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/OneToMany.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/OneToMany.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Description: Describes a 1-many relationship. It applies to some method that returns a [List] of Model objects. @@ -8,19 +8,19 @@ package com.raizlabs.dbflow5.annotation @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) @Retention(AnnotationRetention.SOURCE) annotation class OneToMany( - /** - * @return The methods you wish to call it from. By default it's loaded out of the DB. - */ - val oneToManyMethods: Array = [OneToManyMethod.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. - */ - val variableName: String = "", - /** - * @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. - */ - val efficientMethods: Boolean = true) + /** + * @return The methods you wish to call it from. By default it's loaded out of the DB. + */ + val oneToManyMethods: Array = [(OneToManyMethod.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. + */ + val variableName: String = "", + /** + * @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. + */ + val efficientMethods: Boolean = true) /** * The method to apply the OneToMany to. diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/PrimaryKey.kt b/core/src/main/kotlin/com/dbflow5/annotation/PrimaryKey.kt similarity index 94% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/PrimaryKey.kt rename to core/src/main/kotlin/com/dbflow5/annotation/PrimaryKey.kt index f0a7f2563..103a7cace 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/PrimaryKey.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/PrimaryKey.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation /** * Description: diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/QueryModel.kt b/core/src/main/kotlin/com/dbflow5/annotation/QueryModel.kt similarity index 93% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/QueryModel.kt rename to core/src/main/kotlin/com/dbflow5/annotation/QueryModel.kt index 4dcf9abc8..a3d65df3d 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/QueryModel.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/QueryModel.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation import kotlin.reflect.KClass diff --git a/core/src/main/kotlin/com/dbflow5/annotation/Table.kt b/core/src/main/kotlin/com/dbflow5/annotation/Table.kt new file mode 100644 index 000000000..ec018773d --- /dev/null +++ b/core/src/main/kotlin/com/dbflow5/annotation/Table.kt @@ -0,0 +1,96 @@ +package com.dbflow5.annotation + +import com.dbflow5.annotation.ConflictAction +import kotlin.reflect.KClass + +val DEFAULT_CACHE_SIZE = 25 + +/** + * 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(AnnotationRetention.SOURCE) +@Target(AnnotationTarget.CLASS, AnnotationTarget.FILE) +annotation class Table( + /** + * @return Specifies a different name for the table than the name of the Model class. + */ + val name: String = "", + /** + * @return Specify the database class that this table belongs to. It must have the [Database] annotation. + */ + val database: KClass<*>, + /** + * @return Specify the general conflict algorithm used by this table when updating records. + */ + val updateConflict: com.dbflow5.annotation.ConflictAction = com.dbflow5.annotation.ConflictAction.NONE, + /** + * @return Specify the general insert conflict algorithm used by this table. + */ + val insertConflict: com.dbflow5.annotation.ConflictAction = com.dbflow5.annotation.ConflictAction.NONE, + /** + * @return An optional [ConflictAction] that we append to creation for conflict handling in PK. + */ + val primaryKeyConflict: com.dbflow5.annotation.ConflictAction = com.dbflow5.annotation.ConflictAction.NONE, + /** + * @return When true, all public, package-private , non-static, and non-final fields of the reference class are considered as [com.dbflow5.annotation.Column] . + * The only required annotated field becomes The [PrimaryKey] + * or [PrimaryKey.autoincrement]. + */ + val allFields: Boolean = true, + /** + * @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" + */ + val useBooleanGetterSetters: Boolean = 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. + */ + val cachingEnabled: Boolean = 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. + */ + val orderedCursorLookUp: Boolean = 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. + */ + val assignDefaultValuesFromCursor: Boolean = 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. + */ + val createWithDatabase: Boolean = true, + + /** + * If true, generates ContentValues bindings for a table. By default it no longer does. + */ + val generateContentValues: Boolean = false, + /** + * @return The cache size for this Table. + */ + val cacheSize: Int = 25, + /** + * @return Declares a set of UNIQUE columns with the corresponding [ConflictAction]. A [Column] + * will point to this group using [Unique.uniqueGroups] + */ + val uniqueColumnGroups: Array = [], + /** + * @return The set of INDEX clauses that specific columns can define to belong to, using the [Index] annotation. + * The generated Index properties belong to the corresponding property class to this table. + */ + val indexGroups: Array = [], + /** + * @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. + */ + val inheritedColumns: Array = [], + /** + * @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. + */ + val inheritedPrimaryKeys: Array = []) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/TypeConverter.kt b/core/src/main/kotlin/com/dbflow5/annotation/TypeConverter.kt similarity index 93% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/TypeConverter.kt rename to core/src/main/kotlin/com/dbflow5/annotation/TypeConverter.kt index eb5df7805..6e863a591 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/TypeConverter.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/TypeConverter.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation +package com.dbflow5.annotation import kotlin.reflect.KClass diff --git a/core/src/main/kotlin/com/dbflow5/annotation/Unique.kt b/core/src/main/kotlin/com/dbflow5/annotation/Unique.kt new file mode 100644 index 000000000..e0c9b456a --- /dev/null +++ b/core/src/main/kotlin/com/dbflow5/annotation/Unique.kt @@ -0,0 +1,24 @@ +package com.dbflow5.annotation + +/** + * Description: Marks the field as unique, meaning its value cannot be repeated. It is, however, + * NOT a primary key. + */ +@Retention(AnnotationRetention.BINARY) +@Target(AnnotationTarget.FIELD) +annotation class Unique( + /** + * @return if field is unique. If false, we expect [.uniqueGroups] to be specified.` + */ + val unique: Boolean = true, + /** + * @return Marks a unique field as part of a unique group. For every unique number entered, + * it will generate a UNIQUE() column statement. + */ + val uniqueGroups: IntArray = [], + /** + * Defines how to handle conflicts for a unique column + * + * @return a [ConflictAction] enum + */ + val onUniqueConflict: ConflictAction = ConflictAction.FAIL) diff --git a/core/src/main/kotlin/com/dbflow5/annotation/UniqueGroup.kt b/core/src/main/kotlin/com/dbflow5/annotation/UniqueGroup.kt new file mode 100644 index 000000000..4667558cb --- /dev/null +++ b/core/src/main/kotlin/com/dbflow5/annotation/UniqueGroup.kt @@ -0,0 +1,16 @@ +package com.dbflow5.annotation + +/** + * Description: + */ +@Target(AnnotationTarget.ANNOTATION_CLASS) +@Retention(AnnotationRetention.SOURCE) +annotation class UniqueGroup( + /** + * @return The number that columns point to to use this group + */ + val groupNumber: Int, + /** + * @return The conflict action that this group takes. + */ + val uniqueConflict: ConflictAction = ConflictAction.FAIL) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/ContentProvider.kt b/core/src/main/kotlin/com/dbflow5/annotation/provider/ContentProvider.kt similarity index 92% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/ContentProvider.kt rename to core/src/main/kotlin/com/dbflow5/annotation/provider/ContentProvider.kt index b54181aed..64fc0ff19 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/ContentProvider.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/provider/ContentProvider.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation.provider +package com.dbflow5.annotation.provider import kotlin.reflect.KClass diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/ContentUri.kt b/core/src/main/kotlin/com/dbflow5/annotation/provider/ContentUri.kt similarity index 93% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/ContentUri.kt rename to core/src/main/kotlin/com/dbflow5/annotation/provider/ContentUri.kt index 0944057bf..9adaed3c0 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/ContentUri.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/provider/ContentUri.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation.provider +package com.dbflow5.annotation.provider /** * Description: Defines the URI for a content provider. @@ -7,32 +7,32 @@ package com.raizlabs.dbflow5.annotation.provider AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) @Retention(AnnotationRetention.SOURCE) annotation class ContentUri( - /** + /** * @return the path of this ContentUri. ex: notes/#, notes/1, etc. Must be unique within a [TableEndpoint] */ val path: String, - /** + /** * @return The type of content that this uri is associated with. Ex: [ContentType.VND_SINGLE] */ val type: String, - /** + /** * @return If the path defines "#", then we use these numbers to find them in the same order as * where column. */ val segments: Array = [], - /** + /** * @return false if you wish to not allow queries from the specified URI. */ val queryEnabled: Boolean = true, - /** + /** * @return false if you wish to prevent inserts. */ val insertEnabled: Boolean = true, - /** + /** * @return false if you wish to prevent deletion. */ val deleteEnabled: Boolean = true, - /** + /** * @return false if you wish to prevent updates. */ val updateEnabled: Boolean = true) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/Notify.kt b/core/src/main/kotlin/com/dbflow5/annotation/provider/Notify.kt similarity index 73% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/Notify.kt rename to core/src/main/kotlin/com/dbflow5/annotation/provider/Notify.kt index 2caf40ca5..cf5e18703 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/Notify.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/provider/Notify.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.annotation.provider +package com.dbflow5.annotation.provider /** - * Description: Annotates a method part of [com.raizlabs.android.dbflow.annotation.provider.TableEndpoint] + * Description: Annotates a method part of [com.dbflow5.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. */ @@ -9,7 +9,7 @@ package com.raizlabs.dbflow5.annotation.provider @Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER) annotation class Notify( /** - * @return The [com.raizlabs.android.dbflow.annotation.provider.Notify.Method] notify + * @return The [com.dbflow5.annotation.provider.Notify.Method] notify */ val notifyMethod: NotifyMethod, /** diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/TableEndpoint.kt b/core/src/main/kotlin/com/dbflow5/annotation/provider/TableEndpoint.kt similarity index 91% rename from core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/TableEndpoint.kt rename to core/src/main/kotlin/com/dbflow5/annotation/provider/TableEndpoint.kt index ce07c395f..076fc4607 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/provider/TableEndpoint.kt +++ b/core/src/main/kotlin/com/dbflow5/annotation/provider/TableEndpoint.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.annotation.provider +package com.dbflow5.annotation.provider import kotlin.reflect.KClass diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/converter/TypeConverters.kt b/core/src/main/kotlin/com/dbflow5/converter/TypeConverters.kt similarity index 92% rename from core/src/main/kotlin/com/raizlabs/dbflow5/converter/TypeConverters.kt rename to core/src/main/kotlin/com/dbflow5/converter/TypeConverters.kt index 961ea36ee..9fb853fac 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/converter/TypeConverters.kt +++ b/core/src/main/kotlin/com/dbflow5/converter/TypeConverters.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.converter +package com.dbflow5.converter import java.math.BigDecimal import java.math.BigInteger @@ -11,7 +11,7 @@ import java.util.* * Description: This class is responsible for converting the stored database value into the field value in * a Model. */ -@com.raizlabs.dbflow5.annotation.TypeConverter +@com.dbflow5.annotation.TypeConverter abstract class TypeConverter { /** @@ -61,7 +61,7 @@ class BooleanConverter : TypeConverter() { /** * Description: Defines how we store and retrieve a [java.util.Calendar] */ -@com.raizlabs.dbflow5.annotation.TypeConverter(allowedSubtypes = [(GregorianCalendar::class)]) +@com.dbflow5.annotation.TypeConverter(allowedSubtypes = [(GregorianCalendar::class)]) class CalendarConverter : TypeConverter() { override fun getDBValue(model: Calendar?): Long? = model?.timeInMillis @@ -94,7 +94,7 @@ class DateConverter : TypeConverter() { /** * Description: Defines how we store and retrieve a [java.sql.Date] */ -@com.raizlabs.dbflow5.annotation.TypeConverter(allowedSubtypes = [(Time::class), (Timestamp::class)]) +@com.dbflow5.annotation.TypeConverter(allowedSubtypes = [(Time::class), (Timestamp::class)]) class SqlDateConverter : TypeConverter() { override fun getDBValue(model: java.sql.Date?): Long? = model?.time diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/data/Blob.kt b/core/src/main/kotlin/com/dbflow5/data/Blob.kt similarity index 88% rename from core/src/main/kotlin/com/raizlabs/dbflow5/data/Blob.kt rename to core/src/main/kotlin/com/dbflow5/data/Blob.kt index 57723da61..9e668070f 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/data/Blob.kt +++ b/core/src/main/kotlin/com/dbflow5/data/Blob.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.data +package com.dbflow5.data /** * Description: Provides a way to support blob format data. diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/sql/Query.kt b/core/src/main/kotlin/com/dbflow5/sql/Query.kt similarity index 85% rename from core/src/main/kotlin/com/raizlabs/dbflow5/sql/Query.kt rename to core/src/main/kotlin/com/dbflow5/sql/Query.kt index 1bd91f464..50b29b12f 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/sql/Query.kt +++ b/core/src/main/kotlin/com/dbflow5/sql/Query.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.sql +package com.dbflow5.sql /** * Description: The basic interface for something that has a piece of a query. diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/sql/QueryCloneable.kt b/core/src/main/kotlin/com/dbflow5/sql/QueryCloneable.kt similarity index 71% rename from core/src/main/kotlin/com/raizlabs/dbflow5/sql/QueryCloneable.kt rename to core/src/main/kotlin/com/dbflow5/sql/QueryCloneable.kt index 6c53d9df9..a137de4eb 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/sql/QueryCloneable.kt +++ b/core/src/main/kotlin/com/dbflow5/sql/QueryCloneable.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.sql +package com.dbflow5.sql /** * Description: diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/sql/SQLiteType.kt b/core/src/main/kotlin/com/dbflow5/sql/SQLiteType.kt similarity index 96% rename from core/src/main/kotlin/com/raizlabs/dbflow5/sql/SQLiteType.kt rename to core/src/main/kotlin/com/dbflow5/sql/SQLiteType.kt index c139fcb10..2b4b90d81 100644 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/sql/SQLiteType.kt +++ b/core/src/main/kotlin/com/dbflow5/sql/SQLiteType.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.sql +package com.dbflow5.sql -import com.raizlabs.dbflow5.data.Blob +import com.dbflow5.data.Blob /** * Description: Represents a type that SQLite understands. diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ColumnMapReference.kt b/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ColumnMapReference.kt deleted file mode 100644 index bd96f942e..000000000 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/ColumnMapReference.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.raizlabs.dbflow5.annotation - -import com.raizlabs.dbflow5.converter.TypeConverter -import kotlin.reflect.KClass - -/** - * Description: Allows a [ColumnMap] to specify a reference override for its fields. Anything not - * defined here will not be used. - */ -@Retention(AnnotationRetention.BINARY) -@Target(AnnotationTarget.FIELD) -annotation class ColumnMapReference( - /** - * @return The local column name that will be referenced in the DB - */ - val columnName: String, - /** - * @return The column name in the referenced table - */ - val columnMapFieldName: String, - /** - * @return The default value for the reference column. Same as [Column.defaultValue] - */ - val defaultValue: String = "", - - /** - * @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. - */ - val typeConverter: KClass> = TypeConverter::class, - - /** - * @return Specify the [NotNull] annotation here and it will get pasted into the reference definition. - */ - val notNull: NotNull = NotNull(onNullConflict = ConflictAction.NONE)) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Database.kt b/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Database.kt deleted file mode 100644 index 9fd713b6c..000000000 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Database.kt +++ /dev/null @@ -1,52 +0,0 @@ -package com.raizlabs.dbflow5.annotation - -/** - * 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(AnnotationTarget.CLASS, AnnotationTarget.FILE) -@Retention(AnnotationRetention.SOURCE) -annotation class Database( - /** - * @return The current version of the DB. Increment it to trigger a DB update. - */ - val version: Int, - @Deprecated("use DatabaseConfig.databaseName() to change the name.") - val name: String = "", - @Deprecated("use DatabaseConfig.extension() to change the extension.") - val databaseExtension: String = "", - @Deprecated("use DatabaseConfig.inMemoryBuilder() instead.") - val inMemory: Boolean = false, - /** - * @return If true, SQLite will throw exceptions when [ForeignKey] constraints are not respected. - * Default is false and will not throw exceptions. - */ - val foreignKeyConstraintsEnforced: Boolean = false, - /** - * @return Checks for consistency in the DB, if true it will recopy over the prepackage database. - */ - val consistencyCheckEnabled: Boolean = false, - /** - * @return Keeps a backup for whenever the database integrity fails a "PRAGMA quick_check(1)" that will - * replace the corrupted DB - */ - val backupEnabled: Boolean = false, - /** - * @return Global default insert conflict that can be applied to any table when it leaves - * its [ConflictAction] as NONE. - */ - val insertConflict: ConflictAction = ConflictAction.NONE, - /** - * @return Global update conflict that can be applied to any table when it leaves its - * [ConflictAction] as NONE - */ - val updateConflict: ConflictAction = ConflictAction.NONE) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/InheritedColumn.kt b/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/InheritedColumn.kt deleted file mode 100644 index ae1b7b2e0..000000000 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/InheritedColumn.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.raizlabs.dbflow5.annotation - -/** - * Description: Allows [Table] to inherit fields from other objects to make it part of the DB table. - */ -@Target(AnnotationTarget.ANNOTATION_CLASS) -@Retention(AnnotationRetention.SOURCE) -annotation class InheritedColumn( - /** - * @return The column annotation as if it was part of the class - */ - val 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 [Column] allows you to define getter and setters for it. - */ - val fieldName: String, - /** - * @return If specified other than [ConflictAction.NONE], then we assume [NotNull]. - */ - val nonNullConflict: ConflictAction = ConflictAction.NONE) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/NotNull.kt b/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/NotNull.kt deleted file mode 100644 index 583123a1e..000000000 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/NotNull.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.raizlabs.dbflow5.annotation - -/** - * Description: Specifies that a [Column] is not null. - */ -@Target(AnnotationTarget.FIELD) -@Retention(AnnotationRetention.SOURCE) -annotation class NotNull( - /** - * Defines how to handle conflicts for not null column - * - * @return a [com.raizlabs.android.dbflow.annotation.ConflictAction] enum - */ - val onNullConflict: ConflictAction = ConflictAction.FAIL) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Table.kt b/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Table.kt deleted file mode 100644 index 1e5f11f4b..000000000 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Table.kt +++ /dev/null @@ -1,95 +0,0 @@ -package com.raizlabs.dbflow5.annotation - -import kotlin.reflect.KClass - -val DEFAULT_CACHE_SIZE = 25 - -/** - * 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(AnnotationRetention.SOURCE) -@Target(AnnotationTarget.CLASS, AnnotationTarget.FILE) -annotation class Table( - /** - * @return Specifies a different name for the table than the name of the Model class. - */ - val name: String = "", - /** - * @return Specify the database class that this table belongs to. It must have the [Database] annotation. - */ - val database: KClass<*>, - /** - * @return Specify the general conflict algorithm used by this table when updating records. - */ - val updateConflict: ConflictAction = ConflictAction.NONE, - /** - * @return Specify the general insert conflict algorithm used by this table. - */ - val insertConflict: ConflictAction = ConflictAction.NONE, - /** - * @return An optional [ConflictAction] that we append to creation for conflict handling in PK. - */ - val primaryKeyConflict: ConflictAction = ConflictAction.NONE, - /** - * @return When true, all public, package-private , non-static, and non-final fields of the reference class are considered as [com.raizlabs.android.dbflow.annotation.Column] . - * The only required annotated field becomes The [PrimaryKey] - * or [PrimaryKey.autoincrement]. - */ - val allFields: Boolean = true, - /** - * @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" - */ - val useBooleanGetterSetters: Boolean = 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. - */ - val cachingEnabled: Boolean = 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. - */ - val orderedCursorLookUp: Boolean = 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. - */ - val assignDefaultValuesFromCursor: Boolean = 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. - */ - val createWithDatabase: Boolean = true, - - /** - * If true, generates ContentValues bindings for a table. By default it no longer does. - */ - val generateContentValues: Boolean = false, - /** - * @return The cache size for this Table. - */ - val cacheSize: Int = 25, - /** - * @return Declares a set of UNIQUE columns with the corresponding [ConflictAction]. A [Column] - * will point to this group using [Unique.uniqueGroups] - */ - val uniqueColumnGroups: Array = [], - /** - * @return The set of INDEX clauses that specific columns can define to belong to, using the [Index] annotation. - * The generated Index properties belong to the corresponding property class to this table. - */ - val indexGroups: Array = [], - /** - * @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. - */ - val inheritedColumns: Array = [], - /** - * @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. - */ - val inheritedPrimaryKeys: Array = []) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Unique.kt b/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Unique.kt deleted file mode 100644 index 0a8b9ea90..000000000 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/Unique.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.raizlabs.dbflow5.annotation - -/** - * Description: Marks the field as unique, meaning its value cannot be repeated. It is, however, - * NOT a primary key. - */ -@Retention(AnnotationRetention.BINARY) -@Target(AnnotationTarget.FIELD) -annotation class Unique( - /** - * @return if field is unique. If false, we expect [.uniqueGroups] to be specified.` - */ - val unique: Boolean = true, - /** - * @return Marks a unique field as part of a unique group. For every unique number entered, - * it will generate a UNIQUE() column statement. - */ - val uniqueGroups: IntArray = [], - /** - * Defines how to handle conflicts for a unique column - * - * @return a [ConflictAction] enum - */ - val onUniqueConflict: ConflictAction = ConflictAction.FAIL) diff --git a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/UniqueGroup.kt b/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/UniqueGroup.kt deleted file mode 100644 index a4f45bf2a..000000000 --- a/core/src/main/kotlin/com/raizlabs/dbflow5/annotation/UniqueGroup.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.raizlabs.dbflow5.annotation - -/** - * Description: - */ -@Target(AnnotationTarget.ANNOTATION_CLASS) -@Retention(AnnotationRetention.SOURCE) -annotation class UniqueGroup( - /** - * @return The number that columns point to to use this group - */ - val groupNumber: Int, - /** - * @return The conflict action that this group takes. - */ - val uniqueConflict: ConflictAction = ConflictAction.FAIL) diff --git a/coroutines/build.gradle b/coroutines/build.gradle index 4e888605b..cccb6b8f6 100644 --- a/coroutines/build.gradle +++ b/coroutines/build.gradle @@ -23,7 +23,7 @@ android { } dependencies { - implementation project("${dbflow_project_prefix}dbflow") + implementation project(':lib') api deps.coroutines } diff --git a/coroutines/src/main/AndroidManifest.xml b/coroutines/src/main/AndroidManifest.xml index 00f38e852..88396f77d 100644 --- a/coroutines/src/main/AndroidManifest.xml +++ b/coroutines/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/coroutines/src/main/kotlin/com/raizlabs/dbflow5/coroutines/Coroutines.kt b/coroutines/src/main/kotlin/com/dbflow5/coroutines/Coroutines.kt similarity index 87% rename from coroutines/src/main/kotlin/com/raizlabs/dbflow5/coroutines/Coroutines.kt rename to coroutines/src/main/kotlin/com/dbflow5/coroutines/Coroutines.kt index fbfb1e123..ed6889f22 100644 --- a/coroutines/src/main/kotlin/com/raizlabs/dbflow5/coroutines/Coroutines.kt +++ b/coroutines/src/main/kotlin/com/dbflow5/coroutines/Coroutines.kt @@ -1,17 +1,17 @@ -package com.raizlabs.dbflow5.coroutines - -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.query.Queriable -import com.raizlabs.dbflow5.structure.delete -import com.raizlabs.dbflow5.structure.insert -import com.raizlabs.dbflow5.structure.load -import com.raizlabs.dbflow5.structure.save -import com.raizlabs.dbflow5.structure.update -import com.raizlabs.dbflow5.transaction.FastStoreModelTransaction -import com.raizlabs.dbflow5.transaction.fastDelete -import com.raizlabs.dbflow5.transaction.fastInsert -import com.raizlabs.dbflow5.transaction.fastSave -import com.raizlabs.dbflow5.transaction.fastUpdate +package com.dbflow5.coroutines + +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.query.Queriable +import com.dbflow5.structure.delete +import com.dbflow5.structure.insert +import com.dbflow5.structure.load +import com.dbflow5.structure.save +import com.dbflow5.structure.update +import com.dbflow5.transaction.FastStoreModelTransaction +import com.dbflow5.transaction.fastDelete +import com.dbflow5.transaction.fastInsert +import com.dbflow5.transaction.fastSave +import com.dbflow5.transaction.fastUpdate import kotlinx.coroutines.experimental.CancellableContinuation import kotlinx.coroutines.experimental.suspendCancellableCoroutine @@ -23,7 +23,7 @@ suspend inline fun DBFlowDatabase.awaitTransact( modelQueriable: Q, crossinline queriableFunction: Q.() -> R) = suspendCancellableCoroutine { continuation -> - com.raizlabs.dbflow5.coroutines.constructCoroutine(continuation, this) { queriableFunction(modelQueriable) } + com.dbflow5.coroutines.constructCoroutine(continuation, this) { queriableFunction(modelQueriable) } } inline fun constructCoroutine(continuation: CancellableContinuation, diff --git a/dbflow/src/main/AndroidManifest.xml b/dbflow/src/main/AndroidManifest.xml deleted file mode 100644 index 67bbf30c5..000000000 --- a/dbflow/src/main/AndroidManifest.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/gradle.properties b/gradle.properties index 9d97ed823..76cb67ec1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ version=5.0.0-alpha1 version_code=1 -group=com.raizlabs.android -bt_siteUrl=https://github.com/Raizlabs/DBFlow -bt_gitUrl=https://github.com/Raizlabs/DBFlow.git +group=com.dbflow5 +bt_siteUrl=https://github.com/agrosner/DBFlow +bt_gitUrl=https://github.com/agrosner/DBFlow.git bt_licenseName=The MIT License bt_licenseUrl=http://opensource.org/licenses/MIT bt_repo=Libraries diff --git a/dbflow/build.gradle b/lib/build.gradle similarity index 91% rename from dbflow/build.gradle rename to lib/build.gradle index b17eea76a..d60dd9c98 100644 --- a/dbflow/build.gradle +++ b/lib/build.gradle @@ -27,7 +27,7 @@ android { dependencies { api project(':core') - api "com.android.support:support-annotations:27.0.2" + api "com.android.support:support-annotations:27.1.1" api "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" } diff --git a/dbflow/gradle.properties b/lib/gradle.properties similarity index 100% rename from dbflow/gradle.properties rename to lib/gradle.properties diff --git a/dbflow/settings.gradle b/lib/settings.gradle similarity index 100% rename from dbflow/settings.gradle rename to lib/settings.gradle diff --git a/lib/src/main/AndroidManifest.xml b/lib/src/main/AndroidManifest.xml new file mode 100644 index 000000000..1c6093f3a --- /dev/null +++ b/lib/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/SqlUtils.kt b/lib/src/main/kotlin/com/dbflow5/SqlUtils.kt similarity index 93% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/SqlUtils.kt rename to lib/src/main/kotlin/com/dbflow5/SqlUtils.kt index 586bbee99..9fd668c79 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/SqlUtils.kt +++ b/lib/src/main/kotlin/com/dbflow5/SqlUtils.kt @@ -1,17 +1,20 @@ @file:JvmName("SqlUtils") -package com.raizlabs.dbflow5 +package com.dbflow5 import android.content.ContentValues import android.net.Uri -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.Operator -import com.raizlabs.dbflow5.query.OperatorGroup -import com.raizlabs.dbflow5.query.SQLOperator -import com.raizlabs.dbflow5.structure.ChangeAction -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.isNotNullOrEmpty +import com.dbflow5.quoteIfNeeded +import com.dbflow5.stripQuotes +import com.dbflow5.config.FlowManager +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.NameAlias +import com.dbflow5.query.Operator +import com.dbflow5.query.OperatorGroup +import com.dbflow5.query.SQLOperator +import com.dbflow5.structure.ChangeAction +import com.dbflow5.structure.Model /** * Description: Provides some handy methods for dealing with SQL statements. It's purpose is to move the diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/CacheAdapter.kt b/lib/src/main/kotlin/com/dbflow5/adapter/CacheAdapter.kt similarity index 88% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/CacheAdapter.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/CacheAdapter.kt index 773d1e754..53ea4a8fd 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/CacheAdapter.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/CacheAdapter.kt @@ -1,12 +1,12 @@ -package com.raizlabs.dbflow5.adapter - -import com.raizlabs.dbflow5.annotation.DEFAULT_CACHE_SIZE -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.cache.IMultiKeyCacheConverter -import com.raizlabs.dbflow5.query.cache.ModelCache -import com.raizlabs.dbflow5.query.cache.SimpleMapCache -import com.raizlabs.dbflow5.structure.InvalidDBConfiguration +package com.dbflow5.adapter + +import com.dbflow5.annotation.DEFAULT_CACHE_SIZE +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.cache.IMultiKeyCacheConverter +import com.dbflow5.query.cache.ModelCache +import com.dbflow5.query.cache.SimpleMapCache +import com.dbflow5.structure.InvalidDBConfiguration /** * Description: diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/InternalAdapter.kt b/lib/src/main/kotlin/com/dbflow5/adapter/InternalAdapter.kt similarity index 95% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/InternalAdapter.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/InternalAdapter.kt index bcf0a98e4..63f2814cb 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/InternalAdapter.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/InternalAdapter.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.adapter +package com.dbflow5.adapter import android.content.ContentValues -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.annotation.PrimaryKey +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.database.DatabaseWrapper /** * Description: Used for our internal Adapter classes such as generated [ModelAdapter]. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/ModelAdapter.kt b/lib/src/main/kotlin/com/dbflow5/adapter/ModelAdapter.kt similarity index 92% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/ModelAdapter.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/ModelAdapter.kt index dda159a7e..6dd017afb 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/ModelAdapter.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/ModelAdapter.kt @@ -1,16 +1,16 @@ -package com.raizlabs.dbflow5.adapter +package com.dbflow5.adapter import android.content.ContentValues -import com.raizlabs.dbflow5.adapter.saveable.ListModelSaver -import com.raizlabs.dbflow5.adapter.saveable.ModelSaver -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.annotation.ForeignKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.query.property.Property +import com.dbflow5.adapter.saveable.ListModelSaver +import com.dbflow5.adapter.saveable.ModelSaver +import com.dbflow5.annotation.ConflictAction +import com.dbflow5.annotation.ForeignKey +import com.dbflow5.annotation.Table +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.property.IProperty +import com.dbflow5.query.property.Property /** * Description: Used for generated classes from the combination of [Table] and [Model]. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/ModelViewAdapter.kt b/lib/src/main/kotlin/com/dbflow5/adapter/ModelViewAdapter.kt similarity index 77% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/ModelViewAdapter.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/ModelViewAdapter.kt index 24775ce24..f9ec45e09 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/ModelViewAdapter.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/ModelViewAdapter.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.adapter +package com.dbflow5.adapter -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.database.DatabaseWrapper /** * Description: The base class for a [T] adapter that defines how it interacts with the DB. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/QueryModelAdapter.kt b/lib/src/main/kotlin/com/dbflow5/adapter/QueryModelAdapter.kt similarity index 73% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/QueryModelAdapter.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/QueryModelAdapter.kt index 86321cd1f..fd4be26aa 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/QueryModelAdapter.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/QueryModelAdapter.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.adapter +package com.dbflow5.adapter -import com.raizlabs.dbflow5.annotation.QueryModel -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.OperatorGroup +import com.dbflow5.annotation.QueryModel +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.OperatorGroup /** * Description: The baseclass for adapters to [QueryModel] that defines how it interacts with the DB. The diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/RetrievalAdapter.kt b/lib/src/main/kotlin/com/dbflow5/adapter/RetrievalAdapter.kt similarity index 89% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/RetrievalAdapter.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/RetrievalAdapter.kt index 853678870..45d68c98b 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/RetrievalAdapter.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/RetrievalAdapter.kt @@ -1,14 +1,14 @@ -package com.raizlabs.dbflow5.adapter - -import com.raizlabs.dbflow5.adapter.queriable.ListModelLoader -import com.raizlabs.dbflow5.adapter.queriable.SingleModelLoader -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.config.TableConfig -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.OperatorGroup -import com.raizlabs.dbflow5.query.select +package com.dbflow5.adapter + +import com.dbflow5.adapter.queriable.ListModelLoader +import com.dbflow5.adapter.queriable.SingleModelLoader +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.FlowManager +import com.dbflow5.config.TableConfig +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.OperatorGroup +import com.dbflow5.query.select /** * Description: Provides a base retrieval class for all [Model] backed diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/CacheableListModelLoader.kt b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/CacheableListModelLoader.kt similarity index 80% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/CacheableListModelLoader.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/queriable/CacheableListModelLoader.kt index 8078e7ee3..39f063a33 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/CacheableListModelLoader.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/CacheableListModelLoader.kt @@ -1,12 +1,12 @@ -package com.raizlabs.dbflow5.adapter.queriable +package com.dbflow5.adapter.queriable -import com.raizlabs.dbflow5.adapter.CacheAdapter -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.cache.ModelCache -import com.raizlabs.dbflow5.query.cache.addOrReload +import com.dbflow5.adapter.CacheAdapter +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.annotation.Table +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.cache.ModelCache +import com.dbflow5.query.cache.addOrReload /** * Description: Loads a [List] of [T] with [Table.cachingEnabled] true. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/CacheableModelLoader.kt b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/CacheableModelLoader.kt similarity index 82% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/CacheableModelLoader.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/queriable/CacheableModelLoader.kt index 3ba51b719..f64d43ccd 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/CacheableModelLoader.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/CacheableModelLoader.kt @@ -1,12 +1,12 @@ -package com.raizlabs.dbflow5.adapter.queriable +package com.dbflow5.adapter.queriable -import com.raizlabs.dbflow5.adapter.CacheAdapter -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.cache.ModelCache -import com.raizlabs.dbflow5.query.cache.addOrReload +import com.dbflow5.adapter.CacheAdapter +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.annotation.Table +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.cache.ModelCache +import com.dbflow5.query.cache.addOrReload /** * Description: Loads model data that is backed by a [ModelCache]. Used when [Table.cachingEnabled] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/ListModelLoader.kt b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/ListModelLoader.kt similarity index 78% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/ListModelLoader.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/queriable/ListModelLoader.kt index 3cbdf166e..61a57e591 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/ListModelLoader.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/ListModelLoader.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.adapter.queriable +package com.dbflow5.adapter.queriable -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor /** * Description: Loads a [List] of [T]. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/ModelLoader.kt b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/ModelLoader.kt similarity index 84% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/ModelLoader.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/queriable/ModelLoader.kt index f44ac29df..0f66de445 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/ModelLoader.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/ModelLoader.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.adapter.queriable +package com.dbflow5.adapter.queriable -import com.raizlabs.dbflow5.adapter.RetrievalAdapter -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor +import com.dbflow5.adapter.RetrievalAdapter +import com.dbflow5.config.FlowManager +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor /** * Description: Represents how models load from DB. It will query a [DatabaseWrapper] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/SingleKeyCacheableListModelLoader.kt b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/SingleKeyCacheableListModelLoader.kt similarity index 77% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/SingleKeyCacheableListModelLoader.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/queriable/SingleKeyCacheableListModelLoader.kt index c2441293e..e77016b6f 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/SingleKeyCacheableListModelLoader.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/SingleKeyCacheableListModelLoader.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.adapter.queriable +package com.dbflow5.adapter.queriable -import com.raizlabs.dbflow5.adapter.CacheAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.cache.addOrReload +import com.dbflow5.adapter.CacheAdapter +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.cache.addOrReload /** * Description: diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/SingleKeyCacheableModelLoader.kt b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/SingleKeyCacheableModelLoader.kt similarity index 76% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/SingleKeyCacheableModelLoader.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/queriable/SingleKeyCacheableModelLoader.kt index bb04ad288..c4c45fe02 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/SingleKeyCacheableModelLoader.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/SingleKeyCacheableModelLoader.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.adapter.queriable +package com.dbflow5.adapter.queriable -import com.raizlabs.dbflow5.adapter.CacheAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.cache.addOrReload -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.adapter.CacheAdapter +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.cache.addOrReload +import com.dbflow5.structure.Model /** * Description: More optimized version of [CacheableModelLoader] which assumes that the [Model] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/SingleModelLoader.kt b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/SingleModelLoader.kt similarity index 81% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/SingleModelLoader.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/queriable/SingleModelLoader.kt index 49b38c6e9..867f81b32 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/queriable/SingleModelLoader.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/queriable/SingleModelLoader.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.adapter.queriable +package com.dbflow5.adapter.queriable -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor /** * Description: Responsible for loading data into a single object. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/saveable/CacheableListModelSaver.kt b/lib/src/main/kotlin/com/dbflow5/adapter/saveable/CacheableListModelSaver.kt similarity index 92% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/saveable/CacheableListModelSaver.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/saveable/CacheableListModelSaver.kt index 4c5cd0662..10f3a8b1f 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/saveable/CacheableListModelSaver.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/saveable/CacheableListModelSaver.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.adapter.saveable +package com.dbflow5.adapter.saveable -import com.raizlabs.dbflow5.adapter.CacheAdapter -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.adapter.CacheAdapter +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.database.DatabaseWrapper /** * Description: Used for model caching, enables caching models when saving in list. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/saveable/ListModelSaver.kt b/lib/src/main/kotlin/com/dbflow5/adapter/saveable/ListModelSaver.kt similarity index 92% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/saveable/ListModelSaver.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/saveable/ListModelSaver.kt index aa4c24630..6ffb88e95 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/saveable/ListModelSaver.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/saveable/ListModelSaver.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.adapter.saveable +package com.dbflow5.adapter.saveable -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.database.DatabaseWrapper open class ListModelSaver(val modelSaver: ModelSaver) { diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/saveable/ModelSaver.kt b/lib/src/main/kotlin/com/dbflow5/adapter/saveable/ModelSaver.kt similarity index 91% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/saveable/ModelSaver.kt rename to lib/src/main/kotlin/com/dbflow5/adapter/saveable/ModelSaver.kt index 790ba7324..502ed533c 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/adapter/saveable/ModelSaver.kt +++ b/lib/src/main/kotlin/com/dbflow5/adapter/saveable/ModelSaver.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.adapter.saveable +package com.dbflow5.adapter.saveable -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.runtime.NotifyDistributor -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.runtime.NotifyDistributor +import com.dbflow5.structure.ChangeAction /** * Description: Defines how models get saved into the DB. It will bind values to [DatabaseStatement] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/DBFlowDatabase.kt b/lib/src/main/kotlin/com/dbflow5/config/DBFlowDatabase.kt similarity index 85% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/DBFlowDatabase.kt rename to lib/src/main/kotlin/com/dbflow5/config/DBFlowDatabase.kt index b2ffdb206..fbab7d2a4 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/DBFlowDatabase.kt +++ b/lib/src/main/kotlin/com/dbflow5/config/DBFlowDatabase.kt @@ -1,32 +1,32 @@ -package com.raizlabs.dbflow5.config +package com.dbflow5.config import android.content.ContentValues -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.adapter.ModelViewAdapter -import com.raizlabs.dbflow5.adapter.QueryModelAdapter -import com.raizlabs.dbflow5.adapter.queriable.ListModelLoader -import com.raizlabs.dbflow5.adapter.queriable.SingleModelLoader -import com.raizlabs.dbflow5.adapter.saveable.ModelSaver -import com.raizlabs.dbflow5.annotation.Database -import com.raizlabs.dbflow5.annotation.QueryModel -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.database.AndroidSQLiteOpenHelper -import com.raizlabs.dbflow5.database.DatabaseCallback -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.database.OpenHelper -import com.raizlabs.dbflow5.migration.Migration -import com.raizlabs.dbflow5.runtime.DirectModelNotifier -import com.raizlabs.dbflow5.runtime.ModelNotifier -import com.raizlabs.dbflow5.structure.BaseModelView -import com.raizlabs.dbflow5.transaction.BaseTransactionManager -import com.raizlabs.dbflow5.transaction.DefaultTransactionManager -import com.raizlabs.dbflow5.transaction.DefaultTransactionQueue -import com.raizlabs.dbflow5.transaction.Error -import com.raizlabs.dbflow5.transaction.ITransaction -import com.raizlabs.dbflow5.transaction.Success -import com.raizlabs.dbflow5.transaction.Transaction +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.adapter.ModelViewAdapter +import com.dbflow5.adapter.QueryModelAdapter +import com.dbflow5.adapter.queriable.ListModelLoader +import com.dbflow5.adapter.queriable.SingleModelLoader +import com.dbflow5.adapter.saveable.ModelSaver +import com.dbflow5.annotation.Database +import com.dbflow5.annotation.QueryModel +import com.dbflow5.annotation.Table +import com.dbflow5.database.AndroidSQLiteOpenHelper +import com.dbflow5.database.DatabaseCallback +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.database.OpenHelper +import com.dbflow5.migration.Migration +import com.dbflow5.runtime.DirectModelNotifier +import com.dbflow5.runtime.ModelNotifier +import com.dbflow5.structure.BaseModelView +import com.dbflow5.transaction.BaseTransactionManager +import com.dbflow5.transaction.DefaultTransactionManager +import com.dbflow5.transaction.DefaultTransactionQueue +import com.dbflow5.transaction.Error +import com.dbflow5.transaction.ITransaction +import com.dbflow5.transaction.Success +import com.dbflow5.transaction.Transaction /** * Description: The main interface that all Database implementations extend from. Use this to @@ -185,9 +185,9 @@ abstract class DBFlowDatabase : DatabaseWrapper { for (tableConfig in tableConfigCollection) { val modelAdapter: ModelAdapter = modelAdapters[tableConfig.tableClass] as ModelAdapter? ?: continue - tableConfig.listModelLoader?.let { modelAdapter.listModelLoader = it as ListModelLoader } - tableConfig.singleModelLoader?.let { modelAdapter.singleModelLoader = it as SingleModelLoader } - tableConfig.modelSaver?.let { modelAdapter.modelSaver = it as ModelSaver } + tableConfig.listModelLoader?.let { loader -> modelAdapter.listModelLoader = loader as ListModelLoader } + tableConfig.singleModelLoader?.let { loader -> modelAdapter.singleModelLoader = loader as SingleModelLoader } + tableConfig.modelSaver?.let { saver -> modelAdapter.modelSaver = saver as ModelSaver } } callback = databaseConfig.callback } @@ -200,27 +200,23 @@ abstract class DBFlowDatabase : DatabaseWrapper { protected fun addModelAdapter(modelAdapter: ModelAdapter, holder: DatabaseHolder) { holder.putDatabaseForTable(modelAdapter.table, this) - modelTableNames.put(modelAdapter.tableName, modelAdapter.table) - modelAdapters.put(modelAdapter.table, modelAdapter) + modelTableNames[modelAdapter.tableName] = modelAdapter.table + modelAdapters[modelAdapter.table] = modelAdapter } protected fun addModelViewAdapter(modelViewAdapter: ModelViewAdapter, holder: DatabaseHolder) { holder.putDatabaseForTable(modelViewAdapter.table, this) - modelViewAdapterMap.put(modelViewAdapter.table, modelViewAdapter) + modelViewAdapterMap[modelViewAdapter.table] = modelViewAdapter } protected fun addQueryModelAdapter(queryModelAdapter: QueryModelAdapter, holder: DatabaseHolder) { holder.putDatabaseForTable(queryModelAdapter.table, this) - queryModelAdapterMap.put(queryModelAdapter.table, queryModelAdapter) + queryModelAdapterMap[queryModelAdapter.table] = queryModelAdapter } protected fun addMigration(version: Int, migration: Migration) { - var list: MutableList? = migrationMap[version] - if (list == null) { - list = arrayListOf() - migrationMap.put(version, list) - } - list.add(migration) + val list = migrationMap.getOrPut(version) { arrayListOf() } + list += migration } /** @@ -303,7 +299,7 @@ abstract class DBFlowDatabase : DatabaseWrapper { fun beginTransactionAsync(transaction: ITransaction): Transaction.Builder = Transaction.Builder(transaction, this) - fun beginTransactionAsync(transaction: (DatabaseWrapper) -> R): Transaction.Builder = + inline fun beginTransactionAsync(crossinline transaction: (DatabaseWrapper) -> R): Transaction.Builder = beginTransactionAsync(object : ITransaction { override fun execute(databaseWrapper: DatabaseWrapper) = transaction(databaseWrapper) }) diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/DatabaseConfig.kt b/lib/src/main/kotlin/com/dbflow5/config/DatabaseConfig.kt similarity index 93% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/DatabaseConfig.kt rename to lib/src/main/kotlin/com/dbflow5/config/DatabaseConfig.kt index ffcb539ba..e81cfe7ef 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/DatabaseConfig.kt +++ b/lib/src/main/kotlin/com/dbflow5/config/DatabaseConfig.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.config +package com.dbflow5.config -import com.raizlabs.dbflow5.database.DatabaseCallback -import com.raizlabs.dbflow5.database.OpenHelper -import com.raizlabs.dbflow5.isNotNullOrEmpty -import com.raizlabs.dbflow5.runtime.ModelNotifier -import com.raizlabs.dbflow5.transaction.BaseTransactionManager +import com.dbflow5.database.DatabaseCallback +import com.dbflow5.database.OpenHelper +import com.dbflow5.isNotNullOrEmpty +import com.dbflow5.runtime.ModelNotifier +import com.dbflow5.transaction.BaseTransactionManager import kotlin.reflect.KClass typealias OpenHelperCreator = (DBFlowDatabase, DatabaseCallback?) -> OpenHelper diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/DatabaseHolder.kt b/lib/src/main/kotlin/com/dbflow5/config/DatabaseHolder.kt similarity index 95% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/DatabaseHolder.kt rename to lib/src/main/kotlin/com/dbflow5/config/DatabaseHolder.kt index 264d13969..38d15f40e 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/DatabaseHolder.kt +++ b/lib/src/main/kotlin/com/dbflow5/config/DatabaseHolder.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.config +package com.dbflow5.config -import com.raizlabs.dbflow5.converter.TypeConverter +import com.dbflow5.converter.TypeConverter /** * Description: The base interface for interacting with all of the database and top-level data that's shared diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/FlowConfig.kt b/lib/src/main/kotlin/com/dbflow5/config/FlowConfig.kt similarity index 98% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/FlowConfig.kt rename to lib/src/main/kotlin/com/dbflow5/config/FlowConfig.kt index a08c6fba1..204c285e6 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/FlowConfig.kt +++ b/lib/src/main/kotlin/com/dbflow5/config/FlowConfig.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.config +package com.dbflow5.config import android.content.Context diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/FlowLog.kt b/lib/src/main/kotlin/com/dbflow5/config/FlowLog.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/FlowLog.kt rename to lib/src/main/kotlin/com/dbflow5/config/FlowLog.kt index 87905f18d..bba044ac9 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/FlowLog.kt +++ b/lib/src/main/kotlin/com/dbflow5/config/FlowLog.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.config +package com.dbflow5.config import android.os.Build import android.util.Log -import com.raizlabs.dbflow5.config.FlowLog.Level +import com.dbflow5.config.FlowLog.Level /** * Description: Mirrors [Log] with its own [Level] flag. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/FlowManager.kt b/lib/src/main/kotlin/com/dbflow5/config/FlowManager.kt similarity index 95% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/FlowManager.kt rename to lib/src/main/kotlin/com/dbflow5/config/FlowManager.kt index 39d930001..9d220aaf7 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/FlowManager.kt +++ b/lib/src/main/kotlin/com/dbflow5/config/FlowManager.kt @@ -1,25 +1,25 @@ @file:Suppress("NOTHING_TO_INLINE") -package com.raizlabs.dbflow5.config +package com.dbflow5.config import android.annotation.SuppressLint import android.content.Context -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.adapter.ModelViewAdapter -import com.raizlabs.dbflow5.adapter.QueryModelAdapter -import com.raizlabs.dbflow5.adapter.RetrievalAdapter -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.converter.TypeConverter -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.migration.Migration -import com.raizlabs.dbflow5.quote -import com.raizlabs.dbflow5.runtime.ModelNotifier -import com.raizlabs.dbflow5.runtime.TableNotifierRegister -import com.raizlabs.dbflow5.structure.BaseModel -import com.raizlabs.dbflow5.structure.BaseModelView -import com.raizlabs.dbflow5.structure.BaseQueryModel -import com.raizlabs.dbflow5.structure.InvalidDBConfiguration -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.adapter.ModelViewAdapter +import com.dbflow5.adapter.QueryModelAdapter +import com.dbflow5.adapter.RetrievalAdapter +import com.dbflow5.annotation.Table +import com.dbflow5.converter.TypeConverter +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.migration.Migration +import com.dbflow5.quote +import com.dbflow5.runtime.ModelNotifier +import com.dbflow5.runtime.TableNotifierRegister +import com.dbflow5.structure.BaseModel +import com.dbflow5.structure.BaseModelView +import com.dbflow5.structure.BaseQueryModel +import com.dbflow5.structure.InvalidDBConfiguration +import com.dbflow5.structure.Model import kotlin.reflect.KClass /** @@ -331,7 +331,7 @@ object FlowManager { getModelAdapterOrNull(modelClass) ?: throwCannotFindAdapter("ModelAdapter", modelClass) /** - * Returns the model view adapter for a SQLite VIEW. These are only created with the [com.raizlabs.android.dbflow.annotation.ModelView] annotation. + * Returns the model view adapter for a SQLite VIEW. These are only created with the [com.dbflow5.annotation.ModelView] annotation. * * @param modelViewClass The class of the VIEW * @param [T] The class that extends [BaseModelView] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/NaturalOrderComparator.java b/lib/src/main/kotlin/com/dbflow5/config/NaturalOrderComparator.java similarity index 99% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/NaturalOrderComparator.java rename to lib/src/main/kotlin/com/dbflow5/config/NaturalOrderComparator.java index 8962ad587..9dae66d4b 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/NaturalOrderComparator.java +++ b/lib/src/main/kotlin/com/dbflow5/config/NaturalOrderComparator.java @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.config; +package com.dbflow5.config; /* NaturalOrderComparator.java -- Perform 'natural order' comparisons of strings in Java. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/TableConfig.kt b/lib/src/main/kotlin/com/dbflow5/config/TableConfig.kt similarity index 90% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/TableConfig.kt rename to lib/src/main/kotlin/com/dbflow5/config/TableConfig.kt index ac8c01553..451a8e7eb 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/config/TableConfig.kt +++ b/lib/src/main/kotlin/com/dbflow5/config/TableConfig.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.config +package com.dbflow5.config -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.adapter.queriable.ListModelLoader -import com.raizlabs.dbflow5.adapter.queriable.SingleModelLoader -import com.raizlabs.dbflow5.adapter.saveable.ModelSaver +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.adapter.queriable.ListModelLoader +import com.dbflow5.adapter.queriable.SingleModelLoader +import com.dbflow5.adapter.saveable.ModelSaver import kotlin.reflect.KClass /** diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/AndroidDatabase.kt b/lib/src/main/kotlin/com/dbflow5/database/AndroidDatabase.kt similarity index 95% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/AndroidDatabase.kt rename to lib/src/main/kotlin/com/dbflow5/database/AndroidDatabase.kt index a926d3613..c23214877 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/AndroidDatabase.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/AndroidDatabase.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database import android.content.ContentValues import android.database.sqlite.SQLiteDatabase @@ -82,7 +82,7 @@ class AndroidDatabase internal constructor(val database: SQLiteDatabase) : Datab } } -fun SQLiteException.toDBFlowSQLiteException() = com.raizlabs.dbflow5.database.SQLiteException("A Database Error Occurred", this) +fun SQLiteException.toDBFlowSQLiteException() = com.dbflow5.database.SQLiteException("A Database Error Occurred", this) inline fun rethrowDBFlowException(fn: () -> T) = try { fn() diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/AndroidDatabaseStatement.kt b/lib/src/main/kotlin/com/dbflow5/database/AndroidDatabaseStatement.kt similarity index 98% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/AndroidDatabaseStatement.kt rename to lib/src/main/kotlin/com/dbflow5/database/AndroidDatabaseStatement.kt index 77b0098d0..5caee9af5 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/AndroidDatabaseStatement.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/AndroidDatabaseStatement.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database import android.database.Cursor import android.database.SQLException diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/AndroidSQLiteOpenHelper.kt b/lib/src/main/kotlin/com/dbflow5/database/AndroidSQLiteOpenHelper.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/AndroidSQLiteOpenHelper.kt rename to lib/src/main/kotlin/com/dbflow5/database/AndroidSQLiteOpenHelper.kt index c3796efd9..05a76070b 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/AndroidSQLiteOpenHelper.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/AndroidSQLiteOpenHelper.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database import android.content.Context import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteOpenHelper -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.OpenHelperCreator +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.OpenHelperCreator /** * Description: Wraps around the [SQLiteOpenHelper] and provides extra features for use in this library. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/BaseDatabaseHelper.kt b/lib/src/main/kotlin/com/dbflow5/database/BaseDatabaseHelper.kt similarity index 96% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/BaseDatabaseHelper.kt rename to lib/src/main/kotlin/com/dbflow5/database/BaseDatabaseHelper.kt index f34835989..dd55328ca 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/BaseDatabaseHelper.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/BaseDatabaseHelper.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database import android.content.Context -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.config.NaturalOrderComparator +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.FlowLog +import com.dbflow5.config.NaturalOrderComparator import java.io.IOException import java.io.InputStream @@ -95,7 +95,7 @@ open class BaseDatabaseHelper(protected val context: Context, try { val files: List = context.assets.list( "$MIGRATION_PATH/${databaseDefinition.databaseName}") - .sortedWith(NaturalOrderComparator()) + .sortedWith(com.dbflow5.config.NaturalOrderComparator()) val migrationFileMap = hashMapOf>() for (file in files) { diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/BaseDatabaseStatement.kt b/lib/src/main/kotlin/com/dbflow5/database/BaseDatabaseStatement.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/BaseDatabaseStatement.kt rename to lib/src/main/kotlin/com/dbflow5/database/BaseDatabaseStatement.kt index 927d601b5..f04a59d21 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/BaseDatabaseStatement.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/BaseDatabaseStatement.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database /** * Description: Default implementation for some [DatabaseStatement] methods. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/ContentValueExtensions.kt b/lib/src/main/kotlin/com/dbflow5/database/ContentValueExtensions.kt similarity index 95% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/ContentValueExtensions.kt rename to lib/src/main/kotlin/com/dbflow5/database/ContentValueExtensions.kt index 4977a8fa8..4a86bcbf3 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/ContentValueExtensions.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/ContentValueExtensions.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database import android.content.ContentValues diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseCallback.kt b/lib/src/main/kotlin/com/dbflow5/database/DatabaseCallback.kt similarity index 96% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseCallback.kt rename to lib/src/main/kotlin/com/dbflow5/database/DatabaseCallback.kt index 60fcf8123..d1f0c9b60 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseCallback.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/DatabaseCallback.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database /** * Description: Provides callbacks for [OpenHelper] methods diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseHelperDelegate.kt b/lib/src/main/kotlin/com/dbflow5/database/DatabaseHelperDelegate.kt similarity index 98% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseHelperDelegate.kt rename to lib/src/main/kotlin/com/dbflow5/database/DatabaseHelperDelegate.kt index 4e74d9042..a44d473c4 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseHelperDelegate.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/DatabaseHelperDelegate.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database import android.content.Context -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.transaction.DefaultTransactionQueue +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.FlowLog +import com.dbflow5.transaction.DefaultTransactionQueue import java.io.File import java.io.FileInputStream import java.io.FileOutputStream diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseStatement.kt b/lib/src/main/kotlin/com/dbflow5/database/DatabaseStatement.kt similarity index 96% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseStatement.kt rename to lib/src/main/kotlin/com/dbflow5/database/DatabaseStatement.kt index 0ce95bf9e..b599a99fe 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseStatement.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/DatabaseStatement.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database import java.io.Closeable diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseStatementWrapper.kt b/lib/src/main/kotlin/com/dbflow5/database/DatabaseStatementWrapper.kt similarity index 92% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseStatementWrapper.kt rename to lib/src/main/kotlin/com/dbflow5/database/DatabaseStatementWrapper.kt index ed2a4811f..2973f8cc0 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseStatementWrapper.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/DatabaseStatementWrapper.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database -import com.raizlabs.dbflow5.query.BaseQueriable -import com.raizlabs.dbflow5.runtime.NotifyDistributor +import com.dbflow5.query.BaseQueriable +import com.dbflow5.runtime.NotifyDistributor /** * Description: Delegates all of its calls to the contained [DatabaseStatement], while diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseWrapper.kt b/lib/src/main/kotlin/com/dbflow5/database/DatabaseWrapper.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseWrapper.kt rename to lib/src/main/kotlin/com/dbflow5/database/DatabaseWrapper.kt index 03054dc84..aa7d29b80 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/DatabaseWrapper.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/DatabaseWrapper.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database import android.content.ContentValues diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/FlowCursor.kt b/lib/src/main/kotlin/com/dbflow5/database/FlowCursor.kt similarity index 99% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/FlowCursor.kt rename to lib/src/main/kotlin/com/dbflow5/database/FlowCursor.kt index 2a5b6cdee..c6094f189 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/FlowCursor.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/FlowCursor.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database import android.database.Cursor import android.database.CursorWrapper diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/OpenHelper.kt b/lib/src/main/kotlin/com/dbflow5/database/OpenHelper.kt similarity index 92% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/OpenHelper.kt rename to lib/src/main/kotlin/com/dbflow5/database/OpenHelper.kt index e233c3206..b48afc85a 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/OpenHelper.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/OpenHelper.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database /** * Description: Abstracts out the [DatabaseHelperDelegate] into the one used in this library. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/SQLiteException.kt b/lib/src/main/kotlin/com/dbflow5/database/SQLiteException.kt similarity index 86% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/SQLiteException.kt rename to lib/src/main/kotlin/com/dbflow5/database/SQLiteException.kt index 00d330c96..090641daa 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/database/SQLiteException.kt +++ b/lib/src/main/kotlin/com/dbflow5/database/SQLiteException.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.database +package com.dbflow5.database /** * Description: DBFlow mirror to an Android SQLiteException. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/AlterTableMigration.kt b/lib/src/main/kotlin/com/dbflow5/migration/AlterTableMigration.kt similarity index 92% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/AlterTableMigration.kt rename to lib/src/main/kotlin/com/dbflow5/migration/AlterTableMigration.kt index 29231d187..bd35d3a87 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/AlterTableMigration.kt +++ b/lib/src/main/kotlin/com/dbflow5/migration/AlterTableMigration.kt @@ -1,13 +1,13 @@ -package com.raizlabs.dbflow5.migration +package com.dbflow5.migration import android.support.annotation.CallSuper -import com.raizlabs.dbflow5.appendQuotedIfNeeded -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.quoteIfNeeded -import com.raizlabs.dbflow5.sql.SQLiteType -import com.raizlabs.dbflow5.stripQuotes +import com.dbflow5.appendQuotedIfNeeded +import com.dbflow5.config.FlowManager +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.select +import com.dbflow5.quoteIfNeeded +import com.dbflow5.sql.SQLiteType +import com.dbflow5.stripQuotes /** * Description: Provides a very nice way to alter a single table quickly and easily. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/BaseMigration.kt b/lib/src/main/kotlin/com/dbflow5/migration/BaseMigration.kt similarity index 78% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/BaseMigration.kt rename to lib/src/main/kotlin/com/dbflow5/migration/BaseMigration.kt index 6dfe25845..312807386 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/BaseMigration.kt +++ b/lib/src/main/kotlin/com/dbflow5/migration/BaseMigration.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.migration +package com.dbflow5.migration -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.DatabaseWrapper /** * Description: Provides the base implementation of [Migration] with diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/IndexMigration.kt b/lib/src/main/kotlin/com/dbflow5/migration/IndexMigration.kt similarity index 83% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/IndexMigration.kt rename to lib/src/main/kotlin/com/dbflow5/migration/IndexMigration.kt index 87bf225d5..d91875df8 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/IndexMigration.kt +++ b/lib/src/main/kotlin/com/dbflow5/migration/IndexMigration.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.migration +package com.dbflow5.migration -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.index -import com.raizlabs.dbflow5.query.property.IProperty +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.index +import com.dbflow5.query.property.IProperty /** * Description: Defines and enables an Index structurally through a migration. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/IndexPropertyMigration.kt b/lib/src/main/kotlin/com/dbflow5/migration/IndexPropertyMigration.kt similarity index 78% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/IndexPropertyMigration.kt rename to lib/src/main/kotlin/com/dbflow5/migration/IndexPropertyMigration.kt index b6f598648..a1df9ac51 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/IndexPropertyMigration.kt +++ b/lib/src/main/kotlin/com/dbflow5/migration/IndexPropertyMigration.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.migration +package com.dbflow5.migration -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.property.IndexProperty +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.property.IndexProperty /** * Description: Allows you to specify if and when an [IndexProperty] gets used or created. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/Migration.kt b/lib/src/main/kotlin/com/dbflow5/migration/Migration.kt similarity index 77% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/Migration.kt rename to lib/src/main/kotlin/com/dbflow5/migration/Migration.kt index 4e88cf5fb..6e2a99d86 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/Migration.kt +++ b/lib/src/main/kotlin/com/dbflow5/migration/Migration.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.migration +package com.dbflow5.migration -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.DatabaseWrapper /** - * Description: Called when the Database is migrating. We can perform custom migrations here. A [com.raizlabs.android.dbflow.annotation.Migration] + * Description: Called when the Database is migrating. We can perform custom migrations here. A [com.dbflow5.annotation.Migration] * is required for registering this class to automatically be called in an upgrade of the DB. */ interface Migration { diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/UpdateTableMigration.kt b/lib/src/main/kotlin/com/dbflow5/migration/UpdateTableMigration.kt similarity index 80% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/UpdateTableMigration.kt rename to lib/src/main/kotlin/com/dbflow5/migration/UpdateTableMigration.kt index eac10978f..7af1882cd 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/migration/UpdateTableMigration.kt +++ b/lib/src/main/kotlin/com/dbflow5/migration/UpdateTableMigration.kt @@ -1,14 +1,14 @@ -package com.raizlabs.dbflow5.migration +package com.dbflow5.migration -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.BaseQueriable -import com.raizlabs.dbflow5.query.OperatorGroup -import com.raizlabs.dbflow5.query.SQLOperator -import com.raizlabs.dbflow5.query.update +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.BaseQueriable +import com.dbflow5.query.OperatorGroup +import com.dbflow5.query.SQLOperator +import com.dbflow5.query.update /** * Description: Provides a simple way to update a table's field or fields quickly in a migration. - * It ties an SQLite [com.raizlabs.android.dbflow.sql.language.Update] + * It ties an SQLite [com.dbflow5.sql.language.Update] * to migrations whenever we want to batch update tables in a structured manner. */ open class UpdateTableMigration diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Actionable.kt b/lib/src/main/kotlin/com/dbflow5/query/Actionable.kt similarity index 59% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Actionable.kt rename to lib/src/main/kotlin/com/dbflow5/query/Actionable.kt index 46e6acb8c..e31c4afc0 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Actionable.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Actionable.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.structure.ChangeAction /** * Description: Provides [Action] for SQL constructs. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseModelQueriable.kt b/lib/src/main/kotlin/com/dbflow5/query/BaseModelQueriable.kt similarity index 86% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseModelQueriable.kt rename to lib/src/main/kotlin/com/dbflow5/query/BaseModelQueriable.kt index 4f339f1b7..174241a0f 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseModelQueriable.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/BaseModelQueriable.kt @@ -1,15 +1,15 @@ -package com.raizlabs.dbflow5.query - -import com.raizlabs.dbflow5.adapter.RetrievalAdapter -import com.raizlabs.dbflow5.adapter.queriable.ListModelLoader -import com.raizlabs.dbflow5.adapter.queriable.SingleModelLoader -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.config.queryModelAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.list.FlowCursorList -import com.raizlabs.dbflow5.query.list.FlowQueryList -import com.raizlabs.dbflow5.sql.Query +package com.dbflow5.query + +import com.dbflow5.adapter.RetrievalAdapter +import com.dbflow5.adapter.queriable.ListModelLoader +import com.dbflow5.adapter.queriable.SingleModelLoader +import com.dbflow5.config.FlowLog +import com.dbflow5.config.FlowManager +import com.dbflow5.config.queryModelAdapter +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.list.FlowCursorList +import com.dbflow5.query.list.FlowQueryList +import com.dbflow5.sql.Query /** * Description: Provides a base implementation of [ModelQueriable] to simplify a lot of code. It provides the diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseOperator.kt b/lib/src/main/kotlin/com/dbflow5/query/BaseOperator.kt similarity index 96% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseOperator.kt rename to lib/src/main/kotlin/com/dbflow5/query/BaseOperator.kt index b06382c5d..bfe2ef9c9 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseOperator.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/BaseOperator.kt @@ -1,11 +1,11 @@ -package com.raizlabs.dbflow5.query - -import com.raizlabs.dbflow5.byteArrayToHexString -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.converter.TypeConverter -import com.raizlabs.dbflow5.data.Blob -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.sqlEscapeString +package com.dbflow5.query + +import com.dbflow5.byteArrayToHexString +import com.dbflow5.config.FlowManager +import com.dbflow5.converter.TypeConverter +import com.dbflow5.data.Blob +import com.dbflow5.sql.Query +import com.dbflow5.sqlEscapeString /** * Description: Base class for all kinds of [SQLOperator] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseQueriable.kt b/lib/src/main/kotlin/com/dbflow5/query/BaseQueriable.kt similarity index 81% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseQueriable.kt rename to lib/src/main/kotlin/com/dbflow5/query/BaseQueriable.kt index 38f7fc8f3..c3c5ba2d1 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseQueriable.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/BaseQueriable.kt @@ -1,14 +1,14 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseStatementWrapper -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.database.SQLiteException -import com.raizlabs.dbflow5.longForQuery -import com.raizlabs.dbflow5.runtime.NotifyDistributor -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.config.FlowLog +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.database.DatabaseStatementWrapper +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.database.SQLiteException +import com.dbflow5.longForQuery +import com.dbflow5.runtime.NotifyDistributor +import com.dbflow5.structure.ChangeAction /** * Description: Base implementation of something that can be queried from the database. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseTransformable.kt b/lib/src/main/kotlin/com/dbflow5/query/BaseTransformable.kt similarity index 92% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseTransformable.kt rename to lib/src/main/kotlin/com/dbflow5/query/BaseTransformable.kt index 281e51fa9..0fa16898a 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/BaseTransformable.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/BaseTransformable.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.property.IProperty +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.property.IProperty /** * Description: Combines basic transformations and query ops into a base class. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Case.kt b/lib/src/main/kotlin/com/dbflow5/query/Case.kt similarity index 94% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Case.kt rename to lib/src/main/kotlin/com/dbflow5/query/Case.kt index 446fff953..b33f539ff 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Case.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Case.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.query.property.Property -import com.raizlabs.dbflow5.quoteIfNeeded -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.query.property.IProperty +import com.dbflow5.query.property.Property +import com.dbflow5.quoteIfNeeded +import com.dbflow5.sql.Query /** * Description: Represents a SQLITE CASE argument. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/CaseCondition.kt b/lib/src/main/kotlin/com/dbflow5/query/CaseCondition.kt similarity index 93% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/CaseCondition.kt rename to lib/src/main/kotlin/com/dbflow5/query/CaseCondition.kt index 7896f67e0..62e7a8514 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/CaseCondition.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/CaseCondition.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.query.property.IProperty +import com.dbflow5.sql.Query /** * Description: Represents an individual condition inside a CASE. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/CompletedTrigger.kt b/lib/src/main/kotlin/com/dbflow5/query/CompletedTrigger.kt similarity index 88% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/CompletedTrigger.kt rename to lib/src/main/kotlin/com/dbflow5/query/CompletedTrigger.kt index 017797be0..15cfa45db 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/CompletedTrigger.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/CompletedTrigger.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.dropTrigger -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.dropTrigger +import com.dbflow5.sql.Query /** * Description: The last piece of a TRIGGER statement, this class contains the BEGIN...END and the logic in between. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/ContentValuesListener.kt b/lib/src/main/kotlin/com/dbflow5/query/ContentValuesListener.kt similarity index 84% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/ContentValuesListener.kt rename to lib/src/main/kotlin/com/dbflow5/query/ContentValuesListener.kt index 9dba4738c..d2f7c9860 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/ContentValuesListener.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/ContentValuesListener.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query import android.content.ContentValues -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.annotation.provider.ContentProvider -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.annotation.Table +import com.dbflow5.annotation.provider.ContentProvider +import com.dbflow5.structure.Model /** * Description: Called after the declared [ContentValues] are binded. It enables diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Delete.kt b/lib/src/main/kotlin/com/dbflow5/query/Delete.kt similarity index 88% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Delete.kt rename to lib/src/main/kotlin/com/dbflow5/query/Delete.kt index eec706187..210047780 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Delete.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Delete.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.sql.Query import kotlin.reflect.KClass /** @@ -36,7 +36,7 @@ class Delete internal constructor() : Query { * * @param table The table to delete * @param conditions The list of conditions to use to delete from the specified table - * @param [T] The class that implements [com.raizlabs.dbflow5.structure.Model] + * @param [T] The class that implements [com.dbflow5.structure.Model] */ @JvmStatic fun table(databaseWrapper: DatabaseWrapper, diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/ExistenceOperator.kt b/lib/src/main/kotlin/com/dbflow5/query/ExistenceOperator.kt similarity index 88% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/ExistenceOperator.kt rename to lib/src/main/kotlin/com/dbflow5/query/ExistenceOperator.kt index 8bf229a4a..95ddb8572 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/ExistenceOperator.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/ExistenceOperator.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.appendQualifier -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.appendQualifier +import com.dbflow5.sql.Query /** * Description: The condition that represents EXISTS in a SQL statement. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/From.kt b/lib/src/main/kotlin/com/dbflow5/query/From.kt similarity index 96% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/From.kt rename to lib/src/main/kotlin/com/dbflow5/query/From.kt index b4256e89f..915268ec0 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/From.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/From.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.query.Join.JoinType -import com.raizlabs.dbflow5.query.property.IndexProperty -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.config.FlowManager +import com.dbflow5.query.Join.JoinType +import com.dbflow5.query.property.IndexProperty +import com.dbflow5.sql.Query +import com.dbflow5.structure.ChangeAction import kotlin.reflect.KClass import kotlin.collections.Set as KSet diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/IConditional.kt b/lib/src/main/kotlin/com/dbflow5/query/IConditional.kt similarity index 98% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/IConditional.kt rename to lib/src/main/kotlin/com/dbflow5/query/IConditional.kt index f2148003d..e73a3a34a 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/IConditional.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/IConditional.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.sql.Query /** * Description: Simple interface for objects that can be used as [Operator]. This class diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/IOperator.kt b/lib/src/main/kotlin/com/dbflow5/query/IOperator.kt similarity index 98% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/IOperator.kt rename to lib/src/main/kotlin/com/dbflow5/query/IOperator.kt index a03ef8b20..37622a1b9 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/IOperator.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/IOperator.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.sql.Query /** * Description: Interface for objects that can be used as [Operator] that have a type parameter. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Index.kt b/lib/src/main/kotlin/com/dbflow5/query/Index.kt similarity index 89% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Index.kt rename to lib/src/main/kotlin/com/dbflow5/query/Index.kt index eb7f7940b..9cd176e9a 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Index.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Index.kt @@ -1,13 +1,13 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.appendList -import com.raizlabs.dbflow5.appendQuotedIfNeeded -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.SQLiteException -import com.raizlabs.dbflow5.dropIndex -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.appendList +import com.dbflow5.appendQuotedIfNeeded +import com.dbflow5.config.FlowManager +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.SQLiteException +import com.dbflow5.dropIndex +import com.dbflow5.query.property.IProperty +import com.dbflow5.sql.Query /** * Description: an INDEX class that enables you to index a specific column from a table. This enables diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/IndexedBy.kt b/lib/src/main/kotlin/com/dbflow5/query/IndexedBy.kt similarity index 80% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/IndexedBy.kt rename to lib/src/main/kotlin/com/dbflow5/query/IndexedBy.kt index 5514d0103..bd469583f 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/IndexedBy.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/IndexedBy.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.query.property.IndexProperty -import com.raizlabs.dbflow5.quoteIfNeeded -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.query.property.IndexProperty +import com.dbflow5.quoteIfNeeded +import com.dbflow5.sql.Query +import com.dbflow5.structure.ChangeAction /** * Description: The INDEXED BY part of a SELECT/UPDATE/DELETE diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Insert.kt b/lib/src/main/kotlin/com/dbflow5/query/Insert.kt similarity index 95% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Insert.kt rename to lib/src/main/kotlin/com/dbflow5/query/Insert.kt index 7130638f5..f93790357 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Insert.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Insert.kt @@ -1,15 +1,15 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query import android.content.ContentValues -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.appendArray -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.config.modelAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.query.property.Property -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.annotation.ConflictAction +import com.dbflow5.appendArray +import com.dbflow5.config.FlowManager +import com.dbflow5.config.modelAdapter +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.property.IProperty +import com.dbflow5.query.property.Property +import com.dbflow5.sql.Query +import com.dbflow5.structure.ChangeAction /** * Description: The SQLite INSERT command diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Join.kt b/lib/src/main/kotlin/com/dbflow5/query/Join.kt similarity index 95% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Join.kt rename to lib/src/main/kotlin/com/dbflow5/query/Join.kt index 458d686c2..c5c9bee47 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Join.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Join.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.appendList -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.query.property.PropertyFactory -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.appendList +import com.dbflow5.config.FlowManager +import com.dbflow5.query.property.IProperty +import com.dbflow5.query.property.PropertyFactory +import com.dbflow5.sql.Query /** * Description: Specifies a SQLite JOIN statement diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/LoadFromCursorListener.kt b/lib/src/main/kotlin/com/dbflow5/query/LoadFromCursorListener.kt similarity index 72% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/LoadFromCursorListener.kt rename to lib/src/main/kotlin/com/dbflow5/query/LoadFromCursorListener.kt index 35f590958..295dcc900 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/LoadFromCursorListener.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/LoadFromCursorListener.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.database.FlowCursor +import com.dbflow5.structure.Model /** * Description: Marks a [Model] as listening to [FlowCursor] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Method.kt b/lib/src/main/kotlin/com/dbflow5/query/Method.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Method.kt rename to lib/src/main/kotlin/com/dbflow5/query/Method.kt index 5291afbfb..d49ac6567 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Method.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Method.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.query.property.Property -import com.raizlabs.dbflow5.query.property.PropertyFactory -import com.raizlabs.dbflow5.sql.SQLiteType +import com.dbflow5.query.property.IProperty +import com.dbflow5.query.property.Property +import com.dbflow5.query.property.PropertyFactory +import com.dbflow5.sql.SQLiteType /** * Represents SQLite methods on columns. These act as [Property] so we can use them in complex diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/ModelQueriable.kt b/lib/src/main/kotlin/com/dbflow5/query/ModelQueriable.kt similarity index 90% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/ModelQueriable.kt rename to lib/src/main/kotlin/com/dbflow5/query/ModelQueriable.kt index b4196efd8..074999ad8 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/ModelQueriable.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/ModelQueriable.kt @@ -1,11 +1,11 @@ -package com.raizlabs.dbflow5.query - -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.list.FlowCursorList -import com.raizlabs.dbflow5.query.list.FlowQueryList -import com.raizlabs.dbflow5.structure.BaseQueryModel +package com.dbflow5.query + +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.databaseForTable +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.list.FlowCursorList +import com.dbflow5.query.list.FlowQueryList +import com.dbflow5.structure.BaseQueryModel /** diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/NameAlias.kt b/lib/src/main/kotlin/com/dbflow5/query/NameAlias.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/NameAlias.kt rename to lib/src/main/kotlin/com/dbflow5/query/NameAlias.kt index 516a2e085..b3703ee14 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/NameAlias.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/NameAlias.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.isNotNullOrEmpty -import com.raizlabs.dbflow5.quoteIfNeeded -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.stripQuotes +import com.dbflow5.isNotNullOrEmpty +import com.dbflow5.quoteIfNeeded +import com.dbflow5.sql.Query +import com.dbflow5.stripQuotes /** * Description: Rewritten from the ground up, this class makes it easier to build an alias. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Operator.kt b/lib/src/main/kotlin/com/dbflow5/query/Operator.kt similarity index 98% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Operator.kt rename to lib/src/main/kotlin/com/dbflow5/query/Operator.kt index 8d29d196a..157a33f54 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Operator.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Operator.kt @@ -1,14 +1,14 @@ @file:Suppress("UNCHECKED_CAST") -package com.raizlabs.dbflow5.query - -import com.raizlabs.dbflow5.annotation.Collate -import com.raizlabs.dbflow5.appendOptional -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.converter.TypeConverter -import com.raizlabs.dbflow5.query.property.Property -import com.raizlabs.dbflow5.sql.Query +package com.dbflow5.query + +import com.dbflow5.annotation.Collate +import com.dbflow5.appendOptional +import com.dbflow5.config.FlowLog +import com.dbflow5.config.FlowManager +import com.dbflow5.converter.TypeConverter +import com.dbflow5.query.property.Property +import com.dbflow5.sql.Query /** * Description: The class that contains a column name, Operator, and value. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/OperatorGroup.kt b/lib/src/main/kotlin/com/dbflow5/query/OperatorGroup.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/OperatorGroup.kt rename to lib/src/main/kotlin/com/dbflow5/query/OperatorGroup.kt index aca990cc9..10b6b6686 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/OperatorGroup.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/OperatorGroup.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.query.Operator.Operation -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.query.Operator.Operation +import com.dbflow5.sql.Query /** * Allows combining of [SQLOperator] into one condition. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/OrderBy.kt b/lib/src/main/kotlin/com/dbflow5/query/OrderBy.kt similarity index 91% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/OrderBy.kt rename to lib/src/main/kotlin/com/dbflow5/query/OrderBy.kt index e4557e1b7..6532176b2 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/OrderBy.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/OrderBy.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.annotation.Collate -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.annotation.Collate +import com.dbflow5.query.property.IProperty +import com.dbflow5.sql.Query /** * Description: Class that represents a SQL order-by. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Queriable.kt b/lib/src/main/kotlin/com/dbflow5/query/Queriable.kt similarity index 82% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Queriable.kt rename to lib/src/main/kotlin/com/dbflow5/query/Queriable.kt index 755577d0a..9f472e7af 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Queriable.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Queriable.kt @@ -1,12 +1,12 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.structure.ChangeAction -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.config.databaseForTable +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.sql.Query +import com.dbflow5.structure.ChangeAction +import com.dbflow5.structure.Model /** * Description: The most basic interface that some of the classes such as [Insert], [ModelQueriable], diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/SQLOperator.kt b/lib/src/main/kotlin/com/dbflow5/query/SQLOperator.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/SQLOperator.kt rename to lib/src/main/kotlin/com/dbflow5/query/SQLOperator.kt index 2a628afd6..4a551a631 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/SQLOperator.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/SQLOperator.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query /** * Description: Basic interface for all of the Operator classes. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/SQLite.kt b/lib/src/main/kotlin/com/dbflow5/query/SQLite.kt similarity index 95% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/SQLite.kt rename to lib/src/main/kotlin/com/dbflow5/query/SQLite.kt index d8b24ff68..bf6f2b5fc 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/SQLite.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/SQLite.kt @@ -1,11 +1,11 @@ @file:JvmName("SQLite") -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.query.property.Property -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.query.property.IProperty +import com.dbflow5.query.property.Property +import com.dbflow5.structure.Model import kotlin.reflect.KClass diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/SQLiteStatementListener.kt b/lib/src/main/kotlin/com/dbflow5/query/SQLiteStatementListener.kt similarity index 78% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/SQLiteStatementListener.kt rename to lib/src/main/kotlin/com/dbflow5/query/SQLiteStatementListener.kt index 11d5ed86d..6a74d9742 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/SQLiteStatementListener.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/SQLiteStatementListener.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.adapter.InternalAdapter -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.adapter.InternalAdapter +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.structure.Model /** * Description: Marks a [Model] as subscribing to the [DatabaseStatement] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Select.kt b/lib/src/main/kotlin/com/dbflow5/query/Select.kt similarity index 88% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Select.kt rename to lib/src/main/kotlin/com/dbflow5/query/Select.kt index cd5eb205c..e88d1f106 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Select.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Select.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.query.property.Property -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.sql.QueryCloneable +import com.dbflow5.query.property.IProperty +import com.dbflow5.query.property.Property +import com.dbflow5.sql.Query +import com.dbflow5.sql.QueryCloneable import kotlin.reflect.KClass /** @@ -11,7 +11,7 @@ import kotlin.reflect.KClass */ class Select /** - * Creates this instance with the specified columns from the specified [com.raizlabs.dbflow5.config.FlowManager] + * Creates this instance with the specified columns from the specified [com.dbflow5.config.FlowManager] * * @param properties The properties to select from. */ @@ -52,7 +52,7 @@ internal constructor(vararg properties: IProperty<*>) : Query, QueryCloneable from(table: Class): From = From(this, table) diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Set.kt b/lib/src/main/kotlin/com/dbflow5/query/Set.kt similarity index 81% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Set.kt rename to lib/src/main/kotlin/com/dbflow5/query/Set.kt index 07def1a8b..83fe63a0a 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Set.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Set.kt @@ -1,15 +1,15 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query import android.content.ContentValues -import com.raizlabs.dbflow5.addContentValues -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.addContentValues +import com.dbflow5.sql.Query +import com.dbflow5.structure.ChangeAction /** - * Description: Used to specify the SET part of an [com.raizlabs.dbflow5.query.Update] query. + * Description: Used to specify the SET part of an [com.dbflow5.query.Update] query. */ class Set internal constructor( - override val queryBuilderBase: Query, table: Class) + override val queryBuilderBase: Query, table: Class) : BaseTransformable(table), WhereBase { private val operatorGroup: OperatorGroup = OperatorGroup.nonGroupingClause().setAllCommaSeparated(true) diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/StringQuery.kt b/lib/src/main/kotlin/com/dbflow5/query/StringQuery.kt similarity index 86% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/StringQuery.kt rename to lib/src/main/kotlin/com/dbflow5/query/StringQuery.kt index c052e77c6..b00f0056d 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/StringQuery.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/StringQuery.kt @@ -1,14 +1,13 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query import android.database.sqlite.SQLiteDatabase -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseStatementWrapper -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.runtime.NotifyDistributor -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.config.FlowLog +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.database.DatabaseStatementWrapper +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.sql.Query +import com.dbflow5.structure.ChangeAction /** * Description: Provides a very basic query mechanism for strings. Allows you to easily perform custom SQL cursor string diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Transformable.kt b/lib/src/main/kotlin/com/dbflow5/query/Transformable.kt similarity index 93% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Transformable.kt rename to lib/src/main/kotlin/com/dbflow5/query/Transformable.kt index 33652f2d1..07079a29f 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Transformable.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Transformable.kt @@ -1,9 +1,9 @@ @file:JvmName("TransformableUtils") -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.sql.QueryCloneable +import com.dbflow5.query.property.IProperty +import com.dbflow5.sql.QueryCloneable /** * Description: Provides a standard set of methods for ending a SQLite query method. These include diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Trigger.kt b/lib/src/main/kotlin/com/dbflow5/query/Trigger.kt similarity index 93% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Trigger.kt rename to lib/src/main/kotlin/com/dbflow5/query/Trigger.kt index 1c2c4cce8..3be03c760 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Trigger.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Trigger.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.appendOptional -import com.raizlabs.dbflow5.appendQuotedIfNeeded -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.appendOptional +import com.dbflow5.appendQuotedIfNeeded +import com.dbflow5.query.property.IProperty +import com.dbflow5.sql.Query import kotlin.reflect.KClass /** diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/TriggerMethod.kt b/lib/src/main/kotlin/com/dbflow5/query/TriggerMethod.kt similarity index 91% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/TriggerMethod.kt rename to lib/src/main/kotlin/com/dbflow5/query/TriggerMethod.kt index 9c4c36efa..5853a5240 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/TriggerMethod.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/TriggerMethod.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.appendArray -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.appendArray +import com.dbflow5.config.FlowManager +import com.dbflow5.query.property.IProperty +import com.dbflow5.sql.Query /** * Description: Describes the method that the trigger uses. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/UnSafeStringOperator.kt b/lib/src/main/kotlin/com/dbflow5/query/UnSafeStringOperator.kt similarity index 91% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/UnSafeStringOperator.kt rename to lib/src/main/kotlin/com/dbflow5/query/UnSafeStringOperator.kt index b70770a3b..41cdd010a 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/UnSafeStringOperator.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/UnSafeStringOperator.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.isNotNullOrEmpty -import com.raizlabs.dbflow5.sql.Query +import com.dbflow5.isNotNullOrEmpty +import com.dbflow5.sql.Query /** * Description: This class will use a String to describe its condition. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Update.kt b/lib/src/main/kotlin/com/dbflow5/query/Update.kt similarity index 90% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Update.kt rename to lib/src/main/kotlin/com/dbflow5/query/Update.kt index 6d6f38c2a..b9b1feb31 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Update.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Update.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.sql.QueryCloneable +import com.dbflow5.annotation.ConflictAction +import com.dbflow5.config.FlowManager +import com.dbflow5.sql.Query +import com.dbflow5.sql.QueryCloneable /** * Description: The SQLite UPDATE query. Will update rows in the DB. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Where.kt b/lib/src/main/kotlin/com/dbflow5/query/Where.kt similarity index 92% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Where.kt rename to lib/src/main/kotlin/com/dbflow5/query/Where.kt index 3efda3e82..530a97977 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/Where.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/Where.kt @@ -1,19 +1,19 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.annotation.provider.ContentProvider -import com.raizlabs.dbflow5.appendQualifier -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.sql.QueryCloneable -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.annotation.provider.ContentProvider +import com.dbflow5.appendQualifier +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.property.IProperty +import com.dbflow5.sql.QueryCloneable +import com.dbflow5.structure.ChangeAction /** * Description: Defines the SQL WHERE statement of the query. */ class Where /** - * Constructs this class with the specified [com.raizlabs.dbflow5.config.FlowManager] + * Constructs this class with the specified [com.dbflow5.config.FlowManager] * and [From] chunk * * @param whereBase The FROM or SET statement chunk diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/WhereBase.kt b/lib/src/main/kotlin/com/dbflow5/query/WhereBase.kt similarity index 72% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/WhereBase.kt rename to lib/src/main/kotlin/com/dbflow5/query/WhereBase.kt index 567d42780..c19880bc7 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/WhereBase.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/WhereBase.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.query +package com.dbflow5.query -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.sql.QueryCloneable +import com.dbflow5.sql.Query +import com.dbflow5.sql.QueryCloneable /** * Description: The base for a [Where] statement. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/IMultiKeyCacheConverter.kt b/lib/src/main/kotlin/com/dbflow5/query/cache/IMultiKeyCacheConverter.kt similarity index 88% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/IMultiKeyCacheConverter.kt rename to lib/src/main/kotlin/com/dbflow5/query/cache/IMultiKeyCacheConverter.kt index d1984249a..ca208d80b 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/IMultiKeyCacheConverter.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/cache/IMultiKeyCacheConverter.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.query.cache +package com.dbflow5.query.cache -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.structure.Model /** * Description: This interface allows for [Model] to have multiple primary keys in a cache. This diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/ModelCache.kt b/lib/src/main/kotlin/com/dbflow5/query/cache/ModelCache.kt similarity index 87% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/ModelCache.kt rename to lib/src/main/kotlin/com/dbflow5/query/cache/ModelCache.kt index 102c8b666..f990b01eb 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/ModelCache.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/cache/ModelCache.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.query.cache +package com.dbflow5.query.cache -import com.raizlabs.dbflow5.adapter.CacheAdapter -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor +import com.dbflow5.adapter.CacheAdapter +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor /** * Description: A generic cache for models that is implemented or can be implemented to your liking. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/ModelLruCache.kt b/lib/src/main/kotlin/com/dbflow5/query/cache/ModelLruCache.kt similarity index 94% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/ModelLruCache.kt rename to lib/src/main/kotlin/com/dbflow5/query/cache/ModelLruCache.kt index 41a709581..03992b3d5 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/ModelLruCache.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/cache/ModelLruCache.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.query.cache +package com.dbflow5.query.cache import android.util.LruCache -import com.raizlabs.dbflow5.annotation.DEFAULT_CACHE_SIZE +import com.dbflow5.annotation.DEFAULT_CACHE_SIZE /** * Description: Provides an [android.util.LruCache] under its hood diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/SimpleMapCache.kt b/lib/src/main/kotlin/com/dbflow5/query/cache/SimpleMapCache.kt similarity index 89% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/SimpleMapCache.kt rename to lib/src/main/kotlin/com/dbflow5/query/cache/SimpleMapCache.kt index 98a471bf5..f76ba6e28 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/SimpleMapCache.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/cache/SimpleMapCache.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.query.cache +package com.dbflow5.query.cache -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.config.FlowLog +import com.dbflow5.structure.Model import java.util.HashMap /** diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/SparseArrayBasedCache.kt b/lib/src/main/kotlin/com/dbflow5/query/cache/SparseArrayBasedCache.kt similarity index 95% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/SparseArrayBasedCache.kt rename to lib/src/main/kotlin/com/dbflow5/query/cache/SparseArrayBasedCache.kt index 1a48c1bba..63357f01b 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/cache/SparseArrayBasedCache.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/cache/SparseArrayBasedCache.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.query.cache +package com.dbflow5.query.cache import android.util.SparseArray -import com.raizlabs.dbflow5.config.FlowLog +import com.dbflow5.config.FlowLog /** * Description: A cache backed by a [android.util.SparseArray] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/FlowCursorIterator.kt b/lib/src/main/kotlin/com/dbflow5/query/list/FlowCursorIterator.kt similarity index 93% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/FlowCursorIterator.kt rename to lib/src/main/kotlin/com/dbflow5/query/list/FlowCursorIterator.kt index d88e41341..a34d9da9b 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/FlowCursorIterator.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/list/FlowCursorIterator.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.query.list +package com.dbflow5.query.list -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.ModelQueriable -import com.raizlabs.dbflow5.query.Transformable -import com.raizlabs.dbflow5.query.constrain -import com.raizlabs.dbflow5.sql.QueryCloneable +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.ModelQueriable +import com.dbflow5.query.Transformable +import com.dbflow5.query.constrain +import com.dbflow5.sql.QueryCloneable import java.io.Closeable /** diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/FlowCursorList.kt b/lib/src/main/kotlin/com/dbflow5/query/list/FlowCursorList.kt similarity index 94% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/FlowCursorList.kt rename to lib/src/main/kotlin/com/dbflow5/query/list/FlowCursorList.kt index 3c7dc9aa4..cc2f7f05b 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/FlowCursorList.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/list/FlowCursorList.kt @@ -1,12 +1,12 @@ -package com.raizlabs.dbflow5.query.list +package com.dbflow5.query.list import android.widget.ListView -import com.raizlabs.dbflow5.adapter.RetrievalAdapter -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.ModelQueriable +import com.dbflow5.adapter.RetrievalAdapter +import com.dbflow5.config.FlowLog +import com.dbflow5.config.FlowManager +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.ModelQueriable /** * Description: A non-modifiable, cursor-backed list that you can use in [ListView] or other data sources. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/FlowQueryList.kt b/lib/src/main/kotlin/com/dbflow5/query/list/FlowQueryList.kt similarity index 94% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/FlowQueryList.kt rename to lib/src/main/kotlin/com/dbflow5/query/list/FlowQueryList.kt index 30115a21f..df42b18e7 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/FlowQueryList.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/list/FlowQueryList.kt @@ -1,12 +1,12 @@ -package com.raizlabs.dbflow5.query.list +package com.dbflow5.query.list import android.os.Handler import android.os.Looper -import com.raizlabs.dbflow5.adapter.RetrievalAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.ModelQueriable -import com.raizlabs.dbflow5.query.list.FlowCursorList.OnCursorRefreshListener +import com.dbflow5.adapter.RetrievalAdapter +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor +import com.dbflow5.query.ModelQueriable +import com.dbflow5.query.list.FlowCursorList.OnCursorRefreshListener /** * Description: A query-backed immutable [List]. Represents the results of a cursor without loading @@ -92,7 +92,7 @@ class FlowQueryList( * Checks to see if the table contains the object only if its a [T] * * @param element A model class. For interface purposes, this must be an Object. - * @return always false if its anything other than the current table. True if [com.raizlabs.dbflow5.structure.Model.exists] passes. + * @return always false if its anything other than the current table. True if [com.dbflow5.structure.Model.exists] passes. */ override operator fun contains(element: T): Boolean { return internalCursorList.instanceAdapter.exists(element, internalCursorList.databaseWrapper) diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/IFlowCursorIterator.kt b/lib/src/main/kotlin/com/dbflow5/query/list/IFlowCursorIterator.kt similarity index 93% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/IFlowCursorIterator.kt rename to lib/src/main/kotlin/com/dbflow5/query/list/IFlowCursorIterator.kt index 272789ff7..3e2d15aa6 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/list/IFlowCursorIterator.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/list/IFlowCursorIterator.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.query.list +package com.dbflow5.query.list -import com.raizlabs.dbflow5.database.FlowCursor +import com.dbflow5.database.FlowCursor import java.io.Closeable import java.io.IOException diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/IProperty.kt b/lib/src/main/kotlin/com/dbflow5/query/property/IProperty.kt similarity index 91% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/IProperty.kt rename to lib/src/main/kotlin/com/dbflow5/query/property/IProperty.kt index 374566a60..ee94265cd 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/IProperty.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/property/IProperty.kt @@ -1,11 +1,11 @@ -package com.raizlabs.dbflow5.query.property - -import com.raizlabs.dbflow5.query.Join -import com.raizlabs.dbflow5.query.Method -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.OrderBy -import com.raizlabs.dbflow5.sql.Query -import com.raizlabs.dbflow5.structure.Model +package com.dbflow5.query.property + +import com.dbflow5.query.Join +import com.dbflow5.query.Method +import com.dbflow5.query.NameAlias +import com.dbflow5.query.OrderBy +import com.dbflow5.sql.Query +import com.dbflow5.structure.Model /** * Description: Defines the base interface all property classes implement. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/IndexProperty.kt b/lib/src/main/kotlin/com/dbflow5/query/property/IndexProperty.kt similarity index 80% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/IndexProperty.kt rename to lib/src/main/kotlin/com/dbflow5/query/property/IndexProperty.kt index 35be6bd10..67aa853c3 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/IndexProperty.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/property/IndexProperty.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.query.property +package com.dbflow5.query.property -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.Index -import com.raizlabs.dbflow5.quoteIfNeeded +import com.dbflow5.annotation.Table +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.Index +import com.dbflow5.quoteIfNeeded /** * Description: Defines an INDEX in Sqlite. It basically speeds up data retrieval over large datasets. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/Property.kt b/lib/src/main/kotlin/com/dbflow5/query/property/Property.kt similarity index 96% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/Property.kt rename to lib/src/main/kotlin/com/dbflow5/query/property/Property.kt index 0ede92747..a90621727 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/Property.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/property/Property.kt @@ -1,12 +1,12 @@ -package com.raizlabs.dbflow5.query.property - -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.query.BaseModelQueriable -import com.raizlabs.dbflow5.query.IConditional -import com.raizlabs.dbflow5.query.IOperator -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.Operator -import com.raizlabs.dbflow5.query.OrderBy +package com.dbflow5.query.property + +import com.dbflow5.config.FlowManager +import com.dbflow5.query.BaseModelQueriable +import com.dbflow5.query.IConditional +import com.dbflow5.query.IOperator +import com.dbflow5.query.NameAlias +import com.dbflow5.query.Operator +import com.dbflow5.query.OrderBy /** * Description: The main, immutable property class that gets generated from a table definition. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/PropertyFactory.kt b/lib/src/main/kotlin/com/dbflow5/query/property/PropertyFactory.kt similarity index 96% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/PropertyFactory.kt rename to lib/src/main/kotlin/com/dbflow5/query/property/PropertyFactory.kt index 3c8c7f11f..d73ddb8cc 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/PropertyFactory.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/property/PropertyFactory.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.query.property +package com.dbflow5.query.property -import com.raizlabs.dbflow5.query.ModelQueriable -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.Operator +import com.dbflow5.query.ModelQueriable +import com.dbflow5.query.NameAlias +import com.dbflow5.query.Operator import kotlin.reflect.KClass /** diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/TypeConvertedProperty.kt b/lib/src/main/kotlin/com/dbflow5/query/property/TypeConvertedProperty.kt similarity index 90% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/TypeConvertedProperty.kt rename to lib/src/main/kotlin/com/dbflow5/query/property/TypeConvertedProperty.kt index 73a889fc6..e0f5b89e1 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/TypeConvertedProperty.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/property/TypeConvertedProperty.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.query.property +package com.dbflow5.query.property -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.converter.TypeConverter -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.Operator +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.config.FlowManager +import com.dbflow5.converter.TypeConverter +import com.dbflow5.query.NameAlias +import com.dbflow5.query.Operator /** * Description: Provides convenience methods for [TypeConverter] when constructing queries. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/WrapperProperty.kt b/lib/src/main/kotlin/com/dbflow5/query/property/WrapperProperty.kt similarity index 91% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/WrapperProperty.kt rename to lib/src/main/kotlin/com/dbflow5/query/property/WrapperProperty.kt index 92a0cd934..b63f95ca6 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/query/property/WrapperProperty.kt +++ b/lib/src/main/kotlin/com/dbflow5/query/property/WrapperProperty.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.query.property +package com.dbflow5.query.property -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.query.NameAlias +import com.dbflow5.config.FlowManager +import com.dbflow5.query.NameAlias /** * Description: Provides convenience for types that are represented in different ways in the DB. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/ContentResolverNotifier.kt b/lib/src/main/kotlin/com/dbflow5/runtime/ContentResolverNotifier.kt similarity index 92% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/ContentResolverNotifier.kt rename to lib/src/main/kotlin/com/dbflow5/runtime/ContentResolverNotifier.kt index 280f4d1b4..9d7babcb1 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/ContentResolverNotifier.kt +++ b/lib/src/main/kotlin/com/dbflow5/runtime/ContentResolverNotifier.kt @@ -1,11 +1,11 @@ -package com.raizlabs.dbflow5.runtime +package com.dbflow5.runtime import android.content.ContentResolver import android.content.Context -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.getNotificationUri -import com.raizlabs.dbflow5.query.SQLOperator -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.getNotificationUri +import com.dbflow5.query.SQLOperator +import com.dbflow5.structure.ChangeAction /** * The default use case, it notifies via the [ContentResolver] system. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/DBBatchSaveQueue.kt b/lib/src/main/kotlin/com/dbflow5/runtime/DBBatchSaveQueue.kt similarity index 93% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/DBBatchSaveQueue.kt rename to lib/src/main/kotlin/com/dbflow5/runtime/DBBatchSaveQueue.kt index f14314e69..07040474c 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/DBBatchSaveQueue.kt +++ b/lib/src/main/kotlin/com/dbflow5/runtime/DBBatchSaveQueue.kt @@ -1,17 +1,17 @@ -package com.raizlabs.dbflow5.runtime +package com.dbflow5.runtime import android.os.Looper import android.os.Process import android.os.Process.THREAD_PRIORITY_BACKGROUND -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.structure.Model -import com.raizlabs.dbflow5.structure.save -import com.raizlabs.dbflow5.transaction.Error -import com.raizlabs.dbflow5.transaction.ProcessModelTransaction -import com.raizlabs.dbflow5.transaction.Success -import com.raizlabs.dbflow5.transaction.Transaction -import com.raizlabs.dbflow5.transaction.processModel +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.FlowLog +import com.dbflow5.structure.Model +import com.dbflow5.structure.save +import com.dbflow5.transaction.Error +import com.dbflow5.transaction.ProcessModelTransaction +import com.dbflow5.transaction.Success +import com.dbflow5.transaction.Transaction +import com.dbflow5.transaction.processModel /** * Description: This queue will bulk save items added to it when it gets access to the DB. It should only exist as one entity. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/DirectModelNotifier.kt b/lib/src/main/kotlin/com/dbflow5/runtime/DirectModelNotifier.kt similarity index 89% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/DirectModelNotifier.kt rename to lib/src/main/kotlin/com/dbflow5/runtime/DirectModelNotifier.kt index 764482da0..409be0e11 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/DirectModelNotifier.kt +++ b/lib/src/main/kotlin/com/dbflow5/runtime/DirectModelNotifier.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.runtime +package com.dbflow5.runtime -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.config.DatabaseConfig -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.config.DatabaseConfig +import com.dbflow5.structure.ChangeAction /** * Description: Directly notifies about model changes. Users should use [.get] to use the shared @@ -18,8 +18,6 @@ private constructor() : ModelNotifier { private val tableChangedListenerMap = linkedMapOf, MutableSet>() - private val singleRegister = DirectTableNotifierRegister(this) - interface OnModelStateChangedListener { fun onModelChanged(model: T, action: ChangeAction) } @@ -37,20 +35,18 @@ private constructor() : ModelNotifier { override fun notifyModelChanged(model: T, adapter: ModelAdapter, action: ChangeAction) { modelChangedListenerMap[adapter.table] - ?.forEach { listener -> - (listener as OnModelStateChangedListener).onModelChanged(model, action) - } + ?.forEach { listener -> + (listener as OnModelStateChangedListener).onModelChanged(model, action) + } tableChangedListenerMap[adapter.table] - ?.forEach { listener -> listener.onTableChanged(adapter.table, action) } + ?.forEach { listener -> listener.onTableChanged(adapter.table, action) } } override fun notifyTableChanged(table: Class, action: ChangeAction) { tableChangedListenerMap[table]?.forEach { listener -> listener.onTableChanged(table, action) } } - override fun newRegister(): TableNotifierRegister { - return singleRegister - } + override fun newRegister(): TableNotifierRegister = DirectTableNotifierRegister(this) fun registerForModelChanges(table: Class, listener: ModelChangedListener) { diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/FlowContentObserver.kt b/lib/src/main/kotlin/com/dbflow5/runtime/FlowContentObserver.kt similarity index 95% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/FlowContentObserver.kt rename to lib/src/main/kotlin/com/dbflow5/runtime/FlowContentObserver.kt index ac71e4531..6018395a0 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/FlowContentObserver.kt +++ b/lib/src/main/kotlin/com/dbflow5/runtime/FlowContentObserver.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.runtime +package com.dbflow5.runtime import android.annotation.TargetApi import android.content.ContentResolver @@ -8,16 +8,16 @@ import android.net.Uri import android.os.Build import android.os.Build.VERSION_CODES import android.os.Handler -import com.raizlabs.dbflow5.TABLE_QUERY_PARAM -import com.raizlabs.dbflow5.config.DatabaseConfig -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.getNotificationUri -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.Operator -import com.raizlabs.dbflow5.query.SQLOperator -import com.raizlabs.dbflow5.structure.ChangeAction -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.TABLE_QUERY_PARAM +import com.dbflow5.config.DatabaseConfig +import com.dbflow5.config.FlowLog +import com.dbflow5.config.FlowManager +import com.dbflow5.getNotificationUri +import com.dbflow5.query.NameAlias +import com.dbflow5.query.Operator +import com.dbflow5.query.SQLOperator +import com.dbflow5.structure.ChangeAction +import com.dbflow5.structure.Model import java.util.concurrent.CopyOnWriteArraySet import java.util.concurrent.atomic.AtomicInteger diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/ModelNotifier.kt b/lib/src/main/kotlin/com/dbflow5/runtime/ModelNotifier.kt similarity index 69% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/ModelNotifier.kt rename to lib/src/main/kotlin/com/dbflow5/runtime/ModelNotifier.kt index c9d0b0bf8..e06a8e9e7 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/ModelNotifier.kt +++ b/lib/src/main/kotlin/com/dbflow5/runtime/ModelNotifier.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.runtime +package com.dbflow5.runtime -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.structure.ChangeAction /** * Interface for defining how we notify model changes. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/NotifyDistributor.kt b/lib/src/main/kotlin/com/dbflow5/runtime/NotifyDistributor.kt similarity index 85% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/NotifyDistributor.kt rename to lib/src/main/kotlin/com/dbflow5/runtime/NotifyDistributor.kt index 4df025d2b..0f9069c46 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/NotifyDistributor.kt +++ b/lib/src/main/kotlin/com/dbflow5/runtime/NotifyDistributor.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.runtime +package com.dbflow5.runtime -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.config.FlowManager +import com.dbflow5.structure.ChangeAction /** * Description: Distributes notifications to the [ModelNotifier]. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/OnTableChangedListener.kt b/lib/src/main/kotlin/com/dbflow5/runtime/OnTableChangedListener.kt similarity index 81% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/OnTableChangedListener.kt rename to lib/src/main/kotlin/com/dbflow5/runtime/OnTableChangedListener.kt index b1f576557..4568df9fb 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/OnTableChangedListener.kt +++ b/lib/src/main/kotlin/com/dbflow5/runtime/OnTableChangedListener.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.runtime +package com.dbflow5.runtime -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.structure.ChangeAction /** * Interface for when a generic change on a table occurs. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/TableNotifierRegister.kt b/lib/src/main/kotlin/com/dbflow5/runtime/TableNotifierRegister.kt similarity index 87% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/TableNotifierRegister.kt rename to lib/src/main/kotlin/com/dbflow5/runtime/TableNotifierRegister.kt index f30a4ce49..02b5fbaf7 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/runtime/TableNotifierRegister.kt +++ b/lib/src/main/kotlin/com/dbflow5/runtime/TableNotifierRegister.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.runtime +package com.dbflow5.runtime -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.structure.ChangeAction /** * Description: Defines how [ModelNotifier] registers listeners. Abstracts that away. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/Action.kt b/lib/src/main/kotlin/com/dbflow5/structure/Action.kt similarity index 71% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/Action.kt rename to lib/src/main/kotlin/com/dbflow5/structure/Action.kt index 607fb64ef..e031717a2 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/Action.kt +++ b/lib/src/main/kotlin/com/dbflow5/structure/Action.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.structure +package com.dbflow5.structure /** * Specifies the Action that was taken when data changes @@ -13,7 +13,7 @@ enum class ChangeAction { /** * The model was changed. used in prior to Android JellyBean and in generic change - * actions like [com.raizlabs.dbflow5.query.StringQuery] + * actions like [com.dbflow5.query.StringQuery] */ CHANGE } \ No newline at end of file diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/BaseModel.kt b/lib/src/main/kotlin/com/dbflow5/structure/BaseModel.kt similarity index 80% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/BaseModel.kt rename to lib/src/main/kotlin/com/dbflow5/structure/BaseModel.kt index 67f5a8a52..1ab35a678 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/BaseModel.kt +++ b/lib/src/main/kotlin/com/dbflow5/structure/BaseModel.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.structure +package com.dbflow5.structure -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.annotation.ColumnIgnore -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.config.modelAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.annotation.ColumnIgnore +import com.dbflow5.config.FlowManager +import com.dbflow5.config.modelAdapter +import com.dbflow5.database.DatabaseWrapper /** * Description: The base implementation of [Model]. It is recommended to use this class as diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/BaseModelView.kt b/lib/src/main/kotlin/com/dbflow5/structure/BaseModelView.kt similarity index 63% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/BaseModelView.kt rename to lib/src/main/kotlin/com/dbflow5/structure/BaseModelView.kt index 601d7c6fb..510f9577b 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/BaseModelView.kt +++ b/lib/src/main/kotlin/com/dbflow5/structure/BaseModelView.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.structure +package com.dbflow5.structure -import com.raizlabs.dbflow5.annotation.ModelView -import com.raizlabs.dbflow5.annotation.ModelViewQuery +import com.dbflow5.annotation.ModelView +import com.dbflow5.annotation.ModelViewQuery /** * Description: Provides a base implementation for a ModelView. Use a [ModelView] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/BaseQueryModel.kt b/lib/src/main/kotlin/com/dbflow5/structure/BaseQueryModel.kt similarity index 73% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/BaseQueryModel.kt rename to lib/src/main/kotlin/com/dbflow5/structure/BaseQueryModel.kt index 1e2ced6cf..7993a2f13 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/BaseQueryModel.kt +++ b/lib/src/main/kotlin/com/dbflow5/structure/BaseQueryModel.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.structure +package com.dbflow5.structure -import com.raizlabs.dbflow5.annotation.QueryModel -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.annotation.QueryModel +import com.dbflow5.database.DatabaseWrapper /** * Description: Provides a base class for objects that represent [QueryModel]. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/InvalidDBConfiguration.kt b/lib/src/main/kotlin/com/dbflow5/structure/InvalidDBConfiguration.kt similarity index 78% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/InvalidDBConfiguration.kt rename to lib/src/main/kotlin/com/dbflow5/structure/InvalidDBConfiguration.kt index ba6d70a57..6f4d30356 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/InvalidDBConfiguration.kt +++ b/lib/src/main/kotlin/com/dbflow5/structure/InvalidDBConfiguration.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.structure +package com.dbflow5.structure /** * Description: Thrown when a DB is incorrectly configured. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/Model.kt b/lib/src/main/kotlin/com/dbflow5/structure/Model.kt similarity index 89% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/Model.kt rename to lib/src/main/kotlin/com/dbflow5/structure/Model.kt index 7b9323a53..37662ffee 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/Model.kt +++ b/lib/src/main/kotlin/com/dbflow5/structure/Model.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.structure +package com.dbflow5.structure -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.config.modelAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.config.FlowManager +import com.dbflow5.config.databaseForTable +import com.dbflow5.config.modelAdapter +import com.dbflow5.database.DatabaseWrapper interface Model : ReadOnlyModel { diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/NoModificationModel.kt b/lib/src/main/kotlin/com/dbflow5/structure/NoModificationModel.kt similarity index 78% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/NoModificationModel.kt rename to lib/src/main/kotlin/com/dbflow5/structure/NoModificationModel.kt index 21cbeb13f..b0dcdc4d9 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/NoModificationModel.kt +++ b/lib/src/main/kotlin/com/dbflow5/structure/NoModificationModel.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.structure +package com.dbflow5.structure -import com.raizlabs.dbflow5.adapter.RetrievalAdapter -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.adapter.RetrievalAdapter +import com.dbflow5.config.FlowManager +import com.dbflow5.database.DatabaseWrapper /** * Description: A convenience class for [ReadOnlyModel]. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/OneToMany.kt b/lib/src/main/kotlin/com/dbflow5/structure/OneToMany.kt similarity index 84% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/OneToMany.kt rename to lib/src/main/kotlin/com/dbflow5/structure/OneToMany.kt index 794e37870..e2c8d72a8 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/OneToMany.kt +++ b/lib/src/main/kotlin/com/dbflow5/structure/OneToMany.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.structure +package com.dbflow5.structure -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.query.ModelQueriable +import com.dbflow5.config.databaseForTable +import com.dbflow5.query.ModelQueriable import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/ReadOnlyModel.kt b/lib/src/main/kotlin/com/dbflow5/structure/ReadOnlyModel.kt similarity index 82% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/ReadOnlyModel.kt rename to lib/src/main/kotlin/com/dbflow5/structure/ReadOnlyModel.kt index cc8ad9b1e..f81aa1b90 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/structure/ReadOnlyModel.kt +++ b/lib/src/main/kotlin/com/dbflow5/structure/ReadOnlyModel.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.structure +package com.dbflow5.structure -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.DatabaseWrapper interface ReadOnlyModel { diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/BaseTransactionManager.kt b/lib/src/main/kotlin/com/dbflow5/transaction/BaseTransactionManager.kt similarity index 87% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/BaseTransactionManager.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/BaseTransactionManager.kt index 1346e4e11..51287173c 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/BaseTransactionManager.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/BaseTransactionManager.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.runtime.DBBatchSaveQueue +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.FlowLog +import com.dbflow5.runtime.DBBatchSaveQueue /** * Description: The base implementation of Transaction manager. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/DefaultTransactionManager.kt b/lib/src/main/kotlin/com/dbflow5/transaction/DefaultTransactionManager.kt similarity index 84% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/DefaultTransactionManager.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/DefaultTransactionManager.kt index a9bac8346..f0be1dfe4 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/DefaultTransactionManager.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/DefaultTransactionManager.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction -import com.raizlabs.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.DBFlowDatabase /** * Description: This class manages batch database interactions. Places DB operations onto the same Thread. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/DefaultTransactionQueue.kt b/lib/src/main/kotlin/com/dbflow5/transaction/DefaultTransactionQueue.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/DefaultTransactionQueue.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/DefaultTransactionQueue.kt index 8bafe251f..8a76b2415 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/DefaultTransactionQueue.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/DefaultTransactionQueue.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction import android.os.Looper import android.os.Process import android.os.Process.THREAD_PRIORITY_BACKGROUND -import com.raizlabs.dbflow5.config.FlowLog +import com.dbflow5.config.FlowLog import java.util.concurrent.LinkedBlockingQueue /** diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/FastStoreModelTransaction.kt b/lib/src/main/kotlin/com/dbflow5/transaction/FastStoreModelTransaction.kt similarity index 93% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/FastStoreModelTransaction.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/FastStoreModelTransaction.kt index c7d03c905..30af51b20 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/FastStoreModelTransaction.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/FastStoreModelTransaction.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction -import com.raizlabs.dbflow5.adapter.InternalAdapter -import com.raizlabs.dbflow5.config.modelAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.adapter.InternalAdapter +import com.dbflow5.config.modelAdapter +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.structure.Model /** * Description: Simple interface for acting on a model in a Transaction or list of [Model] diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/ITransaction.kt b/lib/src/main/kotlin/com/dbflow5/transaction/ITransaction.kt similarity index 84% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/ITransaction.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/ITransaction.kt index 7bd10b213..6f1b59e95 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/ITransaction.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/ITransaction.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.DatabaseWrapper /** * Description: Simplest form of a transaction. It represents an interface by which code is executed diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/ITransactionQueue.kt b/lib/src/main/kotlin/com/dbflow5/transaction/ITransactionQueue.kt similarity index 94% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/ITransactionQueue.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/ITransactionQueue.kt index 2f67325e0..b17ad5b84 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/ITransactionQueue.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/ITransactionQueue.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction /** * Description: Interface for a queue that manages transactions. diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/PriorityTransactionQueue.kt b/lib/src/main/kotlin/com/dbflow5/transaction/PriorityTransactionQueue.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/PriorityTransactionQueue.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/PriorityTransactionQueue.kt index c864bb2bd..2f6d0defa 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/PriorityTransactionQueue.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/PriorityTransactionQueue.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction import android.os.Looper import android.os.Process.THREAD_PRIORITY_BACKGROUND import android.os.Process.setThreadPriority -import com.raizlabs.dbflow5.config.FlowLog +import com.dbflow5.config.FlowLog import java.util.concurrent.PriorityBlockingQueue /** diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/PriorityTransactionWrapper.kt b/lib/src/main/kotlin/com/dbflow5/transaction/PriorityTransactionWrapper.kt similarity index 83% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/PriorityTransactionWrapper.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/PriorityTransactionWrapper.kt index 8506aa613..4193acd17 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/PriorityTransactionWrapper.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/PriorityTransactionWrapper.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction import android.support.annotation.IntDef -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.DatabaseWrapper /** * Description: Provides transaction with priority. Meant to be used in a [PriorityTransactionQueue]. @@ -12,16 +12,16 @@ class PriorityTransactionWrapper(private val priority: Int, private val transact @Suppress("RemoveEmptyPrimaryConstructor") @Retention(AnnotationRetention.SOURCE) - @IntDef(PRIORITY_LOW.toLong(), PRIORITY_NORMAL.toLong(), PRIORITY_HIGH.toLong(), PRIORITY_UI.toLong()) + @IntDef(PRIORITY_LOW, PRIORITY_NORMAL, PRIORITY_HIGH, PRIORITY_UI) annotation class Priority() internal constructor(builder: Builder) : this( - priority = if (builder.priority == 0) { - PRIORITY_NORMAL - } else { - builder.priority - }, - transaction = builder.transaction) + priority = if (builder.priority == 0) { + PRIORITY_NORMAL + } else { + builder.priority + }, + transaction = builder.transaction) override fun execute(databaseWrapper: DatabaseWrapper) { transaction.execute(databaseWrapper) diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/ProcessModelTransaction.kt b/lib/src/main/kotlin/com/dbflow5/transaction/ProcessModelTransaction.kt similarity index 97% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/ProcessModelTransaction.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/ProcessModelTransaction.kt index 340164add..1479072da 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/ProcessModelTransaction.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/ProcessModelTransaction.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.structure.Model +import com.dbflow5.config.databaseForTable +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.structure.Model typealias ProcessFunction = (T, DatabaseWrapper) -> Unit diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/Transaction.kt b/lib/src/main/kotlin/com/dbflow5/transaction/Transaction.kt similarity index 98% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/Transaction.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/Transaction.kt index 58fffe08a..976364105 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/Transaction.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/Transaction.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction import android.os.Handler import android.os.Looper -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.FlowLog +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.FlowLog typealias Success = (Transaction, R) -> Unit diff --git a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/TransactionWrapper.kt b/lib/src/main/kotlin/com/dbflow5/transaction/TransactionWrapper.kt similarity index 85% rename from dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/TransactionWrapper.kt rename to lib/src/main/kotlin/com/dbflow5/transaction/TransactionWrapper.kt index d0fecd4d1..b6c43c858 100644 --- a/dbflow/src/main/kotlin/com/raizlabs/dbflow5/transaction/TransactionWrapper.kt +++ b/lib/src/main/kotlin/com/dbflow5/transaction/TransactionWrapper.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.transaction +package com.dbflow5.transaction -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.DatabaseWrapper /** * Description: Wraps multiple transactions together. diff --git a/paging/build.gradle b/paging/build.gradle index 959b3943b..8d5a7d874 100644 --- a/paging/build.gradle +++ b/paging/build.gradle @@ -26,7 +26,7 @@ android { } dependencies { - implementation project("${dbflow_project_prefix}dbflow") + implementation project(':lib') api deps.paging api deps.kotlin } diff --git a/paging/src/main/AndroidManifest.xml b/paging/src/main/AndroidManifest.xml index 6d377d33b..bec1425d4 100644 --- a/paging/src/main/AndroidManifest.xml +++ b/paging/src/main/AndroidManifest.xml @@ -1,2 +1,2 @@ - + diff --git a/paging/src/main/kotlin/com/raizlabs/dbflow5/paging/QueryDataSource.kt b/paging/src/main/kotlin/com/dbflow5/paging/QueryDataSource.kt similarity index 84% rename from paging/src/main/kotlin/com/raizlabs/dbflow5/paging/QueryDataSource.kt rename to paging/src/main/kotlin/com/dbflow5/paging/QueryDataSource.kt index 23a59f75f..8f68dc582 100644 --- a/paging/src/main/kotlin/com/raizlabs/dbflow5/paging/QueryDataSource.kt +++ b/paging/src/main/kotlin/com/dbflow5/paging/QueryDataSource.kt @@ -1,18 +1,18 @@ -package com.raizlabs.dbflow5.paging +package com.dbflow5.paging import android.arch.paging.DataSource import android.arch.paging.PositionalDataSource -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.query.ModelQueriable -import com.raizlabs.dbflow5.query.Select -import com.raizlabs.dbflow5.query.Transformable -import com.raizlabs.dbflow5.query.WhereBase -import com.raizlabs.dbflow5.query.constrain -import com.raizlabs.dbflow5.query.extractFrom -import com.raizlabs.dbflow5.query.selectCountOf -import com.raizlabs.dbflow5.runtime.TableNotifierRegister -import com.raizlabs.dbflow5.runtime.setListener +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.FlowManager +import com.dbflow5.query.ModelQueriable +import com.dbflow5.query.Select +import com.dbflow5.query.Transformable +import com.dbflow5.query.WhereBase +import com.dbflow5.query.constrain +import com.dbflow5.query.extractFrom +import com.dbflow5.query.selectCountOf +import com.dbflow5.runtime.TableNotifierRegister +import com.dbflow5.runtime.setListener /** * Bridges the [ModelQueriable] into a [PositionalDataSource] that loads a [ModelQueriable]. diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/ClassNames.kt b/processor/src/main/kotlin/com/dbflow5/processor/ClassNames.kt similarity index 96% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/ClassNames.kt rename to processor/src/main/kotlin/com/dbflow5/processor/ClassNames.kt index 9ab60ba41..6bc5ecedc 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/ClassNames.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/ClassNames.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.processor +package com.dbflow5.processor -import com.raizlabs.dbflow5.annotation.ConflictAction +import com.dbflow5.annotation.ConflictAction import com.squareup.javapoet.ClassName /** @@ -9,7 +9,7 @@ import com.squareup.javapoet.ClassName object ClassNames { - val BASE_PACKAGE = "com.raizlabs.dbflow5" + val BASE_PACKAGE = "com.dbflow5" val FLOW_MANAGER_PACKAGE = "$BASE_PACKAGE.config" val DATABASE_HOLDER_STATIC_CLASS_NAME = "GeneratedDatabaseHolder" val CONVERTER = "$BASE_PACKAGE.converter" diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/DBFlowProcessor.kt b/processor/src/main/kotlin/com/dbflow5/processor/DBFlowProcessor.kt similarity index 79% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/DBFlowProcessor.kt rename to processor/src/main/kotlin/com/dbflow5/processor/DBFlowProcessor.kt index e2ccd9d6e..eaae8fa26 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/DBFlowProcessor.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/DBFlowProcessor.kt @@ -1,15 +1,15 @@ -package com.raizlabs.dbflow5.processor +package com.dbflow5.processor -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.ColumnIgnore -import com.raizlabs.dbflow5.annotation.Migration -import com.raizlabs.dbflow5.annotation.ModelView -import com.raizlabs.dbflow5.annotation.QueryModel -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.annotation.TypeConverter -import com.raizlabs.dbflow5.annotation.provider.ContentProvider -import com.raizlabs.dbflow5.annotation.provider.TableEndpoint -import com.raizlabs.dbflow5.processor.definition.DatabaseHolderDefinition +import com.dbflow5.annotation.Column +import com.dbflow5.annotation.ColumnIgnore +import com.dbflow5.annotation.Migration +import com.dbflow5.annotation.ModelView +import com.dbflow5.annotation.QueryModel +import com.dbflow5.annotation.Table +import com.dbflow5.annotation.TypeConverter +import com.dbflow5.annotation.provider.ContentProvider +import com.dbflow5.annotation.provider.TableEndpoint +import com.dbflow5.processor.definition.DatabaseHolderDefinition import javax.annotation.processing.AbstractProcessor import javax.annotation.processing.ProcessingEnvironment import javax.annotation.processing.RoundEnvironment diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/Handlers.kt b/processor/src/main/kotlin/com/dbflow5/processor/Handlers.kt similarity index 82% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/Handlers.kt rename to processor/src/main/kotlin/com/dbflow5/processor/Handlers.kt index a29b65bcf..1562e8c27 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/Handlers.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/Handlers.kt @@ -1,33 +1,33 @@ -package com.raizlabs.dbflow5.processor - -import com.raizlabs.dbflow5.annotation.Database -import com.raizlabs.dbflow5.annotation.ManyToMany -import com.raizlabs.dbflow5.annotation.Migration -import com.raizlabs.dbflow5.annotation.ModelView -import com.raizlabs.dbflow5.annotation.MultipleManyToMany -import com.raizlabs.dbflow5.annotation.QueryModel -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.annotation.TypeConverter -import com.raizlabs.dbflow5.annotation.provider.ContentProvider -import com.raizlabs.dbflow5.annotation.provider.TableEndpoint -import com.raizlabs.dbflow5.converter.BigDecimalConverter -import com.raizlabs.dbflow5.converter.BigIntegerConverter -import com.raizlabs.dbflow5.converter.BooleanConverter -import com.raizlabs.dbflow5.converter.CalendarConverter -import com.raizlabs.dbflow5.converter.CharConverter -import com.raizlabs.dbflow5.converter.DateConverter -import com.raizlabs.dbflow5.converter.SqlDateConverter -import com.raizlabs.dbflow5.converter.UUIDConverter -import com.raizlabs.dbflow5.processor.definition.provider.ContentProviderDefinition -import com.raizlabs.dbflow5.processor.definition.DatabaseDefinition -import com.raizlabs.dbflow5.processor.definition.ManyToManyDefinition -import com.raizlabs.dbflow5.processor.definition.MigrationDefinition -import com.raizlabs.dbflow5.processor.definition.ModelViewDefinition -import com.raizlabs.dbflow5.processor.definition.QueryModelDefinition -import com.raizlabs.dbflow5.processor.definition.TableDefinition -import com.raizlabs.dbflow5.processor.definition.provider.TableEndpointDefinition -import com.raizlabs.dbflow5.processor.definition.TypeConverterDefinition -import com.raizlabs.dbflow5.processor.utils.annotation +package com.dbflow5.processor + +import com.dbflow5.annotation.Database +import com.dbflow5.annotation.ManyToMany +import com.dbflow5.annotation.Migration +import com.dbflow5.annotation.ModelView +import com.dbflow5.annotation.MultipleManyToMany +import com.dbflow5.annotation.QueryModel +import com.dbflow5.annotation.Table +import com.dbflow5.annotation.TypeConverter +import com.dbflow5.annotation.provider.ContentProvider +import com.dbflow5.annotation.provider.TableEndpoint +import com.dbflow5.converter.BigDecimalConverter +import com.dbflow5.converter.BigIntegerConverter +import com.dbflow5.converter.BooleanConverter +import com.dbflow5.converter.CalendarConverter +import com.dbflow5.converter.CharConverter +import com.dbflow5.converter.DateConverter +import com.dbflow5.converter.SqlDateConverter +import com.dbflow5.converter.UUIDConverter +import com.dbflow5.processor.definition.provider.ContentProviderDefinition +import com.dbflow5.processor.definition.DatabaseDefinition +import com.dbflow5.processor.definition.ManyToManyDefinition +import com.dbflow5.processor.definition.MigrationDefinition +import com.dbflow5.processor.definition.ModelViewDefinition +import com.dbflow5.processor.definition.QueryModelDefinition +import com.dbflow5.processor.definition.TableDefinition +import com.dbflow5.processor.definition.provider.TableEndpointDefinition +import com.dbflow5.processor.definition.TypeConverterDefinition +import com.dbflow5.processor.utils.annotation import javax.annotation.processing.RoundEnvironment import javax.lang.model.element.Element import javax.lang.model.element.PackageElement @@ -155,7 +155,7 @@ class TypeConverterHandler : BaseContainerHandler() { override fun onProcessElement(processorManager: ProcessorManager, element: Element) { if (element is TypeElement) { - val className = com.raizlabs.dbflow5.processor.utils.fromTypeMirror(element.asType(), processorManager) + val className = com.dbflow5.processor.utils.fromTypeMirror(element.asType(), processorManager) val converterDefinition = className?.let { TypeConverterDefinition(it, element.asType(), processorManager, element) } converterDefinition?.let { if (VALIDATOR.validate(processorManager, converterDefinition)) { diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/ProcessorManager.kt b/processor/src/main/kotlin/com/dbflow5/processor/ProcessorManager.kt similarity index 93% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/ProcessorManager.kt rename to processor/src/main/kotlin/com/dbflow5/processor/ProcessorManager.kt index 823270ca2..159435bcd 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/ProcessorManager.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/ProcessorManager.kt @@ -1,18 +1,18 @@ -package com.raizlabs.dbflow5.processor - -import com.raizlabs.dbflow5.processor.definition.BaseTableDefinition -import com.raizlabs.dbflow5.processor.definition.DatabaseDefinition -import com.raizlabs.dbflow5.processor.definition.DatabaseHolderDefinition -import com.raizlabs.dbflow5.processor.definition.DatabaseObjectHolder -import com.raizlabs.dbflow5.processor.definition.ManyToManyDefinition -import com.raizlabs.dbflow5.processor.definition.MigrationDefinition -import com.raizlabs.dbflow5.processor.definition.ModelViewDefinition -import com.raizlabs.dbflow5.processor.definition.QueryModelDefinition -import com.raizlabs.dbflow5.processor.definition.TableDefinition -import com.raizlabs.dbflow5.processor.definition.TypeConverterDefinition -import com.raizlabs.dbflow5.processor.definition.provider.ContentProviderDefinition -import com.raizlabs.dbflow5.processor.definition.provider.TableEndpointDefinition -import com.raizlabs.dbflow5.processor.utils.WriterUtils +package com.dbflow5.processor + +import com.dbflow5.processor.definition.BaseTableDefinition +import com.dbflow5.processor.definition.DatabaseDefinition +import com.dbflow5.processor.definition.DatabaseHolderDefinition +import com.dbflow5.processor.definition.DatabaseObjectHolder +import com.dbflow5.processor.definition.ManyToManyDefinition +import com.dbflow5.processor.definition.MigrationDefinition +import com.dbflow5.processor.definition.ModelViewDefinition +import com.dbflow5.processor.definition.QueryModelDefinition +import com.dbflow5.processor.definition.TableDefinition +import com.dbflow5.processor.definition.TypeConverterDefinition +import com.dbflow5.processor.definition.provider.ContentProviderDefinition +import com.dbflow5.processor.definition.provider.TableEndpointDefinition +import com.dbflow5.processor.utils.WriterUtils import com.squareup.javapoet.ClassName import com.squareup.javapoet.JavaFile import com.squareup.javapoet.TypeName @@ -321,7 +321,7 @@ class ProcessorManager internal constructor(val processingEnvironment: Processin try { val databaseHolderDefinition = DatabaseHolderDefinition(processorManager) if (!databaseHolderDefinition.isGarbage()) { - JavaFile.builder(ClassNames.FLOW_MANAGER_PACKAGE, + JavaFile.builder(com.dbflow5.processor.ClassNames.FLOW_MANAGER_PACKAGE, databaseHolderDefinition.typeSpec).build() .writeTo(processorManager.processingEnvironment.filer) } diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/SQLiteHelper.kt b/processor/src/main/kotlin/com/dbflow5/processor/SQLiteHelper.kt similarity index 98% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/SQLiteHelper.kt rename to processor/src/main/kotlin/com/dbflow5/processor/SQLiteHelper.kt index 6a6f50e53..1b27d5172 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/SQLiteHelper.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/SQLiteHelper.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.processor +package com.dbflow5.processor -import com.raizlabs.dbflow5.data.Blob +import com.dbflow5.data.Blob import com.squareup.javapoet.ArrayTypeName import com.squareup.javapoet.ClassName import com.squareup.javapoet.TypeName diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/Validators.kt b/processor/src/main/kotlin/com/dbflow5/processor/Validators.kt similarity index 91% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/Validators.kt rename to processor/src/main/kotlin/com/dbflow5/processor/Validators.kt index 0ee52ed87..e11a53f9c 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/Validators.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/Validators.kt @@ -1,17 +1,17 @@ -package com.raizlabs.dbflow5.processor - -import com.raizlabs.dbflow5.processor.definition.DatabaseDefinition -import com.raizlabs.dbflow5.processor.definition.ModelViewDefinition -import com.raizlabs.dbflow5.processor.definition.OneToManyDefinition -import com.raizlabs.dbflow5.processor.definition.TableDefinition -import com.raizlabs.dbflow5.processor.definition.TypeConverterDefinition -import com.raizlabs.dbflow5.processor.definition.column.ColumnDefinition -import com.raizlabs.dbflow5.processor.definition.column.EnumColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.PrivateScopeColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.ReferenceColumnDefinition -import com.raizlabs.dbflow5.processor.definition.provider.ContentProviderDefinition -import com.raizlabs.dbflow5.processor.definition.provider.TableEndpointDefinition -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty +package com.dbflow5.processor + +import com.dbflow5.processor.definition.DatabaseDefinition +import com.dbflow5.processor.definition.ModelViewDefinition +import com.dbflow5.processor.definition.OneToManyDefinition +import com.dbflow5.processor.definition.TableDefinition +import com.dbflow5.processor.definition.TypeConverterDefinition +import com.dbflow5.processor.definition.column.ColumnDefinition +import com.dbflow5.processor.definition.column.EnumColumnAccessor +import com.dbflow5.processor.definition.column.PrivateScopeColumnAccessor +import com.dbflow5.processor.definition.column.ReferenceColumnDefinition +import com.dbflow5.processor.definition.provider.ContentProviderDefinition +import com.dbflow5.processor.definition.provider.TableEndpointDefinition +import com.dbflow5.processor.utils.isNullOrEmpty /** @@ -181,7 +181,7 @@ class TableEndpointValidator : Validator { } /** - * Description: Validates proper usage of the [com.raizlabs.android.dbflow.annotation.Table] + * Description: Validates proper usage of the [com.dbflow5.annotation.Table] */ class TableValidator : Validator { diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/Adders.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/Adders.kt similarity index 85% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/Adders.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/Adders.kt index 1fac24cf0..031123b2a 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/Adders.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/Adders.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.TypeSpec diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/BaseDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/BaseDefinition.kt similarity index 91% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/BaseDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/BaseDefinition.kt index c1c365b11..fce753a4c 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/BaseDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/BaseDefinition.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.S import com.grosner.kpoet.`@` @@ -7,12 +7,12 @@ import com.grosner.kpoet.extends import com.grosner.kpoet.implements import com.grosner.kpoet.javadoc import com.grosner.kpoet.typeName -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.DBFlowProcessor -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.utils.ElementUtility -import com.raizlabs.dbflow5.processor.utils.hasJavaX -import com.raizlabs.dbflow5.processor.utils.toTypeElement +import com.dbflow5.processor.ClassNames +import com.dbflow5.processor.DBFlowProcessor +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.utils.ElementUtility +import com.dbflow5.processor.utils.hasJavaX +import com.dbflow5.processor.utils.toTypeElement import com.squareup.javapoet.ClassName import com.squareup.javapoet.ParameterizedTypeName import com.squareup.javapoet.TypeName @@ -135,8 +135,8 @@ abstract class BaseDefinition : TypeDefinition { } return `public final class`(outputClassName?.simpleName() ?: "") { if (hasJavaX()) { - addAnnotation(`@`(ClassNames.GENERATED, { - this["value"] = DBFlowProcessor::class.java.canonicalName.toString().S + addAnnotation(`@`(com.dbflow5.processor.ClassNames.GENERATED, { + this["value"] = com.dbflow5.processor.DBFlowProcessor::class.java.canonicalName.toString().S }).build()) } extendsClass?.let { extends(it) } diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/BaseTableDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/BaseTableDefinition.kt similarity index 89% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/BaseTableDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/BaseTableDefinition.kt index 1a3c3e33b..3b13d9836 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/BaseTableDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/BaseTableDefinition.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.`public static final` import com.grosner.kpoet.`return` @@ -9,16 +9,16 @@ import com.grosner.kpoet.modifiers import com.grosner.kpoet.param import com.grosner.kpoet.public import com.grosner.kpoet.statement -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.column.ColumnDefinition -import com.raizlabs.dbflow5.processor.definition.column.PackagePrivateScopeColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.ReferenceColumnDefinition -import com.raizlabs.dbflow5.processor.utils.ElementUtility -import com.raizlabs.dbflow5.processor.utils.ModelUtils -import com.raizlabs.dbflow5.processor.utils.`override fun` -import com.raizlabs.dbflow5.processor.utils.getPackage -import com.raizlabs.dbflow5.processor.utils.toClassName +import com.dbflow5.processor.ClassNames +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.column.ColumnDefinition +import com.dbflow5.processor.definition.column.PackagePrivateScopeColumnAccessor +import com.dbflow5.processor.definition.column.ReferenceColumnDefinition +import com.dbflow5.processor.utils.ElementUtility +import com.dbflow5.processor.utils.ModelUtils +import com.dbflow5.processor.utils.`override fun` +import com.dbflow5.processor.utils.getPackage +import com.dbflow5.processor.utils.toClassName import com.squareup.javapoet.ClassName import com.squareup.javapoet.JavaFile import com.squareup.javapoet.ParameterizedTypeName @@ -93,9 +93,9 @@ abstract class BaseTableDefinition(typeElement: Element, processorManager: Proce constructor { if (hasGlobalTypeConverters) { - addParameter(param(ClassNames.DATABASE_HOLDER, "holder").build()) + addParameter(param(com.dbflow5.processor.ClassNames.DATABASE_HOLDER, "holder").build()) } - addParameter(param(ClassNames.BASE_DATABASE_DEFINITION_CLASSNAME, "databaseDefinition").build()) + addParameter(param(com.dbflow5.processor.ClassNames.BASE_DATABASE_DEFINITION_CLASSNAME, "databaseDefinition").build()) modifiers(public) statement("super(databaseDefinition)") code { diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/DatabaseDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/DatabaseDefinition.kt similarity index 91% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/DatabaseDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/DatabaseDefinition.kt index df68d2b8e..3f62b1a01 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/DatabaseDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/DatabaseDefinition.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.L import com.grosner.kpoet.S @@ -9,15 +9,14 @@ import com.grosner.kpoet.modifiers import com.grosner.kpoet.param import com.grosner.kpoet.public import com.grosner.kpoet.statement -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.annotation.Database -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ModelViewValidator -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.TableValidator -import com.raizlabs.dbflow5.processor.utils.`override fun` -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.isSubclass +import com.dbflow5.annotation.ConflictAction +import com.dbflow5.annotation.Database +import com.dbflow5.processor.ModelViewValidator +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.TableValidator +import com.dbflow5.processor.utils.`override fun` +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.isSubclass import com.squareup.javapoet.ClassName import com.squareup.javapoet.ParameterizedTypeName import com.squareup.javapoet.TypeName @@ -58,7 +57,7 @@ class DatabaseDefinition(manager: ProcessorManager, element: Element) : BaseDefi var inMemory = false init { - packageName = ClassNames.FLOW_MANAGER_PACKAGE + packageName = com.dbflow5.processor.ClassNames.FLOW_MANAGER_PACKAGE element.annotation()?.let { database -> databaseName = database.name @@ -79,9 +78,9 @@ class DatabaseDefinition(manager: ProcessorManager, element: Element) : BaseDefi if (!element.modifiers.contains(Modifier.ABSTRACT) || element.modifiers.contains(Modifier.PRIVATE) - || !typeElement.isSubclass(manager.processingEnvironment, ClassNames.BASE_DATABASE_DEFINITION_CLASSNAME)) { + || !typeElement.isSubclass(manager.processingEnvironment, com.dbflow5.processor.ClassNames.BASE_DATABASE_DEFINITION_CLASSNAME)) { manager.logError("$elementClassName must be a visible abstract class that " + - "extends ${ClassNames.BASE_DATABASE_DEFINITION_CLASSNAME}") + "extends ${com.dbflow5.processor.ClassNames.BASE_DATABASE_DEFINITION_CLASSNAME}") } } @@ -125,7 +124,7 @@ class DatabaseDefinition(manager: ProcessorManager, element: Element) : BaseDefi private fun writeConstructor(builder: TypeSpec.Builder) { - builder.constructor(param(ClassNames.DATABASE_HOLDER, "holder")) { + builder.constructor(param(com.dbflow5.processor.ClassNames.DATABASE_HOLDER, "holder")) { modifiers(public) this@DatabaseDefinition.elementClassName?.let { elementClassName -> for (definition in manager.getTableDefinitions(elementClassName)) { diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/DatabaseHolderDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/DatabaseHolderDefinition.kt similarity index 83% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/DatabaseHolderDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/DatabaseHolderDefinition.kt index e842b28e1..d35d15156 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/DatabaseHolderDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/DatabaseHolderDefinition.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.`public final class` import com.grosner.kpoet.constructor @@ -6,14 +6,14 @@ import com.grosner.kpoet.extends import com.grosner.kpoet.modifiers import com.grosner.kpoet.public import com.grosner.kpoet.statement -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.DatabaseHandler -import com.raizlabs.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.ClassNames +import com.dbflow5.processor.DatabaseHandler +import com.dbflow5.processor.ProcessorManager import com.squareup.javapoet.TypeSpec /** * Description: Top-level writer that handles writing all [DatabaseDefinition] - * and [com.raizlabs.android.dbflow.annotation.TypeConverter] + * and [com.dbflow5.annotation.TypeConverter] */ class DatabaseHolderDefinition(private val processorManager: ProcessorManager) : TypeDefinition { @@ -26,11 +26,11 @@ class DatabaseHolderDefinition(private val processorManager: ProcessorManager) : className = options[OPTION_TARGET_MODULE_NAME] ?: "" } - className += ClassNames.DATABASE_HOLDER_STATIC_CLASS_NAME + className += com.dbflow5.processor.ClassNames.DATABASE_HOLDER_STATIC_CLASS_NAME } override val typeSpec: TypeSpec = `public final class`(this.className) { - extends(ClassNames.DATABASE_HOLDER) + extends(com.dbflow5.processor.ClassNames.DATABASE_HOLDER) constructor { modifiers(public) diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/DatabaseObjectHolder.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/DatabaseObjectHolder.kt similarity index 93% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/DatabaseObjectHolder.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/DatabaseObjectHolder.kt index cbce9e3e6..69f0f460c 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/DatabaseObjectHolder.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/DatabaseObjectHolder.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition -import com.raizlabs.dbflow5.processor.definition.provider.ContentProviderDefinition +import com.dbflow5.processor.definition.provider.ContentProviderDefinition import com.squareup.javapoet.TypeName /** diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/IndexGroupsDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/IndexGroupsDefinition.kt similarity index 72% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/IndexGroupsDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/IndexGroupsDefinition.kt index 9d06b9da8..5974374f6 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/IndexGroupsDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/IndexGroupsDefinition.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.S import com.grosner.kpoet.`=` @@ -6,9 +6,8 @@ import com.grosner.kpoet.field import com.grosner.kpoet.final import com.grosner.kpoet.public import com.grosner.kpoet.static -import com.raizlabs.dbflow5.annotation.IndexGroup -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.definition.column.ColumnDefinition +import com.dbflow5.annotation.IndexGroup +import com.dbflow5.processor.definition.column.ColumnDefinition import com.squareup.javapoet.ParameterizedTypeName import java.util.concurrent.atomic.AtomicInteger @@ -24,12 +23,12 @@ class IndexGroupsDefinition(private val tableDefinition: TableDefinition, indexG val columnDefinitionList: MutableList = arrayListOf() val fieldSpec - get() = field(ParameterizedTypeName.get(ClassNames.INDEX_PROPERTY, tableDefinition.elementClassName), + get() = field(ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.INDEX_PROPERTY, tableDefinition.elementClassName), "index_$indexName") { addModifiers(public, static, final) `=` { add("new \$T<>(${indexName.S}, $isUnique, \$T.class", - ClassNames.INDEX_PROPERTY, tableDefinition.elementTypeName) + com.dbflow5.processor.ClassNames.INDEX_PROPERTY, tableDefinition.elementTypeName) if (columnDefinitionList.isNotEmpty()) { add(",") diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/ManyToManyDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/ManyToManyDefinition.kt similarity index 88% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/ManyToManyDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/ManyToManyDefinition.kt index c9e1ed056..a5743235d 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/ManyToManyDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/ManyToManyDefinition.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.L import com.grosner.kpoet.`@` @@ -11,17 +11,16 @@ import com.grosner.kpoet.modifiers import com.grosner.kpoet.param import com.grosner.kpoet.public import com.grosner.kpoet.statement -import com.raizlabs.dbflow5.annotation.ForeignKey -import com.raizlabs.dbflow5.annotation.ManyToMany -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.extractTypeNameFromAnnotation -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty -import com.raizlabs.dbflow5.processor.utils.lower -import com.raizlabs.dbflow5.processor.utils.toTypeElement +import com.dbflow5.annotation.ForeignKey +import com.dbflow5.annotation.ManyToMany +import com.dbflow5.annotation.PrimaryKey +import com.dbflow5.annotation.Table +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.extractTypeNameFromAnnotation +import com.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.processor.utils.lower +import com.dbflow5.processor.utils.toTypeElement import com.squareup.javapoet.AnnotationSpec import com.squareup.javapoet.TypeName import com.squareup.javapoet.TypeSpec @@ -103,7 +102,7 @@ class ManyToManyDefinition(element: TypeElement, processorManager: ProcessorMana } override val extendsClass: TypeName? - get() = ClassNames.BASE_MODEL + get() = com.dbflow5.processor.ClassNames.BASE_MODEL private fun appendColumnDefinitions(typeBuilder: TypeSpec.Builder, referencedDefinition: TableDefinition, index: Int, optionalName: String) { diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/Methods.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/Methods.kt similarity index 93% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/Methods.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/Methods.kt index a2bf2f7fa..dc657a51f 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/Methods.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/Methods.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.S import com.grosner.kpoet.`=` @@ -10,14 +10,13 @@ import com.grosner.kpoet.modifiers import com.grosner.kpoet.param import com.grosner.kpoet.public import com.grosner.kpoet.statement -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.definition.column.wrapperCommaIfBaseModel -import com.raizlabs.dbflow5.processor.utils.ModelUtils -import com.raizlabs.dbflow5.processor.utils.`override fun` -import com.raizlabs.dbflow5.processor.utils.codeBlock -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty -import com.raizlabs.dbflow5.quote +import com.dbflow5.annotation.ConflictAction +import com.dbflow5.processor.definition.column.wrapperCommaIfBaseModel +import com.dbflow5.processor.utils.ModelUtils +import com.dbflow5.processor.utils.`override fun` +import com.dbflow5.processor.utils.codeBlock +import com.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.quote import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.MethodSpec @@ -52,7 +51,7 @@ class BindToContentValuesMethod(private val baseTableDefinition: BaseTableDefini val methodBuilder = MethodSpec.methodBuilder(if (isInsert) "bindToInsertValues" else "bindToContentValues") .addAnnotation(Override::class.java) .addModifiers(Modifier.PUBLIC, Modifier.FINAL) - .addParameter(ClassNames.CONTENT_VALUES, PARAM_CONTENT_VALUES) + .addParameter(com.dbflow5.processor.ClassNames.CONTENT_VALUES, PARAM_CONTENT_VALUES) .addParameter(baseTableDefinition.parameterClassName, ModelUtils.variable) .returns(TypeName.VOID) @@ -126,7 +125,7 @@ class BindToStatementMethod(private val tableDefinition: TableDefinition, privat val methodBuilder = MethodSpec.methodBuilder(mode.methodName) .addAnnotation(Override::class.java) .addModifiers(Modifier.PUBLIC, Modifier.FINAL) - .addParameter(ClassNames.DATABASE_STATEMENT, PARAM_STATEMENT) + .addParameter(com.dbflow5.processor.ClassNames.DATABASE_STATEMENT, PARAM_STATEMENT) .addParameter(tableDefinition.parameterClassName, ModelUtils.variable).returns(TypeName.VOID) @@ -237,7 +236,7 @@ class CreationQueryMethod(private val tableDefinition: TableDefinition) : Method add(") REFERENCES ") }.build()) - tableNameBlocks.add(codeBlock { add("\$T.getTableName(\$T.class)", ClassNames.FLOW_MANAGER, fk.referencedClassName) }) + tableNameBlocks.add(codeBlock { add("\$T.getTableName(\$T.class)", com.dbflow5.processor.ClassNames.FLOW_MANAGER, fk.referencedClassName) }) referenceKeyBlocks.add(referenceBuilder.apply { add("(") @@ -304,7 +303,7 @@ class ExistenceMethod(private val tableDefinition: BaseTableDefinition) : Method override val methodSpec get() = `override fun`(TypeName.BOOLEAN, "exists", param(tableDefinition.parameterClassName!!, ModelUtils.variable), - param(ClassNames.DATABASE_WRAPPER, "wrapper")) { + param(com.dbflow5.processor.ClassNames.DATABASE_WRAPPER, "wrapper")) { modifiers(public, final) code { // only quick check if enabled. @@ -434,8 +433,8 @@ class LoadFromCursorMethod(private val baseTableDefinition: BaseTableDefinition) override val methodSpec: MethodSpec get() = `override fun`(baseTableDefinition.parameterClassName!!, "loadFromCursor", - param(ClassNames.FLOW_CURSOR, PARAM_CURSOR), - param(ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper)) { + param(com.dbflow5.processor.ClassNames.FLOW_CURSOR, PARAM_CURSOR), + param(com.dbflow5.processor.ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper)) { modifiers(public, final) statement("\$1T ${ModelUtils.variable} = new \$1T()", baseTableDefinition.parameterClassName) val index = AtomicInteger(0) @@ -479,7 +478,7 @@ class OneToManyDeleteMethod(private val tableDefinition: TableDefinition) : Meth return `override fun`(TypeName.BOOLEAN, "delete", param(tableDefinition.elementClassName!!, ModelUtils.variable)) { modifiers(public, final) - addParameter(ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper) + addParameter(com.dbflow5.processor.ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper) if (tableDefinition.cachingEnabled) { statement("cacheAdapter.removeModelFromCache(${ModelUtils.variable})") } @@ -496,7 +495,7 @@ class OneToManyDeleteMethod(private val tableDefinition: TableDefinition) : Meth } /** - * Description: Overrides the save, update, and insert methods if the [com.raizlabs.android.dbflow.annotation.OneToMany.Method.SAVE] is used. + * Description: Overrides the save, update, and insert methods if the [com.dbflow5.annotation.OneToMany.Method.SAVE] is used. */ class OneToManySaveMethod(private val tableDefinition: TableDefinition, private val methodName: String) : MethodDefinition { @@ -516,7 +515,7 @@ class OneToManySaveMethod(private val tableDefinition: TableDefinition, return `override fun`(retType, methodName, param(tableDefinition.elementClassName!!, ModelUtils.variable)) { modifiers(public, final) - addParameter(ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper) + addParameter(com.dbflow5.processor.ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper) code { if (methodName == METHOD_INSERT) { add("long rowId = ") @@ -560,11 +559,11 @@ class OneToManySaveMethod(private val tableDefinition: TableDefinition, class PrimaryConditionMethod(private val tableDefinition: BaseTableDefinition) : MethodDefinition { override val methodSpec: MethodSpec? - get() = `override fun`(ClassNames.OPERATOR_GROUP, "getPrimaryConditionClause", + get() = `override fun`(com.dbflow5.processor.ClassNames.OPERATOR_GROUP, "getPrimaryConditionClause", param(tableDefinition.parameterClassName!!, ModelUtils.variable)) { modifiers(public, final) code { - statement("\$T clause = \$T.clause()", ClassNames.OPERATOR_GROUP, ClassNames.OPERATOR_GROUP) + statement("\$T clause = \$T.clause()", com.dbflow5.processor.ClassNames.OPERATOR_GROUP, com.dbflow5.processor.ClassNames.OPERATOR_GROUP) tableDefinition.primaryColumnDefinitions.forEach { val codeBuilder = CodeBlock.builder() it.appendPropertyComparisonAccessStatement(codeBuilder) diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/MigrationDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/MigrationDefinition.kt similarity index 91% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/MigrationDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/MigrationDefinition.kt index ac267d5e9..cbf36d746 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/MigrationDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/MigrationDefinition.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.typeName -import com.raizlabs.dbflow5.annotation.Migration -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.annotation.Migration +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.isNullOrEmpty import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.ParameterizedTypeName diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/ModelViewDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/ModelViewDefinition.kt similarity index 80% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/ModelViewDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/ModelViewDefinition.kt index 8844c6fb1..08bbbc0b5 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/ModelViewDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/ModelViewDefinition.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.S import com.grosner.kpoet.`=` @@ -8,25 +8,24 @@ import com.grosner.kpoet.final import com.grosner.kpoet.modifiers import com.grosner.kpoet.param import com.grosner.kpoet.public -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.ColumnMap -import com.raizlabs.dbflow5.annotation.ModelView -import com.raizlabs.dbflow5.annotation.ModelViewQuery -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ColumnValidator -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.column.ColumnDefinition -import com.raizlabs.dbflow5.processor.definition.column.ReferenceColumnDefinition -import com.raizlabs.dbflow5.processor.utils.ElementUtility -import com.raizlabs.dbflow5.processor.utils.ModelUtils -import com.raizlabs.dbflow5.processor.utils.`override fun` -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.ensureVisibleStatic -import com.raizlabs.dbflow5.processor.utils.implementsClass -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty -import com.raizlabs.dbflow5.processor.utils.simpleString -import com.raizlabs.dbflow5.processor.utils.toTypeElement -import com.raizlabs.dbflow5.processor.utils.toTypeErasedElement +import com.dbflow5.annotation.Column +import com.dbflow5.annotation.ColumnMap +import com.dbflow5.annotation.ModelView +import com.dbflow5.annotation.ModelViewQuery +import com.dbflow5.processor.ColumnValidator +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.column.ColumnDefinition +import com.dbflow5.processor.definition.column.ReferenceColumnDefinition +import com.dbflow5.processor.utils.ElementUtility +import com.dbflow5.processor.utils.ModelUtils +import com.dbflow5.processor.utils.`override fun` +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.ensureVisibleStatic +import com.dbflow5.processor.utils.implementsClass +import com.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.processor.utils.simpleString +import com.dbflow5.processor.utils.toTypeElement +import com.dbflow5.processor.utils.toTypeErasedElement import com.squareup.javapoet.ParameterizedTypeName import com.squareup.javapoet.TypeName import com.squareup.javapoet.TypeSpec @@ -74,7 +73,7 @@ class ModelViewDefinition(manager: ProcessorManager, element: Element) } implementsLoadFromCursorListener = (element as? TypeElement) - ?.implementsClass(manager.processingEnvironment, ClassNames.LOAD_FROM_CURSOR_LISTENER) ?: false + ?.implementsClass(manager.processingEnvironment, com.dbflow5.processor.ClassNames.LOAD_FROM_CURSOR_LISTENER) ?: false } @@ -140,8 +139,8 @@ class ModelViewDefinition(manager: ProcessorManager, element: Element) if (element != null) { val returnElement = element.returnType.toTypeElement() ensureVisibleStatic(element, typeElement, "ModelViewQuery") - if (!returnElement.implementsClass(manager.processingEnvironment, ClassNames.QUERY)) { - manager.logError("The function ${variableElement.simpleName} must return ${ClassNames.QUERY} from $elementName") + if (!returnElement.implementsClass(manager.processingEnvironment, com.dbflow5.processor.ClassNames.QUERY)) { + manager.logError("The function ${variableElement.simpleName} must return ${com.dbflow5.processor.ClassNames.QUERY} from $elementName") } } @@ -158,7 +157,7 @@ class ModelViewDefinition(manager: ProcessorManager, element: Element) get() = columnDefinitions override val extendsClass: TypeName? - get() = ParameterizedTypeName.get(ClassNames.MODEL_VIEW_ADAPTER, elementClassName) + get() = ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.MODEL_VIEW_ADAPTER, elementClassName) override fun onWriteDefinition(typeBuilder: TypeSpec.Builder) { typeBuilder.apply { @@ -173,7 +172,7 @@ class ModelViewDefinition(manager: ProcessorManager, element: Element) writeGetModelClass(typeBuilder, elementClassName) `override fun`(String::class, "getCreationQuery", - param(ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper)) { + param(com.dbflow5.processor.ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper)) { modifiers(public, final) `return`("\$T.\$L().getQuery()", elementClassName, queryFieldName) } diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/OneToManyDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/OneToManyDefinition.kt similarity index 81% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/OneToManyDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/OneToManyDefinition.kt index cfb19e2f8..82fd11554 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/OneToManyDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/OneToManyDefinition.kt @@ -1,27 +1,26 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.`for` import com.grosner.kpoet.`if` import com.grosner.kpoet.end import com.grosner.kpoet.statement import com.grosner.kpoet.typeName -import com.raizlabs.dbflow5.annotation.OneToMany -import com.raizlabs.dbflow5.annotation.OneToManyMethod -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.column.ColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.GetterSetter -import com.raizlabs.dbflow5.processor.definition.column.PrivateScopeColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.VisibleScopeColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.modelBlock -import com.raizlabs.dbflow5.processor.definition.column.wrapperCommaIfBaseModel -import com.raizlabs.dbflow5.processor.definition.column.wrapperIfBaseModel -import com.raizlabs.dbflow5.processor.utils.ModelUtils -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.isSubclass -import com.raizlabs.dbflow5.processor.utils.simpleString -import com.raizlabs.dbflow5.processor.utils.statement -import com.raizlabs.dbflow5.processor.utils.toTypeElement +import com.dbflow5.annotation.OneToMany +import com.dbflow5.annotation.OneToManyMethod +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.column.ColumnAccessor +import com.dbflow5.processor.definition.column.GetterSetter +import com.dbflow5.processor.definition.column.PrivateScopeColumnAccessor +import com.dbflow5.processor.definition.column.VisibleScopeColumnAccessor +import com.dbflow5.processor.definition.column.modelBlock +import com.dbflow5.processor.definition.column.wrapperCommaIfBaseModel +import com.dbflow5.processor.definition.column.wrapperIfBaseModel +import com.dbflow5.processor.utils.ModelUtils +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.isSubclass +import com.dbflow5.processor.utils.simpleString +import com.dbflow5.processor.utils.statement +import com.dbflow5.processor.utils.toTypeElement import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.MethodSpec @@ -108,10 +107,10 @@ class OneToManyDefinition(executableElement: ExecutableElement, } else { val param = parameters[0] val name = param.asType().typeName - if (name == ClassNames.DATABASE_WRAPPER) { + if (name == com.dbflow5.processor.ClassNames.DATABASE_WRAPPER) { hasWrapper = true } else { - manager.logError(OneToManyDefinition::class, "OneToMany Methods can only specify a ${ClassNames.DATABASE_WRAPPER} as its parameter.") + manager.logError(OneToManyDefinition::class, "OneToMany Methods can only specify a ${com.dbflow5.processor.ClassNames.DATABASE_WRAPPER} as its parameter.") } } } @@ -130,7 +129,7 @@ class OneToManyDefinition(executableElement: ExecutableElement, referencedTableType = refTableType referencedType = referencedTableType.toTypeElement(manager) - extendsModel = referencedType.isSubclass(manager.processingEnvironment, ClassNames.MODEL) + extendsModel = referencedType.isSubclass(manager.processingEnvironment, com.dbflow5.processor.ClassNames.MODEL) } } @@ -176,8 +175,8 @@ class OneToManyDefinition(executableElement: ExecutableElement, // need to load adapter for non-model classes if (!extendsModel || efficientCodeMethods) { statement("\$T adapter = \$T.getModelAdapter(\$T.class)", - ParameterizedTypeName.get(ClassNames.MODEL_ADAPTER, referencedTableType), - ClassNames.FLOW_MANAGER, referencedTableType) + ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.MODEL_ADAPTER, referencedTableType), + com.dbflow5.processor.ClassNames.FLOW_MANAGER, referencedTableType) } if (efficientCodeMethods) { diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/QueryModelDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/QueryModelDefinition.kt similarity index 82% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/QueryModelDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/QueryModelDefinition.kt index 109cea480..3d8f272d8 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/QueryModelDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/QueryModelDefinition.kt @@ -1,17 +1,16 @@ -package com.raizlabs.dbflow5.processor.definition - -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.ColumnMap -import com.raizlabs.dbflow5.annotation.QueryModel -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ColumnValidator -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.column.ColumnDefinition -import com.raizlabs.dbflow5.processor.definition.column.ReferenceColumnDefinition -import com.raizlabs.dbflow5.processor.utils.ElementUtility -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.extractTypeNameFromAnnotation -import com.raizlabs.dbflow5.processor.utils.implementsClass +package com.dbflow5.processor.definition + +import com.dbflow5.annotation.Column +import com.dbflow5.annotation.ColumnMap +import com.dbflow5.annotation.QueryModel +import com.dbflow5.processor.ColumnValidator +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.column.ColumnDefinition +import com.dbflow5.processor.definition.column.ReferenceColumnDefinition +import com.dbflow5.processor.utils.ElementUtility +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.extractTypeNameFromAnnotation +import com.dbflow5.processor.utils.implementsClass import com.squareup.javapoet.ParameterizedTypeName import com.squareup.javapoet.TypeName import com.squareup.javapoet.TypeSpec @@ -38,7 +37,7 @@ class QueryModelDefinition(typeElement: Element, processorManager: ProcessorMana } implementsLoadFromCursorListener = (element as? TypeElement) - ?.implementsClass(manager.processingEnvironment, ClassNames.LOAD_FROM_CURSOR_LISTENER) == true + ?.implementsClass(manager.processingEnvironment, com.dbflow5.processor.ClassNames.LOAD_FROM_CURSOR_LISTENER) == true methods = arrayOf(LoadFromCursorMethod(this)) @@ -59,7 +58,7 @@ class QueryModelDefinition(typeElement: Element, processorManager: ProcessorMana } override val extendsClass: TypeName? - get() = ParameterizedTypeName.get(ClassNames.QUERY_MODEL_ADAPTER, elementClassName) + get() = ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.QUERY_MODEL_ADAPTER, elementClassName) override fun onWriteDefinition(typeBuilder: TypeSpec.Builder) { typeBuilder.apply { diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/TableDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/TableDefinition.kt similarity index 86% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/TableDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/TableDefinition.kt index 6d97d50fe..8aea4bd53 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/TableDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/TableDefinition.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.grosner.kpoet.L import com.grosner.kpoet.S @@ -16,35 +16,34 @@ import com.grosner.kpoet.protected import com.grosner.kpoet.public import com.grosner.kpoet.statement import com.grosner.kpoet.switch -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.ColumnMap -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.annotation.DEFAULT_CACHE_SIZE -import com.raizlabs.dbflow5.annotation.ForeignKey -import com.raizlabs.dbflow5.annotation.InheritedColumn -import com.raizlabs.dbflow5.annotation.InheritedPrimaryKey -import com.raizlabs.dbflow5.annotation.ModelCacheField -import com.raizlabs.dbflow5.annotation.MultiCacheField -import com.raizlabs.dbflow5.annotation.OneToMany -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ColumnValidator -import com.raizlabs.dbflow5.processor.OneToManyValidator -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.BindToStatementMethod.Mode.* -import com.raizlabs.dbflow5.processor.definition.column.ColumnDefinition -import com.raizlabs.dbflow5.processor.definition.column.DefinitionUtils -import com.raizlabs.dbflow5.processor.definition.column.ReferenceColumnDefinition -import com.raizlabs.dbflow5.processor.utils.ElementUtility -import com.raizlabs.dbflow5.processor.utils.ModelUtils -import com.raizlabs.dbflow5.processor.utils.ModelUtils.wrapper -import com.raizlabs.dbflow5.processor.utils.`override fun` -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.ensureVisibleStatic -import com.raizlabs.dbflow5.processor.utils.implementsClass -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty -import com.raizlabs.dbflow5.quote +import com.dbflow5.annotation.Column +import com.dbflow5.annotation.ColumnMap +import com.dbflow5.annotation.ConflictAction +import com.dbflow5.annotation.DEFAULT_CACHE_SIZE +import com.dbflow5.annotation.ForeignKey +import com.dbflow5.annotation.InheritedColumn +import com.dbflow5.annotation.InheritedPrimaryKey +import com.dbflow5.annotation.ModelCacheField +import com.dbflow5.annotation.MultiCacheField +import com.dbflow5.annotation.OneToMany +import com.dbflow5.annotation.PrimaryKey +import com.dbflow5.annotation.Table +import com.dbflow5.processor.ColumnValidator +import com.dbflow5.processor.OneToManyValidator +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.BindToStatementMethod.Mode.* +import com.dbflow5.processor.definition.column.ColumnDefinition +import com.dbflow5.processor.definition.column.DefinitionUtils +import com.dbflow5.processor.definition.column.ReferenceColumnDefinition +import com.dbflow5.processor.utils.ElementUtility +import com.dbflow5.processor.utils.ModelUtils +import com.dbflow5.processor.utils.ModelUtils.wrapper +import com.dbflow5.processor.utils.`override fun` +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.ensureVisibleStatic +import com.dbflow5.processor.utils.implementsClass +import com.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.quote import com.squareup.javapoet.ArrayTypeName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.NameAllocator @@ -160,13 +159,13 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab } implementsLoadFromCursorListener = element.implementsClass(manager.processingEnvironment, - ClassNames.LOAD_FROM_CURSOR_LISTENER) + com.dbflow5.processor.ClassNames.LOAD_FROM_CURSOR_LISTENER) implementsContentValuesListener = element.implementsClass(manager.processingEnvironment, - ClassNames.CONTENT_VALUES_LISTENER) + com.dbflow5.processor.ClassNames.CONTENT_VALUES_LISTENER) implementsSqlStatementListener = element.implementsClass(manager.processingEnvironment, - ClassNames.SQLITE_STATEMENT_LISTENER) + com.dbflow5.processor.ClassNames.SQLITE_STATEMENT_LISTENER) } contentValueMethods = arrayOf(BindToContentValuesMethod(this, true, implementsContentValuesListener), @@ -395,7 +394,7 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab get() = autoIncrementColumn?.let { arrayListOf(it) } ?: _primaryColumnDefinitions override val extendsClass: TypeName? - get() = ParameterizedTypeName.get(ClassNames.MODEL_ADAPTER, elementClassName) + get() = ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.MODEL_ADAPTER, elementClassName) override fun onWriteDefinition(typeBuilder: TypeSpec.Builder) { // check references to properly set them up. @@ -412,26 +411,26 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab } if (updateConflictActionName.isNotEmpty()) { - `override fun`(ClassNames.CONFLICT_ACTION, "getUpdateOnConflictAction") { + `override fun`(com.dbflow5.processor.ClassNames.CONFLICT_ACTION, "getUpdateOnConflictAction") { modifiers(public, final) - `return`("\$T.$updateConflictActionName", ClassNames.CONFLICT_ACTION) + `return`("\$T.$updateConflictActionName", com.dbflow5.processor.ClassNames.CONFLICT_ACTION) } } if (insertConflictActionName.isNotEmpty()) { - `override fun`(ClassNames.CONFLICT_ACTION, "getInsertOnConflictAction") { + `override fun`(com.dbflow5.processor.ClassNames.CONFLICT_ACTION, "getInsertOnConflictAction") { modifiers(public, final) - `return`("\$T.$insertConflictActionName", ClassNames.CONFLICT_ACTION) + `return`("\$T.$insertConflictActionName", com.dbflow5.processor.ClassNames.CONFLICT_ACTION) } } val paramColumnName = "columnName" val getPropertiesBuilder = CodeBlock.builder() - `override fun`(ClassNames.PROPERTY, "getProperty", + `override fun`(com.dbflow5.processor.ClassNames.PROPERTY, "getProperty", param(String::class, paramColumnName)) { modifiers(public, final) - statement("$paramColumnName = \$T.quoteIfNeeded($paramColumnName)", ClassNames.STRING_UTILS) + statement("$paramColumnName = \$T.quoteIfNeeded($paramColumnName)", com.dbflow5.processor.ClassNames.STRING_UTILS) switch("($paramColumnName)") { columnDefinitions.indices.forEach { i -> @@ -450,8 +449,8 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab } } - `public static final field`(ArrayTypeName.of(ClassNames.IPROPERTY), "ALL_COLUMN_PROPERTIES") { - `=`("new \$T[]{\$L}", ClassNames.IPROPERTY, getPropertiesBuilder.build().toString()) + `public static final field`(ArrayTypeName.of(com.dbflow5.processor.ClassNames.IPROPERTY), "ALL_COLUMN_PROPERTIES") { + `=`("new \$T[]{\$L}", com.dbflow5.processor.ClassNames.IPROPERTY, getPropertiesBuilder.build().toString()) } // add index properties here @@ -478,7 +477,7 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab saveForeignKeyFields.forEach { it.appendSaveMethod(code) } `override fun`(TypeName.VOID, "saveForeignKeys", param(elementClassName!!, ModelUtils.variable), - param(ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper)) { + param(com.dbflow5.processor.ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper)) { modifiers(public, final) addCode(code.build()) } @@ -492,13 +491,13 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab deleteForeignKeyFields.forEach { it.appendDeleteMethod(code) } `override fun`(TypeName.VOID, "deleteForeignKeys", param(elementClassName!!, ModelUtils.variable), - param(ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper)) { + param(com.dbflow5.processor.ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper)) { modifiers(public, final) addCode(code.build()) } } - `override fun`(ArrayTypeName.of(ClassNames.IPROPERTY), "getAllColumnProperties") { + `override fun`(ArrayTypeName.of(com.dbflow5.processor.ClassNames.IPROPERTY), "getAllColumnProperties") { modifiers(public, final) `return`("ALL_COLUMN_PROPERTIES") } @@ -511,11 +510,11 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab } if (cachingEnabled) { - `private static final field`(ClassNames.CACHE_ADAPTER, "cacheAdapter") { + `private static final field`(com.dbflow5.processor.ClassNames.CACHE_ADAPTER, "cacheAdapter") { `=` { add("\$L", TypeSpec.anonymousClassBuilder("") - .addSuperinterface(ParameterizedTypeName.get(ClassNames.CACHE_ADAPTER, elementTypeName)) + .addSuperinterface(ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.CACHE_ADAPTER, elementTypeName)) .apply { val primaryColumns = primaryColumnDefinitions if (primaryColumns.size > 1) { @@ -533,7 +532,7 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab `override fun`(ArrayTypeName.of(Any::class.java), "getCachingColumnValuesFromCursor", param(ArrayTypeName.of(Any::class.java), "inValues"), - param(ClassNames.FLOW_CURSOR, "cursor")) { + param(com.dbflow5.processor.ClassNames.FLOW_CURSOR, "cursor")) { modifiers(public, final) for (i in primaryColumns.indices) { val column = primaryColumns[i] @@ -551,7 +550,7 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab addCode(primaryColumns[0].getSimpleAccessString()) } - `override fun`(Any::class, "getCachingColumnValueFromCursor", param(ClassNames.FLOW_CURSOR, "cursor")) { + `override fun`(Any::class, "getCachingColumnValueFromCursor", param(com.dbflow5.processor.ClassNames.FLOW_CURSOR, "cursor")) { modifiers(public, final) val column = primaryColumns[0] val method = DefinitionUtils.getLoadFromCursorMethodString(column.elementTypeName, column.wrapperTypeName) @@ -577,7 +576,7 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab } if (!customCacheFieldName.isNullOrEmpty()) { - `override fun`(ParameterizedTypeName.get(ClassNames.MODEL_CACHE, elementClassName, + `override fun`(ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.MODEL_CACHE, elementClassName, WildcardTypeName.subtypeOf(Any::class.java)), "createModelCache") { modifiers(public, final) `return`("\$T.$customCacheFieldName", elementClassName) @@ -585,7 +584,7 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab } if (!customMultiCacheFieldName.isNullOrEmpty()) { - `override fun`(ParameterizedTypeName.get(ClassNames.MULTI_KEY_CACHE_CONVERTER, + `override fun`(ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.MULTI_KEY_CACHE_CONVERTER, WildcardTypeName.subtypeOf(Any::class.java)), "getCacheConverter") { modifiers(public, final) `return`("\$T.$customMultiCacheFieldName", elementClassName) @@ -594,8 +593,8 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab if (foreignKeyDefinitions.isNotEmpty()) { `override fun`(TypeName.VOID, "reloadRelationships", param(elementClassName!!, ModelUtils.variable), - param(ClassNames.FLOW_CURSOR, LoadFromCursorMethod.PARAM_CURSOR), - param(ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper)) { + param(com.dbflow5.processor.ClassNames.FLOW_CURSOR, LoadFromCursorMethod.PARAM_CURSOR), + param(com.dbflow5.processor.ClassNames.DATABASE_WRAPPER, ModelUtils.wrapper)) { modifiers(public, final) code { val noIndex = AtomicInteger(-1) @@ -612,26 +611,26 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab val singlePrimaryKey = primaryColumnDefinitions.size == 1 - `override fun`(ClassNames.SINGLE_MODEL_LOADER, "createSingleModelLoader") { + `override fun`(com.dbflow5.processor.ClassNames.SINGLE_MODEL_LOADER, "createSingleModelLoader") { modifiers(public, final) addStatement("return new \$T<>(getTable(), cacheAdapter)", if (singlePrimaryKey) - ClassNames.SINGLE_KEY_CACHEABLE_MODEL_LOADER + com.dbflow5.processor.ClassNames.SINGLE_KEY_CACHEABLE_MODEL_LOADER else - ClassNames.CACHEABLE_MODEL_LOADER) + com.dbflow5.processor.ClassNames.CACHEABLE_MODEL_LOADER) } - `override fun`(ClassNames.LIST_MODEL_LOADER, "createListModelLoader") { + `override fun`(com.dbflow5.processor.ClassNames.LIST_MODEL_LOADER, "createListModelLoader") { modifiers(public, final) `return`("new \$T<>(getTable(), cacheAdapter)", if (singlePrimaryKey) - ClassNames.SINGLE_KEY_CACHEABLE_LIST_MODEL_LOADER + com.dbflow5.processor.ClassNames.SINGLE_KEY_CACHEABLE_LIST_MODEL_LOADER else - ClassNames.CACHEABLE_LIST_MODEL_LOADER) + com.dbflow5.processor.ClassNames.CACHEABLE_LIST_MODEL_LOADER) } - `override fun`(ParameterizedTypeName.get(ClassNames.CACHEABLE_LIST_MODEL_SAVER, elementClassName), + `override fun`(ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.CACHEABLE_LIST_MODEL_SAVER, elementClassName), "createListModelSaver") { modifiers(protected) - `return`("new \$T<>(getModelSaver(), cacheAdapter)", ClassNames.CACHEABLE_LIST_MODEL_SAVER) + `return`("new \$T<>(getModelSaver(), cacheAdapter)", com.dbflow5.processor.ClassNames.CACHEABLE_LIST_MODEL_SAVER) } `override fun`(TypeName.BOOLEAN, "cachingEnabled") { modifiers(public, final) @@ -639,7 +638,7 @@ class TableDefinition(manager: ProcessorManager, element: TypeElement) : BaseTab } `override fun`(elementClassName!!, "load", param(elementClassName!!, "model"), - param(ClassNames.DATABASE_WRAPPER, wrapper)) { + param(com.dbflow5.processor.ClassNames.DATABASE_WRAPPER, wrapper)) { modifiers(public, final) statement("\$T loaded = super.load(model, $wrapper)", elementClassName!!) statement("cacheAdapter.storeModelInCache(model)") diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/TypeConverterDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/TypeConverterDefinition.kt similarity index 84% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/TypeConverterDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/TypeConverterDefinition.kt index b3b3adddc..5025caccf 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/TypeConverterDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/TypeConverterDefinition.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition -import com.raizlabs.dbflow5.annotation.TypeConverter -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.utils.annotation +import com.dbflow5.annotation.TypeConverter +import com.dbflow5.processor.ClassNames +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.utils.annotation import com.squareup.javapoet.ClassName import com.squareup.javapoet.TypeName import javax.lang.model.element.TypeElement @@ -43,7 +43,7 @@ class TypeConverterDefinition(val className: ClassName, var typeConverterSuper: DeclaredType? = null val typeConverter = manager.typeUtils.getDeclaredType(manager.elements - .getTypeElement(ClassNames.TYPE_CONVERTER.toString())) + .getTypeElement(com.dbflow5.processor.ClassNames.TYPE_CONVERTER.toString())) for (superType in types.directSupertypes(typeMirror)) { val erasure = types.erasure(superType) diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/TypeDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/TypeDefinition.kt similarity index 83% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/TypeDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/TypeDefinition.kt index 4d1b378e0..818f3bb4e 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/TypeDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/TypeDefinition.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition import com.squareup.javapoet.TypeSpec diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/UniqueGroupsDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/UniqueGroupsDefinition.kt similarity index 78% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/UniqueGroupsDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/UniqueGroupsDefinition.kt index e6364c432..33eac5ff6 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/UniqueGroupsDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/UniqueGroupsDefinition.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.processor.definition +package com.dbflow5.processor.definition -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.annotation.UniqueGroup -import com.raizlabs.dbflow5.processor.definition.column.ColumnDefinition -import com.raizlabs.dbflow5.processor.definition.column.ReferenceColumnDefinition -import com.raizlabs.dbflow5.quote +import com.dbflow5.annotation.ConflictAction +import com.dbflow5.annotation.UniqueGroup +import com.dbflow5.processor.definition.column.ColumnDefinition +import com.dbflow5.processor.definition.column.ReferenceColumnDefinition +import com.dbflow5.quote import com.squareup.javapoet.CodeBlock /** diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ColumnAccessCombiner.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ColumnAccessCombiner.kt similarity index 96% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ColumnAccessCombiner.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/column/ColumnAccessCombiner.kt index 5962f4004..b21fd732e 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ColumnAccessCombiner.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ColumnAccessCombiner.kt @@ -1,17 +1,16 @@ -package com.raizlabs.dbflow5.processor.definition.column +package com.dbflow5.processor.definition.column import com.grosner.kpoet.S import com.grosner.kpoet.`else` import com.grosner.kpoet.`if` import com.grosner.kpoet.end import com.grosner.kpoet.statement -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.SQLiteHelper -import com.raizlabs.dbflow5.processor.utils.ModelUtils -import com.raizlabs.dbflow5.processor.utils.catch -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty -import com.raizlabs.dbflow5.processor.utils.statement -import com.raizlabs.dbflow5.quote +import com.dbflow5.processor.SQLiteHelper +import com.dbflow5.processor.utils.ModelUtils +import com.dbflow5.processor.utils.catch +import com.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.processor.utils.statement +import com.dbflow5.quote import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.NameAllocator @@ -117,7 +116,7 @@ class ExistenceAccessCombiner(combiner: Combiner, add("\$T.selectCountOf()\n.from(\$T.class)\n" + ".where(getPrimaryConditionClause(\$L))\n" + ".hasData(wrapper)", - ClassNames.SQLITE, tableClassName, modelBlock) + com.dbflow5.processor.ClassNames.SQLITE, tableClassName, modelBlock) } add(";\n") } @@ -294,7 +293,7 @@ class PrimaryReferenceAccessCombiner(combiner: Combiner) override fun addNull(code: CodeBlock.Builder, columnRepresentation: String, index: Int) { code.addStatement("clause.and(\$L.eq((\$T) \$L))", columnRepresentation, - ClassNames.ICONDITIONAL, "null") + com.dbflow5.processor.ClassNames.ICONDITIONAL, "null") } } @@ -336,7 +335,7 @@ class SaveModelAccessCombiner(combiner: Combiner, statement("$access.save(${wrapperIfBaseModel(extendsBaseModel)})") } else { statement("\$T.getModelAdapter(\$T.class).save($access, ${ModelUtils.wrapper})", - ClassNames.FLOW_MANAGER, fieldTypeName) + com.dbflow5.processor.ClassNames.FLOW_MANAGER, fieldTypeName) } }.end() } @@ -357,7 +356,7 @@ class DeleteModelAccessCombiner(combiner: Combiner, statement("$access.delete(${wrapperIfBaseModel(extendsBaseModel)})") } else { statement("\$T.getModelAdapter(\$T.class).delete($access, ${ModelUtils.wrapper})", - ClassNames.FLOW_MANAGER, fieldTypeName) + com.dbflow5.processor.ClassNames.FLOW_MANAGER, fieldTypeName) } }.end() } diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ColumnAccessor.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ColumnAccessor.kt similarity index 97% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ColumnAccessor.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/column/ColumnAccessor.kt index 15272b9bb..b97bbb7eb 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ColumnAccessor.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ColumnAccessor.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.processor.definition.column +package com.dbflow5.processor.definition.column import com.grosner.kpoet.code -import com.raizlabs.dbflow5.data.Blob -import com.raizlabs.dbflow5.processor.utils.capitalizeFirstLetter -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty -import com.raizlabs.dbflow5.processor.utils.lower +import com.dbflow5.data.Blob +import com.dbflow5.processor.utils.capitalizeFirstLetter +import com.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.processor.utils.lower import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.TypeName diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ColumnDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ColumnDefinition.kt similarity index 91% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ColumnDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/column/ColumnDefinition.kt index 0c1e61bc3..09bb57e66 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ColumnDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ColumnDefinition.kt @@ -1,28 +1,27 @@ -package com.raizlabs.dbflow5.processor.definition.column +package com.dbflow5.processor.definition.column import com.grosner.kpoet.code -import com.raizlabs.dbflow5.annotation.Collate -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.annotation.INDEX_GENERIC -import com.raizlabs.dbflow5.annotation.Index -import com.raizlabs.dbflow5.annotation.NotNull -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Unique -import com.raizlabs.dbflow5.data.Blob -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.BaseDefinition -import com.raizlabs.dbflow5.processor.definition.BaseTableDefinition -import com.raizlabs.dbflow5.processor.definition.TableDefinition -import com.raizlabs.dbflow5.processor.definition.TypeConverterDefinition -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.fromTypeMirror -import com.raizlabs.dbflow5.processor.utils.getTypeElement -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty -import com.raizlabs.dbflow5.processor.utils.toClassName -import com.raizlabs.dbflow5.processor.utils.toTypeElement -import com.raizlabs.dbflow5.quote +import com.dbflow5.annotation.Collate +import com.dbflow5.annotation.Column +import com.dbflow5.annotation.ConflictAction +import com.dbflow5.annotation.INDEX_GENERIC +import com.dbflow5.annotation.Index +import com.dbflow5.annotation.NotNull +import com.dbflow5.annotation.PrimaryKey +import com.dbflow5.annotation.Unique +import com.dbflow5.data.Blob +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.BaseDefinition +import com.dbflow5.processor.definition.BaseTableDefinition +import com.dbflow5.processor.definition.TableDefinition +import com.dbflow5.processor.definition.TypeConverterDefinition +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.fromTypeMirror +import com.dbflow5.processor.utils.getTypeElement +import com.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.processor.utils.toClassName +import com.dbflow5.processor.utils.toTypeElement +import com.dbflow5.quote import com.squareup.javapoet.ArrayTypeName import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock @@ -129,7 +128,7 @@ constructor(processorManager: ProcessorManager, element: Element, // android support annotation element.annotationMirrors - .find { it.annotationType.toTypeElement().toClassName() == ClassNames.NON_NULL }?.let { + .find { it.annotationType.toTypeElement().toClassName() == com.dbflow5.processor.ClassNames.NON_NULL }?.let { isNotNullType = true isNullableType = false } @@ -239,7 +238,7 @@ constructor(processorManager: ProcessorManager, element: Element, private fun handleSpecifiedTypeConverter(typeConverterClassName: ClassName?, typeMirror: TypeMirror?) { if (typeConverterClassName != null && typeMirror != null && - typeConverterClassName != ClassNames.TYPE_CONVERTER) { + typeConverterClassName != com.dbflow5.processor.ClassNames.TYPE_CONVERTER) { evaluateTypeConverter(TypeConverterDefinition(typeConverterClassName, typeMirror, manager), true) } } @@ -324,11 +323,11 @@ constructor(processorManager: ProcessorManager, element: Element, elementTypeName?.let { elementTypeName -> val isNonPrimitiveTypeConverter = !wrapperAccessor.isPrimitiveTarget() && wrapperAccessor is TypeConverterScopeColumnAccessor val propParam: TypeName = if (isNonPrimitiveTypeConverter) { - ParameterizedTypeName.get(ClassNames.TYPE_CONVERTED_PROPERTY, wrapperTypeName, elementTypeName.box()) + ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.TYPE_CONVERTED_PROPERTY, wrapperTypeName, elementTypeName.box()) } else if (!wrapperAccessor.isPrimitiveTarget()) { - ParameterizedTypeName.get(ClassNames.WRAPPER_PROPERTY, wrapperTypeName, elementTypeName.box()) + ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.WRAPPER_PROPERTY, wrapperTypeName, elementTypeName.box()) } else { - ParameterizedTypeName.get(ClassNames.PROPERTY, elementTypeName.box()) + ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.PROPERTY, elementTypeName.box()) } val fieldBuilder = FieldSpec.builder(propParam, @@ -345,9 +344,9 @@ constructor(processorManager: ProcessorManager, element: Element, return adapter.${"$"}L; } })""", - ClassNames.TYPE_CONVERTER_GETTER, ClassNames.TYPE_CONVERTER, + com.dbflow5.processor.ClassNames.TYPE_CONVERTER_GETTER, com.dbflow5.processor.ClassNames.TYPE_CONVERTER, baseTableDefinition.outputClassName, baseTableDefinition.outputClassName, - ClassNames.FLOW_MANAGER, + com.dbflow5.processor.ClassNames.FLOW_MANAGER, (wrapperAccessor as TypeConverterScopeColumnAccessor).typeConverterFieldName) fieldBuilder.initializer(codeBlock.build()) } else { diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/DefinitionUtils.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/DefinitionUtils.kt similarity index 87% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/DefinitionUtils.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/column/DefinitionUtils.kt index f50be9655..07df12299 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/DefinitionUtils.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/DefinitionUtils.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.processor.definition.column +package com.dbflow5.processor.definition.column -import com.raizlabs.dbflow5.processor.SQLiteHelper -import com.raizlabs.dbflow5.quote +import com.dbflow5.processor.SQLiteHelper +import com.dbflow5.quote import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.TypeName diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ForeignKeyAccessCombiner.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ForeignKeyAccessCombiner.kt similarity index 96% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ForeignKeyAccessCombiner.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/column/ForeignKeyAccessCombiner.kt index f2048fda2..ec8d26fc1 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ForeignKeyAccessCombiner.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ForeignKeyAccessCombiner.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.processor.definition.column +package com.dbflow5.processor.definition.column -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.SQLiteHelper -import com.raizlabs.dbflow5.processor.utils.statement +import com.dbflow5.processor.ClassNames +import com.dbflow5.processor.SQLiteHelper +import com.dbflow5.processor.utils.statement import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.NameAllocator @@ -70,7 +70,7 @@ class ForeignKeyLoadFromCursorCombiner(val fieldAccessor: ColumnAccessor, if (!isStubbed) { setterBlock.add("\$T.select().from(\$T.class).where()", - ClassNames.SQLITE, referencedTypeName) + com.dbflow5.processor.ClassNames.SQLITE, referencedTypeName) } else { setterBlock.statement( fieldAccessor.set(CodeBlock.of("new \$T()", referencedTypeName), modelBlock)) diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ReferenceColumnDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ReferenceColumnDefinition.kt similarity index 92% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ReferenceColumnDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/column/ReferenceColumnDefinition.kt index f83a611ac..d3c796ef6 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ReferenceColumnDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ReferenceColumnDefinition.kt @@ -1,30 +1,29 @@ -package com.raizlabs.dbflow5.processor.definition.column +package com.dbflow5.processor.definition.column import com.grosner.kpoet.S import com.grosner.kpoet.`return` import com.grosner.kpoet.case -import com.raizlabs.dbflow5.annotation.ColumnMap -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.annotation.ForeignKey -import com.raizlabs.dbflow5.annotation.ForeignKeyAction -import com.raizlabs.dbflow5.annotation.ForeignKeyReference -import com.raizlabs.dbflow5.annotation.QueryModel -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ColumnValidator -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.BaseTableDefinition -import com.raizlabs.dbflow5.processor.definition.QueryModelDefinition -import com.raizlabs.dbflow5.processor.definition.TableDefinition -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.fromTypeMirror -import com.raizlabs.dbflow5.processor.utils.implementsClass -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty -import com.raizlabs.dbflow5.processor.utils.isSubclass -import com.raizlabs.dbflow5.processor.utils.toTypeElement -import com.raizlabs.dbflow5.processor.utils.toTypeErasedElement -import com.raizlabs.dbflow5.quote -import com.raizlabs.dbflow5.quoteIfNeeded +import com.dbflow5.annotation.ColumnMap +import com.dbflow5.annotation.ConflictAction +import com.dbflow5.annotation.ForeignKey +import com.dbflow5.annotation.ForeignKeyAction +import com.dbflow5.annotation.ForeignKeyReference +import com.dbflow5.annotation.QueryModel +import com.dbflow5.annotation.Table +import com.dbflow5.processor.ColumnValidator +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.BaseTableDefinition +import com.dbflow5.processor.definition.QueryModelDefinition +import com.dbflow5.processor.definition.TableDefinition +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.fromTypeMirror +import com.dbflow5.processor.utils.implementsClass +import com.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.processor.utils.isSubclass +import com.dbflow5.processor.utils.toTypeElement +import com.dbflow5.processor.utils.toTypeErasedElement +import com.dbflow5.quote +import com.dbflow5.quoteIfNeeded import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.FieldSpec @@ -146,8 +145,8 @@ class ReferenceColumnDefinition(manager: ProcessorManager, tableDefinition: Base manager.logError("Referenced was null for $element within $elementTypeName") } - extendsBaseModel = erasedElement.isSubclass(manager.processingEnvironment, ClassNames.BASE_MODEL) - implementsModel = erasedElement.implementsClass(manager.processingEnvironment, ClassNames.MODEL) + extendsBaseModel = erasedElement.isSubclass(manager.processingEnvironment, com.dbflow5.processor.ClassNames.BASE_MODEL) + implementsModel = erasedElement.implementsClass(manager.processingEnvironment, com.dbflow5.processor.ClassNames.MODEL) isReferencingTableObject = implementsModel || erasedElement.annotation() != null nonModelColumn = !isReferencingTableObject @@ -187,7 +186,7 @@ class ReferenceColumnDefinition(manager: ProcessorManager, tableDefinition: Base var propParam: TypeName? = null val colClassName = it.columnClassName colClassName?.let { - propParam = ParameterizedTypeName.get(ClassNames.PROPERTY, it.box()) + propParam = ParameterizedTypeName.get(com.dbflow5.processor.ClassNames.PROPERTY, it.box()) } if (it.columnName.isNullOrEmpty()) { manager.logError("Found empty reference name at ${it.foreignColumnName}" + diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ReferenceDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ReferenceDefinition.kt similarity index 93% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ReferenceDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/column/ReferenceDefinition.kt index 316a6ffa6..49bc74e42 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/column/ReferenceDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/column/ReferenceDefinition.kt @@ -1,13 +1,12 @@ -package com.raizlabs.dbflow5.processor.definition.column - -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.data.Blob -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.TypeConverterDefinition -import com.raizlabs.dbflow5.processor.utils.ElementUtility -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty -import com.raizlabs.dbflow5.quote +package com.dbflow5.processor.definition.column + +import com.dbflow5.annotation.ConflictAction +import com.dbflow5.data.Blob +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.TypeConverterDefinition +import com.dbflow5.processor.utils.ElementUtility +import com.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.quote import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.TypeName @@ -108,7 +107,7 @@ class ReferenceDefinition(private val manager: ProcessorManager, private fun handleSpecifiedTypeConverter(typeConverterClassName: ClassName?, typeMirror: TypeMirror?) { if (typeConverterClassName != null && typeMirror != null && - typeConverterClassName != ClassNames.TYPE_CONVERTER) { + typeConverterClassName != com.dbflow5.processor.ClassNames.TYPE_CONVERTER) { evaluateTypeConverter(TypeConverterDefinition(typeConverterClassName, typeMirror, manager), true) } } diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/provider/ContentProvider.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/provider/ContentProvider.kt similarity index 84% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/provider/ContentProvider.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/provider/ContentProvider.kt index 17f910b10..e8bfaed69 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/provider/ContentProvider.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/provider/ContentProvider.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.definition.provider +package com.dbflow5.processor.definition.provider import com.grosner.kpoet.L import com.grosner.kpoet.`=` @@ -14,21 +14,20 @@ import com.grosner.kpoet.param import com.grosner.kpoet.parameterized import com.grosner.kpoet.public import com.grosner.kpoet.statement -import com.raizlabs.dbflow5.annotation.provider.ContentProvider -import com.raizlabs.dbflow5.annotation.provider.ContentUri -import com.raizlabs.dbflow5.annotation.provider.NotifyMethod -import com.raizlabs.dbflow5.annotation.provider.PathSegment -import com.raizlabs.dbflow5.annotation.provider.TableEndpoint -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.TableEndpointValidator -import com.raizlabs.dbflow5.processor.definition.BaseDefinition -import com.raizlabs.dbflow5.processor.definition.CodeAdder -import com.raizlabs.dbflow5.processor.definition.MethodDefinition -import com.raizlabs.dbflow5.processor.utils.`override fun` -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.controlFlow -import com.raizlabs.dbflow5.processor.utils.isNullOrEmpty +import com.dbflow5.annotation.provider.ContentProvider +import com.dbflow5.annotation.provider.ContentUri +import com.dbflow5.annotation.provider.NotifyMethod +import com.dbflow5.annotation.provider.PathSegment +import com.dbflow5.annotation.provider.TableEndpoint +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.TableEndpointValidator +import com.dbflow5.processor.definition.BaseDefinition +import com.dbflow5.processor.definition.CodeAdder +import com.dbflow5.processor.definition.MethodDefinition +import com.dbflow5.processor.utils.`override fun` +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.controlFlow +import com.dbflow5.processor.utils.isNullOrEmpty import com.squareup.javapoet.ArrayTypeName import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock @@ -74,9 +73,9 @@ internal fun ContentUriDefinition.getSelectionAndSelectionArgs(): CodeBlock { if (segments.isEmpty()) { return CodeBlock.builder().add("selection, selectionArgs").build() } else { - val selectionBuilder = CodeBlock.builder().add("\$T.concatenateWhere(selection, \"", ClassNames.DATABASE_UTILS) + val selectionBuilder = CodeBlock.builder().add("\$T.concatenateWhere(selection, \"", com.dbflow5.processor.ClassNames.DATABASE_UTILS) val selectionArgsBuilder = CodeBlock.builder().add("\$T.appendSelectionArgs(selectionArgs, new \$T[] {", - ClassNames.DATABASE_UTILS, String::class.java) + com.dbflow5.processor.ClassNames.DATABASE_UTILS, String::class.java) var isFirst = true for (segment in segments) { if (!isFirst) { @@ -113,7 +112,7 @@ class DeleteMethod(private val contentProviderDefinition: ContentProviderDefinit case(uriDefinition.name.L) { add(uriDefinition.getSegmentsPreparation()) add("long count = \$T.getDatabase(\$T.class).delete(\$S, ", - ClassNames.FLOW_MANAGER, contentProviderDefinition.databaseTypeName, + com.dbflow5.processor.ClassNames.FLOW_MANAGER, contentProviderDefinition.databaseTypeName, it.tableName) add(uriDefinition.getSelectionAndSelectionArgs()) add(");\n") @@ -133,7 +132,7 @@ class DeleteMethod(private val contentProviderDefinition: ContentProviderDefinit return MethodSpec.methodBuilder("delete") .addAnnotation(Override::class.java) .addModifiers(Modifier.PUBLIC, Modifier.FINAL) - .addParameter(ClassNames.URI, PARAM_URI) + .addParameter(com.dbflow5.processor.ClassNames.URI, PARAM_URI) .addParameter(ClassName.get(String::class.java), PARAM_SELECTION) .addParameter(ArrayTypeName.of(String::class.java), PARAM_SELECTION_ARGS) .addCode(code.build()).returns(TypeName.INT).build() @@ -165,19 +164,19 @@ class InsertMethod(private val contentProviderDefinition: ContentProviderDefinit code.apply { beginControlFlow("case \$L:", uriDefinition.name) addStatement("\$T adapter = \$T.getModelAdapter(\$T.getTableClassForName(\$T.class, \$S))", - ClassNames.MODEL_ADAPTER, ClassNames.FLOW_MANAGER, ClassNames.FLOW_MANAGER, + com.dbflow5.processor.ClassNames.MODEL_ADAPTER, com.dbflow5.processor.ClassNames.FLOW_MANAGER, com.dbflow5.processor.ClassNames.FLOW_MANAGER, contentProviderDefinition.databaseTypeName, it.tableName) add("final long id = FlowManager.getDatabase(\$T.class)", contentProviderDefinition.databaseTypeName).add( ".insertWithOnConflict(\$S, null, values, " + "\$T.getSQLiteDatabaseAlgorithmInt(adapter.getInsertOnConflictAction()));\n", it.tableName, - ClassNames.CONFLICT_ACTION) + com.dbflow5.processor.ClassNames.CONFLICT_ACTION) NotifyMethod(it, uriDefinition, NotifyMethod.INSERT).addCode(this) if (!isBulk) { - addStatement("return \$T.withAppendedId(\$L, id)", ClassNames.CONTENT_URIS, Constants.PARAM_URI) + addStatement("return \$T.withAppendedId(\$L, id)", com.dbflow5.processor.ClassNames.CONTENT_URIS, Constants.PARAM_URI) } else { addStatement("return id > 0 ? 1 : 0") } @@ -190,10 +189,10 @@ class InsertMethod(private val contentProviderDefinition: ContentProviderDefinit appendDefault(code) code.endControlFlow() return MethodSpec.methodBuilder(if (isBulk) "bulkInsert" else "insert") - .addAnnotation(Override::class.java).addParameter(ClassNames.URI, Constants.PARAM_URI) - .addParameter(ClassNames.CONTENT_VALUES, Constants.PARAM_CONTENT_VALUES) + .addAnnotation(Override::class.java).addParameter(com.dbflow5.processor.ClassNames.URI, Constants.PARAM_URI) + .addParameter(com.dbflow5.processor.ClassNames.CONTENT_VALUES, Constants.PARAM_CONTENT_VALUES) .addModifiers(if (isBulk) Modifier.PROTECTED else Modifier.PUBLIC, Modifier.FINAL) - .addCode(code.build()).returns(if (isBulk) TypeName.INT else ClassNames.URI).build() + .addCode(code.build()).returns(if (isBulk) TypeName.INT else com.dbflow5.processor.ClassNames.URI).build() } } @@ -213,12 +212,12 @@ class NotifyMethod(private val tableEndpointDefinition: TableEndpointDefinition, for (i in notifyDefinitionList.indices) { val notifyDefinition = notifyDefinitionList[i] if (notifyDefinition.returnsArray) { - code.addStatement("\$T[] notifyUris\$L = \$L.\$L(\$L)", ClassNames.URI, + code.addStatement("\$T[] notifyUris\$L = \$L.\$L(\$L)", com.dbflow5.processor.ClassNames.URI, notifyDefinition.methodName, notifyDefinition.parent, notifyDefinition.methodName, notifyDefinition.params) - code.beginControlFlow("for (\$T notifyUri: notifyUris\$L)", ClassNames.URI, notifyDefinition.methodName) + code.beginControlFlow("for (\$T notifyUri: notifyUris\$L)", com.dbflow5.processor.ClassNames.URI, notifyDefinition.methodName) } else { - code.addStatement("\$T notifyUri\$L = \$L.\$L(\$L)", ClassNames.URI, + code.addStatement("\$T notifyUri\$L = \$L.\$L(\$L)", com.dbflow5.processor.ClassNames.URI, notifyDefinition.methodName, notifyDefinition.parent, notifyDefinition.methodName, notifyDefinition.params) } @@ -261,14 +260,14 @@ class QueryMethod(private val contentProviderDefinition: ContentProviderDefiniti val method = MethodSpec.methodBuilder("query") .addAnnotation(Override::class.java) .addModifiers(Modifier.PUBLIC, Modifier.FINAL) - .addParameter(ClassNames.URI, "uri") + .addParameter(com.dbflow5.processor.ClassNames.URI, "uri") .addParameter(ArrayTypeName.of(String::class.java), "projection") .addParameter(ClassName.get(String::class.java), "selection") .addParameter(ArrayTypeName.of(String::class.java), "selectionArgs") .addParameter(ClassName.get(String::class.java), "sortOrder") - .returns(ClassNames.CURSOR) + .returns(com.dbflow5.processor.ClassNames.CURSOR) - method.addStatement("\$L cursor = null", ClassNames.CURSOR) + method.addStatement("\$L cursor = null", com.dbflow5.processor.ClassNames.CURSOR) method.beginControlFlow("switch(\$L.match(uri))", ContentProviderDefinition.URI_MATCHER) for (tableEndpointDefinition in contentProviderDefinition.endpointDefinitions) { tableEndpointDefinition.contentUriDefinitions @@ -279,7 +278,7 @@ class QueryMethod(private val contentProviderDefinition: ContentProviderDefiniti beginControlFlow("case \$L:", it.name) addCode(it.getSegmentsPreparation()) addCode("cursor = \$T.getDatabase(\$T.class).query(\$S, projection, ", - ClassNames.FLOW_MANAGER, contentProviderDefinition.databaseTypeName, + com.dbflow5.processor.ClassNames.FLOW_MANAGER, contentProviderDefinition.databaseTypeName, tableEndpointDefinition.tableName) addCode(it.getSelectionAndSelectionArgs()) addCode(", null, null, sortOrder);\n") @@ -310,8 +309,8 @@ class UpdateMethod(private val contentProviderDefinition: ContentProviderDefinit val method = MethodSpec.methodBuilder("update") .addAnnotation(Override::class.java) .addModifiers(Modifier.PUBLIC) - .addParameter(ClassNames.URI, Constants.PARAM_URI) - .addParameter(ClassNames.CONTENT_VALUES, Constants.PARAM_CONTENT_VALUES) + .addParameter(com.dbflow5.processor.ClassNames.URI, Constants.PARAM_URI) + .addParameter(com.dbflow5.processor.ClassNames.CONTENT_VALUES, Constants.PARAM_CONTENT_VALUES) .addParameter(ClassName.get(String::class.java), "selection") .addParameter(ArrayTypeName.of(String::class.java), "selectionArgs") .returns(TypeName.INT) @@ -325,19 +324,19 @@ class UpdateMethod(private val contentProviderDefinition: ContentProviderDefinit method.apply { beginControlFlow("case \$L:", it.name) addStatement("\$T adapter = \$T.getModelAdapter(\$T.getTableClassForName(\$T.class, \$S))", - ClassNames.MODEL_ADAPTER, ClassNames.FLOW_MANAGER, ClassNames.FLOW_MANAGER, + com.dbflow5.processor.ClassNames.MODEL_ADAPTER, com.dbflow5.processor.ClassNames.FLOW_MANAGER, com.dbflow5.processor.ClassNames.FLOW_MANAGER, contentProviderDefinition.databaseTypeName, tableEndpointDefinition.tableName) addCode(it.getSegmentsPreparation()) addCode( "long count = \$T.getDatabase(\$T.class).updateWithOnConflict(\$S, \$L, ", - ClassNames.FLOW_MANAGER, contentProviderDefinition.databaseTypeName, + com.dbflow5.processor.ClassNames.FLOW_MANAGER, contentProviderDefinition.databaseTypeName, tableEndpointDefinition.tableName, Constants.PARAM_CONTENT_VALUES) addCode(it.getSelectionAndSelectionArgs()) addCode( ", \$T.getSQLiteDatabaseAlgorithmInt(adapter.getUpdateOnConflictAction()));\n", - ClassNames.CONFLICT_ACTION) + com.dbflow5.processor.ClassNames.CONFLICT_ACTION) val code = CodeBlock.builder() NotifyMethod(tableEndpointDefinition, it, @@ -405,7 +404,7 @@ class ContentProviderDefinition(typeElement: Element, processorManager: Processo } override val extendsClass: TypeName? - get() = ClassNames.BASE_CONTENT_PROVIDER + get() = com.dbflow5.processor.ClassNames.BASE_CONTENT_PROVIDER fun prepareForWrite() { val databaseDefinition = manager.getDatabaseHolderDefinition(databaseTypeName)!!.databaseDefinition @@ -423,7 +422,7 @@ class ContentProviderDefinition(typeElement: Element, processorManager: Processo } } - `private final field`(ClassNames.URI_MATCHER, URI_MATCHER) { `=`("new \$T(\$T.NO_MATCH)", ClassNames.URI_MATCHER, ClassNames.URI_MATCHER) } + `private final field`(com.dbflow5.processor.ClassNames.URI_MATCHER, URI_MATCHER) { `=`("new \$T(\$T.NO_MATCH)", com.dbflow5.processor.ClassNames.URI_MATCHER, com.dbflow5.processor.ClassNames.URI_MATCHER) } `override fun`(TypeName.BOOLEAN, "onCreate") { modifiers(public, final) @@ -450,10 +449,10 @@ class ContentProviderDefinition(typeElement: Element, processorManager: Processo `override fun`(String::class, "getDatabaseName") { modifiers(public, final) - `return`("\$T.getDatabaseName(\$T.class)", ClassNames.FLOW_MANAGER, databaseTypeName) + `return`("\$T.getDatabaseName(\$T.class)", com.dbflow5.processor.ClassNames.FLOW_MANAGER, databaseTypeName) } - `override fun`(String::class, "getType", param(ClassNames.URI, "uri")) { + `override fun`(String::class, "getType", param(com.dbflow5.processor.ClassNames.URI, "uri")) { modifiers(public, final) code { statement("\$T type = null", ClassName.get(String::class.java)) @@ -519,11 +518,11 @@ class ContentUriDefinition(typeElement: Element, processorManager: ProcessorMana } if (typeElement is VariableElement) { - if (ClassNames.URI != elementTypeName) { + if (com.dbflow5.processor.ClassNames.URI != elementTypeName) { processorManager.logError("Content Uri field returned wrong type. It must return a Uri") } } else if (typeElement is ExecutableElement) { - if (ClassNames.URI != elementTypeName) { + if (com.dbflow5.processor.ClassNames.URI != elementTypeName) { processorManager.logError("ContentUri method returns wrong type. It must return Uri") } } diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/provider/NotifyDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/provider/NotifyDefinition.kt similarity index 78% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/provider/NotifyDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/provider/NotifyDefinition.kt index 9204f9bc6..475cf5654 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/provider/NotifyDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/provider/NotifyDefinition.kt @@ -1,11 +1,10 @@ -package com.raizlabs.dbflow5.processor.definition.provider +package com.dbflow5.processor.definition.provider -import com.raizlabs.dbflow5.annotation.provider.Notify -import com.raizlabs.dbflow5.annotation.provider.NotifyMethod -import com.raizlabs.dbflow5.processor.ClassNames -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.BaseDefinition -import com.raizlabs.dbflow5.processor.utils.annotation +import com.dbflow5.annotation.provider.Notify +import com.dbflow5.annotation.provider.NotifyMethod +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.BaseDefinition +import com.dbflow5.processor.utils.annotation import com.squareup.javapoet.ClassName import javax.lang.model.element.Element import javax.lang.model.element.ExecutableElement @@ -61,8 +60,8 @@ class NotifyDefinition(typeElement: Element, processorManager: ProcessorManager) val typeMirror = executableElement.returnType when { - "${ClassNames.URI}[]" == typeMirror.toString() -> returnsArray = true - ClassNames.URI.toString() == typeMirror.toString() -> returnsSingle = true + "${com.dbflow5.processor.ClassNames.URI}[]" == typeMirror.toString() -> returnsArray = true + com.dbflow5.processor.ClassNames.URI.toString() == typeMirror.toString() -> returnsSingle = true else -> processorManager.logError("Notify method returns wrong type. It must return Uri or Uri[]") } } diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/provider/TableEndpointDefinition.kt b/processor/src/main/kotlin/com/dbflow5/processor/definition/provider/TableEndpointDefinition.kt similarity index 80% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/provider/TableEndpointDefinition.kt rename to processor/src/main/kotlin/com/dbflow5/processor/definition/provider/TableEndpointDefinition.kt index 6e379080d..6a46553df 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/definition/provider/TableEndpointDefinition.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/definition/provider/TableEndpointDefinition.kt @@ -1,13 +1,13 @@ -package com.raizlabs.dbflow5.processor.definition.provider +package com.dbflow5.processor.definition.provider -import com.raizlabs.dbflow5.annotation.provider.ContentUri -import com.raizlabs.dbflow5.annotation.provider.Notify -import com.raizlabs.dbflow5.annotation.provider.NotifyMethod -import com.raizlabs.dbflow5.annotation.provider.TableEndpoint -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.BaseDefinition -import com.raizlabs.dbflow5.processor.utils.annotation -import com.raizlabs.dbflow5.processor.utils.extractTypeNameFromAnnotation +import com.dbflow5.annotation.provider.ContentUri +import com.dbflow5.annotation.provider.Notify +import com.dbflow5.annotation.provider.NotifyMethod +import com.dbflow5.annotation.provider.TableEndpoint +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.BaseDefinition +import com.dbflow5.processor.utils.annotation +import com.dbflow5.processor.utils.extractTypeNameFromAnnotation import com.squareup.javapoet.TypeName import javax.lang.model.element.Element import javax.lang.model.element.PackageElement diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/CodeExtensions.kt b/processor/src/main/kotlin/com/dbflow5/processor/utils/CodeExtensions.kt similarity index 97% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/CodeExtensions.kt rename to processor/src/main/kotlin/com/dbflow5/processor/utils/CodeExtensions.kt index 75d66597b..321661273 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/CodeExtensions.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/utils/CodeExtensions.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.utils +package com.dbflow5.processor.utils import com.grosner.kpoet.end import com.grosner.kpoet.nextControl diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/DependencyUtils.kt b/processor/src/main/kotlin/com/dbflow5/processor/utils/DependencyUtils.kt similarity index 68% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/DependencyUtils.kt rename to processor/src/main/kotlin/com/dbflow5/processor/utils/DependencyUtils.kt index 6c11cda17..e7d382627 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/DependencyUtils.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/utils/DependencyUtils.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.processor.utils +package com.dbflow5.processor.utils -import com.raizlabs.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.ProcessorManager /** * Used to check if class exists on class path, if so, we add the annotation to generated class files. diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ElementExtensions.kt b/processor/src/main/kotlin/com/dbflow5/processor/utils/ElementExtensions.kt similarity index 92% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ElementExtensions.kt rename to processor/src/main/kotlin/com/dbflow5/processor/utils/ElementExtensions.kt index 27c1d0373..13805844c 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ElementExtensions.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/utils/ElementExtensions.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.processor.utils +package com.dbflow5.processor.utils -import com.raizlabs.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.ProcessorManager import com.squareup.javapoet.ClassName import com.squareup.javapoet.TypeName import javax.lang.model.element.Element diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ElementUtility.kt b/processor/src/main/kotlin/com/dbflow5/processor/utils/ElementUtility.kt similarity index 94% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ElementUtility.kt rename to processor/src/main/kotlin/com/dbflow5/processor/utils/ElementUtility.kt index 4b506d724..8ceccc76c 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ElementUtility.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/utils/ElementUtility.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.processor.utils +package com.dbflow5.processor.utils -import com.raizlabs.dbflow5.annotation.ColumnIgnore -import com.raizlabs.dbflow5.processor.ProcessorManager +import com.dbflow5.annotation.ColumnIgnore +import com.dbflow5.processor.ProcessorManager import com.squareup.javapoet.ClassName import javax.lang.model.element.Element import javax.lang.model.element.Modifier diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/JavaPoetExtensions.kt b/processor/src/main/kotlin/com/dbflow5/processor/utils/JavaPoetExtensions.kt similarity index 97% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/JavaPoetExtensions.kt rename to processor/src/main/kotlin/com/dbflow5/processor/utils/JavaPoetExtensions.kt index bcb0443a8..142a51099 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/JavaPoetExtensions.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/utils/JavaPoetExtensions.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.utils +package com.dbflow5.processor.utils import com.grosner.kpoet.returns import com.squareup.javapoet.MethodSpec diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ModelUtils.kt b/processor/src/main/kotlin/com/dbflow5/processor/utils/ModelUtils.kt similarity index 64% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ModelUtils.kt rename to processor/src/main/kotlin/com/dbflow5/processor/utils/ModelUtils.kt index 67f307c37..66bc8935f 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ModelUtils.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/utils/ModelUtils.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.utils +package com.dbflow5.processor.utils object ModelUtils { diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ProcessorUtils.kt b/processor/src/main/kotlin/com/dbflow5/processor/utils/ProcessorUtils.kt similarity index 96% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ProcessorUtils.kt rename to processor/src/main/kotlin/com/dbflow5/processor/utils/ProcessorUtils.kt index 8499a6bc1..47bc06bb3 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/ProcessorUtils.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/utils/ProcessorUtils.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.processor.utils +package com.dbflow5.processor.utils -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.ProcessorManager.Companion.manager +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.ProcessorManager.Companion.manager import com.squareup.javapoet.ClassName import com.squareup.javapoet.TypeName import javax.annotation.processing.ProcessingEnvironment diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/StringUtils.kt b/processor/src/main/kotlin/com/dbflow5/processor/utils/StringUtils.kt similarity index 91% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/StringUtils.kt rename to processor/src/main/kotlin/com/dbflow5/processor/utils/StringUtils.kt index 0ff397016..ad76e6d47 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/StringUtils.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/utils/StringUtils.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5.processor.utils +package com.dbflow5.processor.utils /** * Description: diff --git a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/WriterUtils.kt b/processor/src/main/kotlin/com/dbflow5/processor/utils/WriterUtils.kt similarity index 83% rename from processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/WriterUtils.kt rename to processor/src/main/kotlin/com/dbflow5/processor/utils/WriterUtils.kt index fed113426..4c6dc1c83 100644 --- a/processor/src/main/kotlin/com/raizlabs/dbflow5/processor/utils/WriterUtils.kt +++ b/processor/src/main/kotlin/com/dbflow5/processor/utils/WriterUtils.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.processor.utils +package com.dbflow5.processor.utils import com.grosner.kpoet.javaFile -import com.raizlabs.dbflow5.processor.ProcessorManager -import com.raizlabs.dbflow5.processor.definition.BaseDefinition +import com.dbflow5.processor.ProcessorManager +import com.dbflow5.processor.definition.BaseDefinition import java.io.IOException /** diff --git a/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor index d6c2ce391..ba9eb39db 100644 --- a/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor +++ b/processor/src/main/resources/META-INF/services/javax.annotation.processing.Processor @@ -1 +1 @@ -com.raizlabs.dbflow5.processor.DBFlowProcessor \ No newline at end of file +com.dbflow5.processor.DBFlowProcessor \ No newline at end of file diff --git a/processor/src/test/java/com/raizlabs/dbflow5/processor/test/ColumnAccessCombinerTests.kt b/processor/src/test/java/com/raizlabs/dbflow5/processor/test/ColumnAccessCombinerTests.kt index 40390c6a4..98dfc03db 100644 --- a/processor/src/test/java/com/raizlabs/dbflow5/processor/test/ColumnAccessCombinerTests.kt +++ b/processor/src/test/java/com/raizlabs/dbflow5/processor/test/ColumnAccessCombinerTests.kt @@ -1,15 +1,15 @@ -package com.raizlabs.android.dbflow.processor.test - -import com.raizlabs.dbflow5.processor.definition.column.BooleanColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.Combiner -import com.raizlabs.dbflow5.processor.definition.column.ContentValuesCombiner -import com.raizlabs.dbflow5.processor.definition.column.LoadFromCursorAccessCombiner -import com.raizlabs.dbflow5.processor.definition.column.PackagePrivateScopeColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.PrimaryReferenceAccessCombiner -import com.raizlabs.dbflow5.processor.definition.column.PrivateScopeColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.SqliteStatementAccessCombiner -import com.raizlabs.dbflow5.processor.definition.column.TypeConverterScopeColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.VisibleScopeColumnAccessor +package com.dbflow5.processor.test + +import com.dbflow5.processor.definition.column.BooleanColumnAccessor +import com.dbflow5.processor.definition.column.Combiner +import com.dbflow5.processor.definition.column.ContentValuesCombiner +import com.dbflow5.processor.definition.column.LoadFromCursorAccessCombiner +import com.dbflow5.processor.definition.column.PackagePrivateScopeColumnAccessor +import com.dbflow5.processor.definition.column.PrimaryReferenceAccessCombiner +import com.dbflow5.processor.definition.column.PrivateScopeColumnAccessor +import com.dbflow5.processor.definition.column.SqliteStatementAccessCombiner +import com.dbflow5.processor.definition.column.TypeConverterScopeColumnAccessor +import com.dbflow5.processor.definition.column.VisibleScopeColumnAccessor import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.NameAllocator import com.squareup.javapoet.TypeName diff --git a/processor/src/test/java/com/raizlabs/dbflow5/processor/test/ForeignKeyAccessCombinerTests.kt b/processor/src/test/java/com/raizlabs/dbflow5/processor/test/ForeignKeyAccessCombinerTests.kt index a047218dc..fdf1f6537 100644 --- a/processor/src/test/java/com/raizlabs/dbflow5/processor/test/ForeignKeyAccessCombinerTests.kt +++ b/processor/src/test/java/com/raizlabs/dbflow5/processor/test/ForeignKeyAccessCombinerTests.kt @@ -1,17 +1,17 @@ -package com.raizlabs.android.dbflow.processor.test - -import com.raizlabs.dbflow5.processor.definition.column.Combiner -import com.raizlabs.dbflow5.processor.definition.column.ContentValuesCombiner -import com.raizlabs.dbflow5.processor.definition.column.ForeignKeyAccessCombiner -import com.raizlabs.dbflow5.processor.definition.column.ForeignKeyAccessField -import com.raizlabs.dbflow5.processor.definition.column.ForeignKeyLoadFromCursorCombiner -import com.raizlabs.dbflow5.processor.definition.column.PackagePrivateScopeColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.PartialLoadFromCursorAccessCombiner -import com.raizlabs.dbflow5.processor.definition.column.PrimaryReferenceAccessCombiner -import com.raizlabs.dbflow5.processor.definition.column.PrivateScopeColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.SqliteStatementAccessCombiner -import com.raizlabs.dbflow5.processor.definition.column.TypeConverterScopeColumnAccessor -import com.raizlabs.dbflow5.processor.definition.column.VisibleScopeColumnAccessor +package com.dbflow5.processor.test + +import com.dbflow5.processor.definition.column.Combiner +import com.dbflow5.processor.definition.column.ContentValuesCombiner +import com.dbflow5.processor.definition.column.ForeignKeyAccessCombiner +import com.dbflow5.processor.definition.column.ForeignKeyAccessField +import com.dbflow5.processor.definition.column.ForeignKeyLoadFromCursorCombiner +import com.dbflow5.processor.definition.column.PackagePrivateScopeColumnAccessor +import com.dbflow5.processor.definition.column.PartialLoadFromCursorAccessCombiner +import com.dbflow5.processor.definition.column.PrimaryReferenceAccessCombiner +import com.dbflow5.processor.definition.column.PrivateScopeColumnAccessor +import com.dbflow5.processor.definition.column.SqliteStatementAccessCombiner +import com.dbflow5.processor.definition.column.TypeConverterScopeColumnAccessor +import com.dbflow5.processor.definition.column.VisibleScopeColumnAccessor import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.NameAllocator @@ -83,7 +83,7 @@ class ForeignKeyAccessCombinerTest { assertEquals("if (com.fuzz.android.TestHelper_Helper.getName(model) != null) {" + "\n clause.and(test.eq(com.fuzz.android.TestHelper2_Helper.getTest(com.fuzz.android.TestHelper_Helper.getName(model))));" + "\n} else {" + - "\n clause.and(test.eq((com.raizlabs.android.dbflow.sql.language.IConditional) null));" + + "\n clause.and(test.eq((com.dbflow5.sql.language.IConditional) null));" + "\n}", builder.build().toString().trim()) } @@ -115,8 +115,8 @@ class ForeignKeyAccessCombinerTest { @Test fun test_canLoadFromCursor() { val foreignKeyAccessCombiner = ForeignKeyLoadFromCursorCombiner(VisibleScopeColumnAccessor("testModel1"), - ClassName.get("com.raizlabs.android.dbflow.test.container", "ParentModel"), - ClassName.get("com.raizlabs.android.dbflow.test.container", "ParentModel_Table"), false, + ClassName.get("com.dbflow5.test.container", "ParentModel"), + ClassName.get("com.dbflow5.test.container", "ParentModel_Table"), false, NameAllocator()) foreignKeyAccessCombiner.fieldAccesses += PartialLoadFromCursorAccessCombiner("testmodel_id", "name", TypeName.get(String::class.java), false, null) @@ -129,9 +129,9 @@ class ForeignKeyAccessCombinerTest { assertEquals("int index_testmodel_id_ParentModel_Table = cursor.getColumnIndex(\"testmodel_id\");" + "\nint index_testmodel_type_ParentModel_Table = cursor.getColumnIndex(\"testmodel_type\");" + "\nif (index_testmodel_id_ParentModel_Table != -1 && !cursor.isNull(index_testmodel_id_ParentModel_Table) && index_testmodel_type_ParentModel_Table != -1 && !cursor.isNull(index_testmodel_type_ParentModel_Table)) {" + - "\n model.testModel1 = com.raizlabs.android.dbflow.sql.language.SQLite.select().from(com.raizlabs.android.dbflow.test.container.ParentModel.class).where()" + - "\n .and(com.raizlabs.android.dbflow.test.container.ParentModel_Table.name.eq(cursor.getString(index_testmodel_id_ParentModel_Table)))" + - "\n .and(com.raizlabs.android.dbflow.test.container.ParentModel_Table.type.eq(cursor.getString(index_testmodel_type_ParentModel_Table)))" + + "\n model.testModel1 = com.dbflow5.sql.language.SQLite.select().from(com.dbflow5.test.container.ParentModel.class).where()" + + "\n .and(com.dbflow5.test.container.ParentModel_Table.name.eq(cursor.getString(index_testmodel_id_ParentModel_Table)))" + + "\n .and(com.dbflow5.test.container.ParentModel_Table.type.eq(cursor.getString(index_testmodel_type_ParentModel_Table)))" + "\n .querySingle();" + "\n} else {" + "\n model.testModel1 = null;" + @@ -141,8 +141,8 @@ class ForeignKeyAccessCombinerTest { @Test fun test_canLoadFromCursorStubbed() { val foreignKeyAccessCombiner = ForeignKeyLoadFromCursorCombiner(VisibleScopeColumnAccessor("testModel1"), - ClassName.get("com.raizlabs.android.dbflow.test.container", "ParentModel"), - ClassName.get("com.raizlabs.android.dbflow.test.container", "ParentModel_Table"), true, + ClassName.get("com.dbflow5.test.container", "ParentModel"), + ClassName.get("com.dbflow5.test.container", "ParentModel_Table"), true, NameAllocator()) foreignKeyAccessCombiner.fieldAccesses += PartialLoadFromCursorAccessCombiner("testmodel_id", "name", TypeName.get(String::class.java), false, VisibleScopeColumnAccessor("name")) @@ -155,7 +155,7 @@ class ForeignKeyAccessCombinerTest { assertEquals("int index_testmodel_id_ParentModel_Table = cursor.getColumnIndex(\"testmodel_id\");" + "\nint index_testmodel_type_ParentModel_Table = cursor.getColumnIndex(\"testmodel_type\");" + "\nif (index_testmodel_id_ParentModel_Table != -1 && !cursor.isNull(index_testmodel_id_ParentModel_Table) && index_testmodel_type_ParentModel_Table != -1 && !cursor.isNull(index_testmodel_type_ParentModel_Table)) {" + - "\n model.testModel1 = new com.raizlabs.android.dbflow.test.container.ParentModel();" + + "\n model.testModel1 = new com.dbflow5.test.container.ParentModel();" + "\n model.testModel1.name = cursor.getString(index_testmodel_id_ParentModel_Table);" + "\n model.testModel1.type = cursor.getString(index_testmodel_type_ParentModel_Table);" + "\n} else {" + diff --git a/processor/src/test/java/com/raizlabs/dbflow5/processor/test/SimpleColumnAccessorTests.kt b/processor/src/test/java/com/raizlabs/dbflow5/processor/test/SimpleColumnAccessorTests.kt index 1b0ea3bf7..136dca4f7 100644 --- a/processor/src/test/java/com/raizlabs/dbflow5/processor/test/SimpleColumnAccessorTests.kt +++ b/processor/src/test/java/com/raizlabs/dbflow5/processor/test/SimpleColumnAccessorTests.kt @@ -1,6 +1,6 @@ -package com.raizlabs.dbflow5.processor.test +package com.dbflow5.processor.test -import com.raizlabs.dbflow5.processor.definition.column.* +import com.dbflow5.processor.definition.column.* import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.TypeName import org.junit.Assert.assertEquals @@ -118,7 +118,7 @@ class EnumColumnAccessorTest { @Test fun test_canSetEnum() { val access = EnumColumnAccessor(TypeName.get(TestEnum::class.java)) - assertEquals("com.raizlabs.dbflow5.processor.test.EnumColumnAccessorTest.TestEnum.valueOf(model.test)", + assertEquals("com.dbflow5.processor.test.EnumColumnAccessorTest.TestEnum.valueOf(model.test)", access.set(CodeBlock.of("model.test")).toString()) } } @@ -134,7 +134,7 @@ class BlobColumnAccessorTest() { @Test fun test_canSetBlob() { val access = BlobColumnAccessor() - assertEquals("new com.raizlabs.dbflow5.Blob(cursor.getBlob(index))", + assertEquals("new com.dbflow5.Blob(cursor.getBlob(index))", access.set(CodeBlock.of("cursor.getBlob(index)")).toString()) } } diff --git a/reactive-streams/build.gradle b/reactive-streams/build.gradle index 0378140b6..31174b324 100644 --- a/reactive-streams/build.gradle +++ b/reactive-streams/build.gradle @@ -22,7 +22,7 @@ android { } dependencies { - api project("${dbflow_project_prefix}dbflow") + api project(':lib') api deps.rx2 api deps.kotlin } diff --git a/reactive-streams/src/main/AndroidManifest.xml b/reactive-streams/src/main/AndroidManifest.xml index 2380e798a..6c0b2d71b 100644 --- a/reactive-streams/src/main/AndroidManifest.xml +++ b/reactive-streams/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/CursorListFlowable.kt b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/CursorListFlowable.kt index 88b84c2e8..a915a25d1 100644 --- a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/CursorListFlowable.kt +++ b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/CursorListFlowable.kt @@ -1,11 +1,11 @@ -package com.raizlabs.dbflow5.reactivestreams.query +package com.dbflow5.reactivestreams.query -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.query.ModelQueriable -import com.raizlabs.dbflow5.query.list.FlowCursorList -import com.raizlabs.dbflow5.reactivestreams.transaction.asSingle -import com.raizlabs.dbflow5.transaction.Transaction +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.FlowLog +import com.dbflow5.query.ModelQueriable +import com.dbflow5.query.list.FlowCursorList +import com.dbflow5.reactivestreams.transaction.asSingle +import com.dbflow5.transaction.Transaction import io.reactivex.Flowable import io.reactivex.SingleObserver import io.reactivex.disposables.Disposable diff --git a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/ModelQueriableExtensions.kt b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/ModelQueriableExtensions.kt index 5671bbe20..935a5be29 100644 --- a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/ModelQueriableExtensions.kt +++ b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/ModelQueriableExtensions.kt @@ -1,10 +1,10 @@ @file:JvmName("RXModelQueriable") -package com.raizlabs.dbflow5.reactivestreams.query +package com.dbflow5.reactivestreams.query -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.query.ModelQueriable -import com.raizlabs.dbflow5.transaction.ITransactionQueue +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.query.ModelQueriable +import com.dbflow5.transaction.ITransactionQueue import io.reactivex.Flowable /** diff --git a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/TableChangeOnSubscribe.kt b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/TableChangeOnSubscribe.kt index e06130af5..271dac7b3 100644 --- a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/TableChangeOnSubscribe.kt +++ b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/query/TableChangeOnSubscribe.kt @@ -1,15 +1,15 @@ -package com.raizlabs.dbflow5.reactivestreams.query +package com.dbflow5.reactivestreams.query -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.Join -import com.raizlabs.dbflow5.query.ModelQueriable -import com.raizlabs.dbflow5.query.extractFrom -import com.raizlabs.dbflow5.runtime.OnTableChangedListener -import com.raizlabs.dbflow5.runtime.TableNotifierRegister -import com.raizlabs.dbflow5.reactivestreams.transaction.asMaybe -import com.raizlabs.dbflow5.structure.ChangeAction +import com.dbflow5.config.FlowManager +import com.dbflow5.config.databaseForTable +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.Join +import com.dbflow5.query.ModelQueriable +import com.dbflow5.query.extractFrom +import com.dbflow5.runtime.OnTableChangedListener +import com.dbflow5.runtime.TableNotifierRegister +import com.dbflow5.reactivestreams.transaction.asMaybe +import com.dbflow5.structure.ChangeAction import io.reactivex.FlowableEmitter import io.reactivex.FlowableOnSubscribe import io.reactivex.disposables.Disposables diff --git a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/BaseRXModel.kt b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/BaseRXModel.kt index 37a3ce1b6..9886f9b10 100644 --- a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/BaseRXModel.kt +++ b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/BaseRXModel.kt @@ -1,11 +1,11 @@ -package com.raizlabs.dbflow5.reactivestreams.structure - -import com.raizlabs.dbflow5.annotation.ColumnIgnore -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.structure.BaseModel -import com.raizlabs.dbflow5.structure.InvalidDBConfiguration -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper +package com.dbflow5.reactivestreams.structure + +import com.dbflow5.annotation.ColumnIgnore +import com.dbflow5.config.FlowManager +import com.dbflow5.structure.BaseModel +import com.dbflow5.structure.InvalidDBConfiguration +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.database.DatabaseWrapper import io.reactivex.Completable import io.reactivex.Single diff --git a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/RXModelAdapter.kt b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/RXModelAdapter.kt index 09e9c829d..62e1ddb7c 100644 --- a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/RXModelAdapter.kt +++ b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/RXModelAdapter.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.reactivestreams.structure +package com.dbflow5.reactivestreams.structure -import com.raizlabs.dbflow5.adapter.ModelAdapter -import com.raizlabs.dbflow5.config.modelAdapter -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.adapter.ModelAdapter +import com.dbflow5.config.modelAdapter +import com.dbflow5.database.DatabaseWrapper import io.reactivex.Completable import io.reactivex.Completable.fromCallable import io.reactivex.Single diff --git a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/RXRetrievalAdapter.kt b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/RXRetrievalAdapter.kt index 75d33e88b..868533393 100644 --- a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/RXRetrievalAdapter.kt +++ b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/structure/RXRetrievalAdapter.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5.reactivestreams.structure +package com.dbflow5.reactivestreams.structure -import com.raizlabs.dbflow5.adapter.RetrievalAdapter -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.DatabaseWrapper +import com.dbflow5.adapter.RetrievalAdapter +import com.dbflow5.config.FlowManager +import com.dbflow5.database.DatabaseWrapper import io.reactivex.Completable import io.reactivex.Single diff --git a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/transaction/TransactionObservable.kt b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/transaction/TransactionObservable.kt index c121686b4..70fee229b 100644 --- a/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/transaction/TransactionObservable.kt +++ b/reactive-streams/src/main/kotlin/com/raizlabs/dbflow5/reactivestreams/transaction/TransactionObservable.kt @@ -1,12 +1,12 @@ @file:JvmName("RXTransactions") -package com.raizlabs.dbflow5.reactivestreams.transaction +package com.dbflow5.reactivestreams.transaction -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.query.ModelQueriable -import com.raizlabs.dbflow5.reactivestreams.query.TableChangeOnSubscribe -import com.raizlabs.dbflow5.transaction.ITransactionQueue -import com.raizlabs.dbflow5.transaction.Transaction +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.query.ModelQueriable +import com.dbflow5.reactivestreams.query.TableChangeOnSubscribe +import com.dbflow5.transaction.ITransactionQueue +import com.dbflow5.transaction.Transaction import io.reactivex.BackpressureStrategy import io.reactivex.Flowable import io.reactivex.Maybe diff --git a/settings.gradle b/settings.gradle index 2551abee8..61aedc7fd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -include ':dbflow', ':reactive-streams', ':coroutines', +include ':lib', ':reactive-streams', ':coroutines', ':contentprovider', ':processor', ':core', ':sqlcipher', diff --git a/sqlcipher/build.gradle b/sqlcipher/build.gradle index 4cad5dbab..ae4e5043c 100644 --- a/sqlcipher/build.gradle +++ b/sqlcipher/build.gradle @@ -27,7 +27,7 @@ android { dependencies { api deps.sql_cipher - api project("${dbflow_project_prefix}dbflow") + api project(':lib') api deps.kotlin } diff --git a/sqlcipher/src/main/AndroidManifest.xml b/sqlcipher/src/main/AndroidManifest.xml index 4d1de0cf9..5f91eb09d 100644 --- a/sqlcipher/src/main/AndroidManifest.xml +++ b/sqlcipher/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherDatabase.kt b/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherDatabase.kt index 62a4b0600..ff687be17 100644 --- a/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherDatabase.kt +++ b/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherDatabase.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.sqlcipher +package com.dbflow5.sqlcipher import android.content.ContentValues -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.FlowCursor +import com.dbflow5.database.DatabaseStatement +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.FlowCursor import net.sqlcipher.database.SQLiteDatabase import net.sqlcipher.database.SQLiteException @@ -77,7 +77,7 @@ internal constructor(val database: SQLiteDatabase) : DatabaseWrapper { } } -fun SQLiteException.toDBFlowSQLiteException() = com.raizlabs.dbflow5.database.SQLiteException("A Database Error Occurred", this) +fun SQLiteException.toDBFlowSQLiteException() = com.dbflow5.database.SQLiteException("A Database Error Occurred", this) inline fun rethrowDBFlowException(fn: () -> T) = try { fn() diff --git a/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherOpenHelper.kt b/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherOpenHelper.kt index bc7b524e8..bbbe3adc6 100644 --- a/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherOpenHelper.kt +++ b/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherOpenHelper.kt @@ -1,13 +1,13 @@ -package com.raizlabs.dbflow5.sqlcipher +package com.dbflow5.sqlcipher import android.content.Context -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.DatabaseConfig -import com.raizlabs.dbflow5.database.BaseDatabaseHelper -import com.raizlabs.dbflow5.database.DatabaseCallback -import com.raizlabs.dbflow5.database.DatabaseHelperDelegate -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.database.OpenHelper +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.DatabaseConfig +import com.dbflow5.database.BaseDatabaseHelper +import com.dbflow5.database.DatabaseCallback +import com.dbflow5.database.DatabaseHelperDelegate +import com.dbflow5.database.DatabaseWrapper +import com.dbflow5.database.OpenHelper import net.sqlcipher.database.SQLiteDatabase import net.sqlcipher.database.SQLiteOpenHelper diff --git a/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherStatement.kt b/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherStatement.kt index 85080f094..b2f49bb7f 100644 --- a/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherStatement.kt +++ b/sqlcipher/src/main/kotlin/com/raizlabs/dbflow5/sqlcipher/SQLCipherStatement.kt @@ -1,7 +1,7 @@ -package com.raizlabs.dbflow5.sqlcipher +package com.dbflow5.sqlcipher -import com.raizlabs.dbflow5.database.BaseDatabaseStatement -import com.raizlabs.dbflow5.database.DatabaseStatement +import com.dbflow5.database.BaseDatabaseStatement +import com.dbflow5.database.DatabaseStatement import net.sqlcipher.database.SQLiteStatement diff --git a/tests/build.gradle b/tests/build.gradle index 9eea30da0..ac373c41c 100644 --- a/tests/build.gradle +++ b/tests/build.gradle @@ -45,11 +45,12 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib" kapt project("${dbflow_project_prefix}processor") - implementation project(':dbflow') + implementation project(':lib') implementation 'com.android.support:appcompat-v7:27.1.1' - implementation project("${dbflow_project_prefix}dbflow") + implementation project(':lib') implementation project("${dbflow_project_prefix}sqlcipher") - implementation project(':dbflow-reactive-streams') + implementation project(':reactive-streams') + implementation project(':contentprovider') implementation project("${dbflow_project_prefix}coroutines") implementation project("${dbflow_project_prefix}paging") diff --git a/tests/src/androidTest/AndroidManifest.xml b/tests/src/androidTest/AndroidManifest.xml index 0ad683537..dc312f688 100644 --- a/tests/src/androidTest/AndroidManifest.xml +++ b/tests/src/androidTest/AndroidManifest.xml @@ -1,12 +1,12 @@ + android:name="com.dbflow5.test.DemoActivity"> diff --git a/tests/src/androidTest/java/com/raizlabs/dbflow5/BaseUnitTest.kt b/tests/src/androidTest/java/com/dbflow5/BaseUnitTest.kt similarity index 84% rename from tests/src/androidTest/java/com/raizlabs/dbflow5/BaseUnitTest.kt rename to tests/src/androidTest/java/com/dbflow5/BaseUnitTest.kt index 6da4576f6..e8878a285 100644 --- a/tests/src/androidTest/java/com/raizlabs/dbflow5/BaseUnitTest.kt +++ b/tests/src/androidTest/java/com/dbflow5/BaseUnitTest.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5 +package com.dbflow5 import org.junit.Rule diff --git a/tests/src/androidTest/java/com/raizlabs/dbflow5/DBFlowInstrumentedTestRule.kt b/tests/src/androidTest/java/com/dbflow5/DBFlowInstrumentedTestRule.kt similarity index 79% rename from tests/src/androidTest/java/com/raizlabs/dbflow5/DBFlowInstrumentedTestRule.kt rename to tests/src/androidTest/java/com/dbflow5/DBFlowInstrumentedTestRule.kt index 331171091..a11282528 100644 --- a/tests/src/androidTest/java/com/raizlabs/dbflow5/DBFlowInstrumentedTestRule.kt +++ b/tests/src/androidTest/java/com/dbflow5/DBFlowInstrumentedTestRule.kt @@ -1,13 +1,15 @@ -package com.raizlabs.dbflow5 +package com.dbflow5 -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.config.DatabaseConfig -import com.raizlabs.dbflow5.config.FlowConfig -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.AndroidSQLiteOpenHelper -import com.raizlabs.dbflow5.prepackaged.PrepackagedDB -import com.raizlabs.dbflow5.runtime.ContentResolverNotifier -import com.raizlabs.dbflow5.sqlcipher.CipherDatabase +import com.dbflow5.AppDatabase +import com.dbflow5.DemoApp +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.config.DatabaseConfig +import com.dbflow5.config.FlowConfig +import com.dbflow5.config.FlowManager +import com.dbflow5.database.AndroidSQLiteOpenHelper +import com.dbflow5.prepackaged.PrepackagedDB +import com.dbflow5.runtime.ContentResolverNotifier +import com.dbflow5.sqlcipher.CipherDatabase import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement diff --git a/tests/src/androidTest/java/com/raizlabs/dbflow5/ImmediateTransactionManager.kt b/tests/src/androidTest/java/com/dbflow5/ImmediateTransactionManager.kt similarity index 73% rename from tests/src/androidTest/java/com/raizlabs/dbflow5/ImmediateTransactionManager.kt rename to tests/src/androidTest/java/com/dbflow5/ImmediateTransactionManager.kt index 76833c12d..33cec2c36 100644 --- a/tests/src/androidTest/java/com/raizlabs/dbflow5/ImmediateTransactionManager.kt +++ b/tests/src/androidTest/java/com/dbflow5/ImmediateTransactionManager.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5 +package com.dbflow5 -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.transaction.BaseTransactionManager -import com.raizlabs.dbflow5.transaction.ITransactionQueue -import com.raizlabs.dbflow5.transaction.Transaction +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.transaction.BaseTransactionManager +import com.dbflow5.transaction.ITransactionQueue +import com.dbflow5.transaction.Transaction /** * Description: Executes all transactions on same thread for testing. diff --git a/tests/src/androidTest/java/com/raizlabs/dbflow5/contentobserver/ContentObserverTest.kt b/tests/src/androidTest/java/com/dbflow5/contentobserver/ContentObserverTest.kt similarity index 79% rename from tests/src/androidTest/java/com/raizlabs/dbflow5/contentobserver/ContentObserverTest.kt rename to tests/src/androidTest/java/com/dbflow5/contentobserver/ContentObserverTest.kt index b9553f2bf..4b9813407 100644 --- a/tests/src/androidTest/java/com/raizlabs/dbflow5/contentobserver/ContentObserverTest.kt +++ b/tests/src/androidTest/java/com/dbflow5/contentobserver/ContentObserverTest.kt @@ -1,23 +1,23 @@ -package com.raizlabs.dbflow5.contentobserver +package com.dbflow5.contentobserver import android.net.Uri -import com.raizlabs.dbflow5.BaseInstrumentedUnitTest -import com.raizlabs.dbflow5.DemoApp -import com.raizlabs.dbflow5.TABLE_QUERY_PARAM -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.config.modelAdapter -import com.raizlabs.dbflow5.config.tableName -import com.raizlabs.dbflow5.contentobserver.User_Table.id -import com.raizlabs.dbflow5.contentobserver.User_Table.name -import com.raizlabs.dbflow5.getNotificationUri -import com.raizlabs.dbflow5.query.SQLOperator -import com.raizlabs.dbflow5.query.delete -import com.raizlabs.dbflow5.runtime.FlowContentObserver -import com.raizlabs.dbflow5.structure.ChangeAction -import com.raizlabs.dbflow5.structure.delete -import com.raizlabs.dbflow5.structure.insert -import com.raizlabs.dbflow5.structure.save -import com.raizlabs.dbflow5.structure.update +import com.dbflow5.BaseInstrumentedUnitTest +import com.dbflow5.DemoApp +import com.dbflow5.TABLE_QUERY_PARAM +import com.dbflow5.config.databaseForTable +import com.dbflow5.config.modelAdapter +import com.dbflow5.config.tableName +import com.dbflow5.contentobserver.User_Table.id +import com.dbflow5.contentobserver.User_Table.name +import com.dbflow5.getNotificationUri +import com.dbflow5.query.SQLOperator +import com.dbflow5.query.delete +import com.dbflow5.runtime.FlowContentObserver +import com.dbflow5.structure.ChangeAction +import com.dbflow5.structure.delete +import com.dbflow5.structure.insert +import com.dbflow5.structure.save +import com.dbflow5.structure.update import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Before diff --git a/tests/src/androidTest/java/com/raizlabs/dbflow5/prepackaged/PrepackagedDBTest.kt b/tests/src/androidTest/java/com/dbflow5/prepackaged/PrepackagedDBTest.kt similarity index 61% rename from tests/src/androidTest/java/com/raizlabs/dbflow5/prepackaged/PrepackagedDBTest.kt rename to tests/src/androidTest/java/com/dbflow5/prepackaged/PrepackagedDBTest.kt index ce971ff60..e781fc534 100644 --- a/tests/src/androidTest/java/com/raizlabs/dbflow5/prepackaged/PrepackagedDBTest.kt +++ b/tests/src/androidTest/java/com/dbflow5/prepackaged/PrepackagedDBTest.kt @@ -1,9 +1,9 @@ -package com.raizlabs.dbflow5.prepackaged +package com.dbflow5.prepackaged -import com.raizlabs.dbflow5.BaseInstrumentedUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.query.list -import com.raizlabs.dbflow5.query.select +import com.dbflow5.BaseInstrumentedUnitTest +import com.dbflow5.config.databaseForTable +import com.dbflow5.query.list +import com.dbflow5.query.select import org.junit.Assert.assertTrue import org.junit.Test diff --git a/tests/src/androidTest/java/com/raizlabs/dbflow5/sqlcipher/CipherTest.kt b/tests/src/androidTest/java/com/dbflow5/sqlcipher/CipherTest.kt similarity index 70% rename from tests/src/androidTest/java/com/raizlabs/dbflow5/sqlcipher/CipherTest.kt rename to tests/src/androidTest/java/com/dbflow5/sqlcipher/CipherTest.kt index 42e4d160c..35b31ce05 100644 --- a/tests/src/androidTest/java/com/raizlabs/dbflow5/sqlcipher/CipherTest.kt +++ b/tests/src/androidTest/java/com/dbflow5/sqlcipher/CipherTest.kt @@ -1,10 +1,10 @@ -package com.raizlabs.dbflow5.sqlcipher +package com.dbflow5.sqlcipher -import com.raizlabs.dbflow5.BaseInstrumentedUnitTest -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.query.delete -import com.raizlabs.dbflow5.query.result -import com.raizlabs.dbflow5.query.select +import com.dbflow5.BaseInstrumentedUnitTest +import com.dbflow5.config.database +import com.dbflow5.query.delete +import com.dbflow5.query.result +import com.dbflow5.query.select import org.junit.Assert.assertTrue import org.junit.Test diff --git a/tests/src/main/AndroidManifest.xml b/tests/src/main/AndroidManifest.xml index 8cc416cf4..2de105f2c 100644 --- a/tests/src/main/AndroidManifest.xml +++ b/tests/src/main/AndroidManifest.xml @@ -1,18 +1,18 @@ + android:name="com.dbflow5.test.DemoActivity"> @@ -21,7 +21,7 @@ diff --git a/tests/src/main/java/com/dbflow5/AppDatabase.kt b/tests/src/main/java/com/dbflow5/AppDatabase.kt new file mode 100644 index 000000000..74df036f7 --- /dev/null +++ b/tests/src/main/java/com/dbflow5/AppDatabase.kt @@ -0,0 +1,7 @@ +package com.dbflow5 + +import com.dbflow5.annotation.Database +import com.dbflow5.config.DBFlowDatabase + +@Database(version = 1) +abstract class AppDatabase : DBFlowDatabase() \ No newline at end of file diff --git a/tests/src/main/java/com/raizlabs/dbflow5/DemoApp.kt b/tests/src/main/java/com/dbflow5/DemoApp.kt similarity index 91% rename from tests/src/main/java/com/raizlabs/dbflow5/DemoApp.kt rename to tests/src/main/java/com/dbflow5/DemoApp.kt index b5e8b375b..72a768215 100644 --- a/tests/src/main/java/com/raizlabs/dbflow5/DemoApp.kt +++ b/tests/src/main/java/com/dbflow5/DemoApp.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5 +package com.dbflow5 import android.annotation.SuppressLint import android.app.Application diff --git a/tests/src/main/java/com/raizlabs/dbflow5/StubContentProvider.kt b/tests/src/main/java/com/dbflow5/StubContentProvider.kt similarity index 97% rename from tests/src/main/java/com/raizlabs/dbflow5/StubContentProvider.kt rename to tests/src/main/java/com/dbflow5/StubContentProvider.kt index 56589c445..170837eae 100644 --- a/tests/src/main/java/com/raizlabs/dbflow5/StubContentProvider.kt +++ b/tests/src/main/java/com/dbflow5/StubContentProvider.kt @@ -1,4 +1,4 @@ -package com.raizlabs.dbflow5 +package com.dbflow5 import android.content.ContentProvider import android.content.ContentValues diff --git a/tests/src/main/java/com/raizlabs/dbflow5/User.kt b/tests/src/main/java/com/dbflow5/User.kt similarity index 58% rename from tests/src/main/java/com/raizlabs/dbflow5/User.kt rename to tests/src/main/java/com/dbflow5/User.kt index 7f417004e..7b541767e 100644 --- a/tests/src/main/java/com/raizlabs/dbflow5/User.kt +++ b/tests/src/main/java/com/dbflow5/User.kt @@ -1,8 +1,8 @@ -package com.raizlabs.dbflow5 +package com.dbflow5 -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table +import com.dbflow5.annotation.Column +import com.dbflow5.annotation.PrimaryKey +import com.dbflow5.annotation.Table @Table(database = AppDatabase::class, name = "User2") class User(@PrimaryKey var id: Int = 0, diff --git a/tests/src/main/java/com/dbflow5/contentobserver/User.kt b/tests/src/main/java/com/dbflow5/contentobserver/User.kt new file mode 100644 index 000000000..a1a4cabb2 --- /dev/null +++ b/tests/src/main/java/com/dbflow5/contentobserver/User.kt @@ -0,0 +1,9 @@ +package com.dbflow5.contentobserver + +import com.dbflow5.AppDatabase +import com.dbflow5.annotation.Column +import com.dbflow5.annotation.PrimaryKey +import com.dbflow5.annotation.Table + +@Table(database = AppDatabase::class) +class User(@PrimaryKey var id: Int = 0, @PrimaryKey var name: String = "", @Column var age: Int = 0) \ No newline at end of file diff --git a/tests/src/main/java/com/dbflow5/prepackaged/PrepackagedDB.kt b/tests/src/main/java/com/dbflow5/prepackaged/PrepackagedDB.kt new file mode 100644 index 000000000..46f975d55 --- /dev/null +++ b/tests/src/main/java/com/dbflow5/prepackaged/PrepackagedDB.kt @@ -0,0 +1,24 @@ +package com.dbflow5.prepackaged + +import com.dbflow5.annotation.Column +import com.dbflow5.annotation.Database +import com.dbflow5.annotation.PrimaryKey +import com.dbflow5.annotation.Table +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.structure.BaseModel + +@Database(version = 1) +abstract class PrepackagedDB : DBFlowDatabase() + +@Table(database = PrepackagedDB::class, allFields = true) +class Dog : BaseModel() { + + @PrimaryKey + var id: Int = 0 + + @Column + var breed: String? = null + + @Column + var color: String? = null +} \ No newline at end of file diff --git a/tests/src/main/java/com/dbflow5/sqlcipher/CipherDatabase.kt b/tests/src/main/java/com/dbflow5/sqlcipher/CipherDatabase.kt new file mode 100644 index 000000000..fe1712e86 --- /dev/null +++ b/tests/src/main/java/com/dbflow5/sqlcipher/CipherDatabase.kt @@ -0,0 +1,7 @@ +package com.dbflow5.sqlcipher + +import com.dbflow5.annotation.Database +import com.dbflow5.config.DBFlowDatabase + +@Database(version = 1) +abstract class CipherDatabase : DBFlowDatabase() \ No newline at end of file diff --git a/tests/src/main/java/com/raizlabs/dbflow5/sqlcipher/CipherTestObjects.kt b/tests/src/main/java/com/dbflow5/sqlcipher/CipherTestObjects.kt similarity index 60% rename from tests/src/main/java/com/raizlabs/dbflow5/sqlcipher/CipherTestObjects.kt rename to tests/src/main/java/com/dbflow5/sqlcipher/CipherTestObjects.kt index 17d70bd00..424422b22 100644 --- a/tests/src/main/java/com/raizlabs/dbflow5/sqlcipher/CipherTestObjects.kt +++ b/tests/src/main/java/com/dbflow5/sqlcipher/CipherTestObjects.kt @@ -1,12 +1,12 @@ -package com.raizlabs.dbflow5.sqlcipher +package com.dbflow5.sqlcipher import android.content.Context -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.database.DatabaseCallback -import com.raizlabs.dbflow5.structure.BaseModel +import com.dbflow5.annotation.Column +import com.dbflow5.annotation.PrimaryKey +import com.dbflow5.annotation.Table +import com.dbflow5.config.DBFlowDatabase +import com.dbflow5.database.DatabaseCallback +import com.dbflow5.structure.BaseModel class SQLCipherOpenHelperImpl(context: Context, databaseDefinition: DBFlowDatabase, diff --git a/tests/src/main/java/com/raizlabs/dbflow5/test/DemoActivity.java b/tests/src/main/java/com/dbflow5/test/DemoActivity.java similarity index 63% rename from tests/src/main/java/com/raizlabs/dbflow5/test/DemoActivity.java rename to tests/src/main/java/com/dbflow5/test/DemoActivity.java index 23d0e193d..55c51f254 100644 --- a/tests/src/main/java/com/raizlabs/dbflow5/test/DemoActivity.java +++ b/tests/src/main/java/com/dbflow5/test/DemoActivity.java @@ -1,15 +1,16 @@ -package com.raizlabs.dbflow5.test; +package com.dbflow5.test; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; -import com.raizlabs.dbflow5.config.DatabaseConfig; -import com.raizlabs.dbflow5.config.FlowConfig; -import com.raizlabs.dbflow5.config.FlowManager; -import com.raizlabs.dbflow5.database.AndroidSQLiteOpenHelper; -import com.raizlabs.dbflow5.prepackaged.PrepackagedDB; +import com.dbflow5.config.DatabaseConfig; +import com.dbflow5.config.FlowConfig; +import com.dbflow5.config.FlowManager; +import com.dbflow5.database.AndroidSQLiteOpenHelper; +import com.dbflow5.prepackaged.PrepackagedDB; +import com.dbflow5.test.R; public class DemoActivity extends Activity { @@ -20,12 +21,12 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_demo); FlowManager.init(new FlowConfig.Builder(getApplicationContext()) - .database( - DatabaseConfig.builder(PrepackagedDB.class, - (dbFlowDatabase, databaseHelperListener) -> new AndroidSQLiteOpenHelper(getApplicationContext(), dbFlowDatabase, databaseHelperListener)) - .databaseName("prepackaged") - .build()) - .build()); + .database(DatabaseConfig.builder(PrepackagedDB.class, + (dbFlowDatabase, databaseHelperListener) -> + new AndroidSQLiteOpenHelper(getApplicationContext(), dbFlowDatabase, databaseHelperListener)) + .databaseName("prepackaged") + .build()) + .build()); } diff --git a/tests/src/main/java/com/raizlabs/dbflow5/AppDatabase.kt b/tests/src/main/java/com/raizlabs/dbflow5/AppDatabase.kt deleted file mode 100644 index 7770d693e..000000000 --- a/tests/src/main/java/com/raizlabs/dbflow5/AppDatabase.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.raizlabs.dbflow5 - -import com.raizlabs.dbflow5.annotation.Database -import com.raizlabs.dbflow5.config.DBFlowDatabase - -@Database(version = 1) -abstract class AppDatabase : DBFlowDatabase() \ No newline at end of file diff --git a/tests/src/main/java/com/raizlabs/dbflow5/contentobserver/User.kt b/tests/src/main/java/com/raizlabs/dbflow5/contentobserver/User.kt deleted file mode 100644 index 643625529..000000000 --- a/tests/src/main/java/com/raizlabs/dbflow5/contentobserver/User.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.raizlabs.dbflow5.contentobserver - -import com.raizlabs.dbflow5.AppDatabase -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table - -@Table(database = AppDatabase::class) -class User(@PrimaryKey var id: Int = 0, @PrimaryKey var name: String = "", @Column var age: Int = 0) \ No newline at end of file diff --git a/tests/src/main/java/com/raizlabs/dbflow5/prepackaged/PrepackagedDB.kt b/tests/src/main/java/com/raizlabs/dbflow5/prepackaged/PrepackagedDB.kt deleted file mode 100644 index 45e7f03fa..000000000 --- a/tests/src/main/java/com/raizlabs/dbflow5/prepackaged/PrepackagedDB.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.raizlabs.dbflow5.prepackaged - -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.Database -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.structure.BaseModel - -@Database(version = 1) -abstract class PrepackagedDB : DBFlowDatabase() - -@Table(database = PrepackagedDB::class, allFields = true) -class Dog : BaseModel() { - - @PrimaryKey - var id: Int = 0 - - @Column - var breed: String? = null - - @Column - var color: String? = null -} \ No newline at end of file diff --git a/tests/src/main/java/com/raizlabs/dbflow5/sqlcipher/CipherDatabase.kt b/tests/src/main/java/com/raizlabs/dbflow5/sqlcipher/CipherDatabase.kt deleted file mode 100644 index 8bf9d547b..000000000 --- a/tests/src/main/java/com/raizlabs/dbflow5/sqlcipher/CipherDatabase.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.raizlabs.dbflow5.sqlcipher - -import com.raizlabs.dbflow5.annotation.Database -import com.raizlabs.dbflow5.config.DBFlowDatabase - -@Database(version = 1) -abstract class CipherDatabase : DBFlowDatabase() \ No newline at end of file diff --git a/tests/src/main/res/layout/activity_demo.xml b/tests/src/main/res/layout/activity_demo.xml index a097220b6..313157d13 100644 --- a/tests/src/main/res/layout/activity_demo.xml +++ b/tests/src/main/res/layout/activity_demo.xml @@ -6,7 +6,7 @@ android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" - tools:context="com.raizlabs.dbflow5.test.DemoActivity"> + tools:context="com.dbflow5.test.DemoActivity"> + tools:context="com.dbflow5.DemoActivity"> - + diff --git a/tests/src/test/java/com/raizlabs/dbflow5/BaseUnitTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/BaseUnitTest.kt deleted file mode 100644 index 3f960b816..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/BaseUnitTest.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.raizlabs.dbflow5 - -import android.content.Context -import org.junit.Rule -import org.junit.runner.RunWith -import org.robolectric.RobolectricTestRunner -import org.robolectric.RuntimeEnvironment -import org.robolectric.annotation.Config - -@RunWith(RobolectricTestRunner::class) -@Config(manifest = Config.NONE) -abstract class BaseUnitTest { - - @JvmField - @Rule - var dblflowTestRule = DBFlowTestRule.create() - - val context: Context - get() = RuntimeEnvironment.application -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/DBFlowTestRule.kt b/tests/src/test/java/com/raizlabs/dbflow5/DBFlowTestRule.kt deleted file mode 100644 index a546c7397..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/DBFlowTestRule.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.raizlabs.dbflow5 - -import android.content.Context -import com.raizlabs.dbflow5.config.DatabaseConfig -import com.raizlabs.dbflow5.config.FlowConfig -import com.raizlabs.dbflow5.config.FlowLog -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.database.AndroidSQLiteOpenHelper -import com.raizlabs.dbflow5.provider.ContentDatabase -import com.raizlabs.dbflow5.runtime.DirectModelNotifier -import org.junit.rules.TestRule -import org.junit.runner.Description -import org.junit.runners.model.Statement -import org.robolectric.RuntimeEnvironment - -class DBFlowTestRule : TestRule { - - val context: Context - get() = RuntimeEnvironment.application - - override fun apply(base: Statement, description: Description): Statement { - return object : Statement() { - - @Throws(Throwable::class) - override fun evaluate() { - FlowLog.setMinimumLoggingLevel(FlowLog.Level.V) - DirectModelNotifier().clearListeners() - FlowManager.init(FlowConfig.Builder(RuntimeEnvironment.application) - .database(DatabaseConfig.Builder(TestDatabase::class, AndroidSQLiteOpenHelper.createHelperCreator(context)) - .transactionManagerCreator(::ImmediateTransactionManager2) - .build()) - .database(DatabaseConfig.builder(ContentDatabase::class, - AndroidSQLiteOpenHelper.createHelperCreator(context)) - .databaseName("content") - .build()) - .build()) - try { - base.evaluate() - } finally { - FlowManager.destroy() - } - } - } - } - - companion object { - fun create() = DBFlowTestRule() - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/ImmediateTransactionManager.kt b/tests/src/test/java/com/raizlabs/dbflow5/ImmediateTransactionManager.kt deleted file mode 100644 index 4c75ba653..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/ImmediateTransactionManager.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.raizlabs.dbflow5 - -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.transaction.BaseTransactionManager -import com.raizlabs.dbflow5.transaction.ITransactionQueue -import com.raizlabs.dbflow5.transaction.Transaction - -/** - * Description: Executes all transactions on same thread for testing. - */ -class ImmediateTransactionManager2(databaseDefinition: DBFlowDatabase) - : BaseTransactionManager(ImmediateTransactionQueue2(), databaseDefinition) - - -class ImmediateTransactionQueue2 : ITransactionQueue { - - override fun add(transaction: Transaction) { - transaction.newBuilder() - .runCallbacksOnSameThread(true) - .build() - .executeSync() - } - - override fun cancel(transaction: Transaction) { - - } - - override fun startIfNotAlive() { - } - - override fun cancel(name: String) { - } - - override fun quit() { - } - -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/TestDatabase.kt b/tests/src/test/java/com/raizlabs/dbflow5/TestDatabase.kt deleted file mode 100644 index b07cc5a55..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/TestDatabase.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.raizlabs.dbflow5 - -import com.raizlabs.dbflow5.annotation.Database -import com.raizlabs.dbflow5.annotation.Migration -import com.raizlabs.dbflow5.config.DBFlowDatabase -import com.raizlabs.dbflow5.migration.UpdateTableMigration -import com.raizlabs.dbflow5.models.SimpleModel - -/** - * Description: - */ -@Database(version = 1) -abstract class TestDatabase : DBFlowDatabase() { - - @Migration(version = 1, database = TestDatabase::class) - class TestMigration : UpdateTableMigration(SimpleModel::class.java) - -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/TestExtensions.kt b/tests/src/test/java/com/raizlabs/dbflow5/TestExtensions.kt deleted file mode 100644 index 4171499de..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/TestExtensions.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.raizlabs.dbflow5 - -import com.raizlabs.dbflow5.sql.Query -import org.junit.Assert.assertEquals -import org.junit.Assert.fail -import kotlin.reflect.KClass - - -fun String.assertEquals(query: Query) = assertEquals(this, query.query.trim()) - -fun Query.assertEquals(actual: Query) = assertEquals(query.trim(), actual.query.trim()) - -fun assertThrowsException(expectedException: KClass, function: () -> Unit) { - try { - function() - fail("Expected call to fail. Unexpectedly passed") - } catch (e: Exception) { - if (e.javaClass != expectedException.java) { - e.printStackTrace() - fail("Expected $expectedException but got ${e.javaClass}") - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/config/ConfigIntegrationTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/config/ConfigIntegrationTest.kt deleted file mode 100644 index e1c3f6d52..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/config/ConfigIntegrationTest.kt +++ /dev/null @@ -1,80 +0,0 @@ -package com.raizlabs.dbflow5.config - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.adapter.queriable.ListModelLoader -import com.raizlabs.dbflow5.adapter.queriable.SingleModelLoader -import com.raizlabs.dbflow5.adapter.saveable.ModelSaver -import com.raizlabs.dbflow5.database.AndroidSQLiteOpenHelper -import com.raizlabs.dbflow5.models.SimpleModel -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertTrue -import org.junit.Before -import org.junit.Test - -/** - * Description: - */ -class ConfigIntegrationTest : BaseUnitTest() { - - private lateinit var builder: FlowConfig.Builder - - @Before - fun setup() { - FlowManager.reset() - FlowLog.setMinimumLoggingLevel(FlowLog.Level.V) - builder = FlowConfig.Builder(context) - } - - - @Test - fun test_flowConfig() { - val config = builder - .openDatabasesOnInit(true) - .build() - assertEquals(config.openDatabasesOnInit, true) - assertTrue(config.databaseConfigMap.isEmpty()) - assertTrue(config.databaseHolders.isEmpty()) - } - - @Test - fun test_tableConfig() { - - val customListModelLoader = ListModelLoader(SimpleModel::class.java) - val singleModelLoader = SingleModelLoader(SimpleModel::class.java) - val modelSaver = ModelSaver() - - FlowManager.init(builder - .database(DatabaseConfig.Builder(TestDatabase::class.java, - AndroidSQLiteOpenHelper.createHelperCreator(context)) - .addTableConfig(TableConfig.Builder(SimpleModel::class.java) - .singleModelLoader(singleModelLoader) - .listModelLoader(customListModelLoader) - .modelAdapterModelSaver(modelSaver) - .build()) - .build()) - .build()) - - val flowConfig = FlowManager.getConfig() - assertNotNull(flowConfig) - - val databaseConfig = flowConfig.databaseConfigMap[TestDatabase::class.java] as DatabaseConfig - assertNotNull(databaseConfig) - - - val config = databaseConfig.tableConfigMap[SimpleModel::class.java] as TableConfig - assertNotNull(config) - - assertEquals(config.listModelLoader, customListModelLoader) - assertEquals(config.singleModelLoader, singleModelLoader) - - val modelAdapter = SimpleModel::class.modelAdapter - assertEquals(modelAdapter.listModelLoader, customListModelLoader) - assertEquals(modelAdapter.singleModelLoader, singleModelLoader) - assertEquals(modelAdapter.modelSaver, modelSaver) - } - -} - - diff --git a/tests/src/test/java/com/raizlabs/dbflow5/config/DatabaseConfigTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/config/DatabaseConfigTest.kt deleted file mode 100644 index e27f1ce01..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/config/DatabaseConfigTest.kt +++ /dev/null @@ -1,88 +0,0 @@ -package com.raizlabs.dbflow5.config - -import com.nhaarman.mockito_kotlin.mock -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.database.AndroidSQLiteOpenHelper -import com.raizlabs.dbflow5.database.DatabaseCallback -import com.raizlabs.dbflow5.database.OpenHelper -import com.raizlabs.dbflow5.transaction.BaseTransactionManager -import org.junit.Assert -import org.junit.Before -import org.junit.Test - - -/** - * Description: - */ -class DatabaseConfigTest : BaseUnitTest() { - - private lateinit var builder: FlowConfig.Builder - - @Before - fun setup() { - FlowManager.reset() - FlowLog.setMinimumLoggingLevel(FlowLog.Level.V) - builder = FlowConfig.Builder(context) - } - - @Test - fun test_databaseConfig() { - - val helperListener = mock() - val customOpenHelper = mock() - - val openHelperCreator: ((DBFlowDatabase, DatabaseCallback?) -> OpenHelper) = { _, _ -> - customOpenHelper - } - var testTransactionManager: TestTransactionManager? = null - val managerCreator: (DBFlowDatabase) -> BaseTransactionManager = { databaseDefinition -> - testTransactionManager = TestTransactionManager(databaseDefinition) - testTransactionManager!! - } - - FlowManager.init(builder - .database(DatabaseConfig.Builder(TestDatabase::class.java, openHelperCreator) - .databaseName("Test") - .helperListener(helperListener) - .transactionManagerCreator(managerCreator) - .build()) - .build()) - - val flowConfig = FlowManager.getConfig() - Assert.assertNotNull(flowConfig) - - val databaseConfig = flowConfig.databaseConfigMap[TestDatabase::class.java]!! - Assert.assertEquals("Test", databaseConfig.databaseName) - Assert.assertEquals(".db", databaseConfig.databaseExtensionName) - Assert.assertEquals(databaseConfig.transactionManagerCreator, managerCreator) - Assert.assertEquals(databaseConfig.databaseClass, TestDatabase::class.java) - Assert.assertEquals(databaseConfig.openHelperCreator, openHelperCreator) - Assert.assertEquals(databaseConfig.callback, helperListener) - Assert.assertTrue(databaseConfig.tableConfigMap.isEmpty()) - - - val databaseDefinition = database() - Assert.assertEquals(databaseDefinition.transactionManager, testTransactionManager) - Assert.assertEquals(databaseDefinition.openHelper, customOpenHelper) - } - - @Test - fun test_EmptyName() { - FlowManager.init(builder - .database(DatabaseConfig.Builder(TestDatabase::class.java, - AndroidSQLiteOpenHelper.createHelperCreator(context)) - .databaseName("Test") - .extensionName("") - .build()) - .build()) - - val databaseConfig = FlowManager.getConfig().databaseConfigMap[TestDatabase::class.java]!! - Assert.assertEquals("Test", databaseConfig.databaseName) - Assert.assertEquals("", databaseConfig.databaseExtensionName) - } - -} - -class TestTransactionManager(databaseDefinition: DBFlowDatabase) - : BaseTransactionManager(mock(), databaseDefinition) \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/database/transaction/CoroutinesTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/database/transaction/CoroutinesTest.kt deleted file mode 100644 index 02632963d..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/database/transaction/CoroutinesTest.kt +++ /dev/null @@ -1,93 +0,0 @@ -package com.raizlabs.dbflow5.database.transaction - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.coroutines.awaitDelete -import com.raizlabs.dbflow5.coroutines.awaitInsert -import com.raizlabs.dbflow5.coroutines.awaitSave -import com.raizlabs.dbflow5.coroutines.awaitTransact -import com.raizlabs.dbflow5.coroutines.awaitUpdate -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.models.TwoColumnModel -import com.raizlabs.dbflow5.models.TwoColumnModel_Table -import com.raizlabs.dbflow5.query.delete -import com.raizlabs.dbflow5.query.list -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.structure.save -import kotlinx.coroutines.experimental.runBlocking -import org.junit.Test - -/** - * Description: - */ -class CoroutinesTest : BaseUnitTest() { - - @Test - fun testTransact() { - runBlocking { - database { - (0..9).forEach { - SimpleModel("$it").save() - } - - val query = awaitTransact( - select from SimpleModel::class - where SimpleModel_Table.name.eq("5")) { list } - - assert(query.size == 1) - - - val result = awaitTransact( - delete() - where SimpleModel_Table.name.eq("5")) { executeUpdateDelete(this@database) } - assert(result == 1L) - } - } - } - - @Test - fun testAwaitSaveAndDelete() { - runBlocking { - database { - val simpleModel = SimpleModel("Name") - val result = simpleModel.awaitSave(this) - assert(result) - - assert(simpleModel.awaitDelete(this)) - } - } - } - - @Test - fun testAwaitInsertAndDelete() { - runBlocking { - database { - val simpleModel = SimpleModel("Name") - val result = simpleModel.awaitInsert(this) - assert(result > 0) - assert(simpleModel.awaitDelete(this)) - } - } - } - - @Test - fun testAwaitUpdate() { - runBlocking { - database { - val simpleModel = TwoColumnModel(name = "Name", id = 5) - val result = simpleModel.awaitSave(this) - assert(result) - - simpleModel.id = 5 - val updated = simpleModel.awaitUpdate(this) - assert(updated) - - val loadedModel = awaitTransact(select from TwoColumnModel::class - where TwoColumnModel_Table.id.eq(5)) { querySingle(this@database) } - assert(loadedModel?.id == 5) - } - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/database/transaction/FastStoreModelTransactionTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/database/transaction/FastStoreModelTransactionTest.kt deleted file mode 100644 index eaf83dccb..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/database/transaction/FastStoreModelTransactionTest.kt +++ /dev/null @@ -1,64 +0,0 @@ -package com.raizlabs.dbflow5.database.transaction - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.TwoColumnModel -import com.raizlabs.dbflow5.coroutines.awaitInsert -import com.raizlabs.dbflow5.coroutines.awaitSave -import com.raizlabs.dbflow5.coroutines.awaitUpdate -import com.raizlabs.dbflow5.query.list -import com.raizlabs.dbflow5.query.select -import kotlinx.coroutines.experimental.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotEquals -import org.junit.Test -import java.util.* - -class FastStoreModelTransactionTest : BaseUnitTest() { - - @Test - fun testSaveBuilder() { - runBlocking { - database(TestDatabase::class) { - val result = (0..9) - .map { SimpleModel("$it") }.awaitSave(this) - val list = (select from SimpleModel::class).list - assertEquals(10, list.size) - assertEquals(10L, result) - } - } - } - - @Test - fun testInsertBuilder() { - runBlocking { - database(TestDatabase::class) { - val result = (0..9) - .map { SimpleModel("$it") }.awaitInsert(this) - val list = (select from SimpleModel::class).list - assertEquals(10, list.size) - assertEquals(10L, result) - } - } - } - - @Test - fun testUpdateBuilder() { - runBlocking { - database(TestDatabase::class) { - val oldList = (0..9).map { TwoColumnModel("$it", Random().nextInt()) } - oldList.awaitInsert(this) - - (0..9).map { TwoColumnModel("$it", Random().nextInt()) }.awaitUpdate(this) - - val list = (select from TwoColumnModel::class).list - assertEquals(10, list.size) - list.forEachIndexed { index, model -> - assertNotEquals(model, oldList[index]) - } - } - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/migration/UpdateTableMigrationTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/migration/UpdateTableMigrationTest.kt deleted file mode 100644 index f31196a1f..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/migration/UpdateTableMigrationTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.raizlabs.dbflow5.migration - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import org.junit.Test - -/** - * Description: - */ - -class UpdateTableMigrationTest : BaseUnitTest() { - - - @Test - fun testUpdateMigrationQuery() { - val update = UpdateTableMigration(SimpleModel::class.java) - update.set(SimpleModel_Table.name.eq("yes")) - update.migrate(databaseForTable()) - } -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/AutoIncrementTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/AutoIncrementTest.kt deleted file mode 100644 index 2b9c465be..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/AutoIncrementTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.structure.insert -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * Description: - */ -class AutoIncrementTest : BaseUnitTest() { - - @Test - fun testCanInsertAutoIncrement() { - val model = AutoIncrementingModel() - model.insert() - assertEquals(1L, model.id) - } - - @Test - fun testCanInsertExistingIdAutoIncrement() { - val model = AutoIncrementingModel(3) - model.insert() - assertEquals(3L, model.id) - } -} - - -@Table(database = TestDatabase::class) -class AutoIncrementingModel(@PrimaryKey(autoincrement = true) var id: Long = 0) \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/CachingModels.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/CachingModels.kt deleted file mode 100644 index 947ceff5a..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/CachingModels.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.ForeignKey -import com.raizlabs.dbflow5.annotation.MultiCacheField -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.query.cache.IMultiKeyCacheConverter - -@Table(database = TestDatabase::class, cachingEnabled = true) -class SimpleCacheObject(@PrimaryKey var id: String = "") - -@Table(database = TestDatabase::class, cachingEnabled = true) -class Coordinate(@PrimaryKey var latitude: Double = 0.0, - @PrimaryKey var longitude: Double = 0.0, - @ForeignKey var path: Path? = null) { - - companion object { - @JvmField - @MultiCacheField - val cacheConverter = object : IMultiKeyCacheConverter { - override fun getCachingKey(values: Array) = "${values[0]},${values[1]}" - } - } -} - -@Table(database = TestDatabase::class) -class Path(@PrimaryKey var id: String = "", - @Column var name: String = "") \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/CachingModelsTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/CachingModelsTest.kt deleted file mode 100644 index 3a6e2fb11..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/CachingModelsTest.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.query.list -import com.raizlabs.dbflow5.query.result -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotEquals -import org.junit.Test - -/** - * Description: Tests to ensure caching works as expected. - */ -class CachingModelsTest : BaseUnitTest() { - - @Test - fun testSimpleCache() = database(TestDatabase::class) { - val list = arrayListOf() - (0..9).forEach { - val simpleCacheObject = SimpleCacheObject("$it") - simpleCacheObject.save() - list += simpleCacheObject - } - - val loadedList = (select from SimpleCacheObject::class).list - - loadedList.forEachIndexed { index, simpleCacheObject -> - assertEquals(list[index], simpleCacheObject) - } - } - - @Test - fun testComplexObject() = database(TestDatabase::class) { - val path = Path("1", "Path") - path.save() - - val coordinate = Coordinate(40.5, 84.0, path) - coordinate.save() - - val oldPath = coordinate.path - - val loadedCoordinate = (select from Coordinate::class).result!! - assertEquals(coordinate, loadedCoordinate) - - // we want to ensure relationships reloaded. - assertNotEquals(oldPath, loadedCoordinate.path) - } -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/DontCreateModelTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/DontCreateModelTest.kt deleted file mode 100644 index e11dcb67d..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/DontCreateModelTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.assertThrowsException -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.database.SQLiteException -import com.raizlabs.dbflow5.query.list -import com.raizlabs.dbflow5.query.select -import org.junit.Test - -/** - * Description: - */ -class DontCreateModelTest : BaseUnitTest() { - - @Test - fun testModelNotCreated() { - databaseForTable { - assertThrowsException(SQLiteException::class) { - (select from DontCreateModel::class).list - } - } - } -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/ForeignKeyModels.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/ForeignKeyModels.kt deleted file mode 100644 index c41578117..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/ForeignKeyModels.kt +++ /dev/null @@ -1,112 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.ColumnMap -import com.raizlabs.dbflow5.annotation.ColumnMapReference -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.annotation.ForeignKey -import com.raizlabs.dbflow5.annotation.ForeignKeyAction -import com.raizlabs.dbflow5.annotation.ForeignKeyReference -import com.raizlabs.dbflow5.annotation.NotNull -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.annotation.TypeConverter -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.query.LoadFromCursorListener - -/** - * Example of simple foreign key object with one foreign key object. - */ -@Table(database = TestDatabase::class) -class Blog(@PrimaryKey(autoincrement = true) var id: Int = 0, @Column var name: String = "", - @ForeignKey(saveForeignKeyModel = true) var author: Author? = null) - -/** - * Parent used as foreign key reference. - */ -@Table(database = TestDatabase::class) -class Author(@PrimaryKey(autoincrement = true) var id: Int = 0, - @Column(name = "first_name") var firstName: String = "", - @Column(name = "last_name") var lastName: String = "") - -/** - * Example of simple foreign key object with its [ForeignKey] deferred. - */ -@Table(database = TestDatabase::class) -class BlogDeferred(@PrimaryKey(autoincrement = true) var id: Int = 0, @Column var name: String = "", - @ForeignKey(deferred = true) var author: Author? = null) - -/** - * Class has example of single foreign key with [ForeignKeyReference] specified - */ -@Table(database = TestDatabase::class) -class BlogRef(@PrimaryKey(autoincrement = true) var id: Int = 0, @Column var name: String = "", - @ForeignKey(references = arrayOf( - ForeignKeyReference(columnName = "authorId", foreignKeyColumnName = "id", - defaultValue = "not gonna work"))) - var author: Author? = null) - -/** - * Class has example of single foreign key with [ForeignKeyReference] specified that is not the model object. - */ -@Table(database = TestDatabase::class) -class BlogRefNoModel(@PrimaryKey(autoincrement = true) var id: Int = 0, @Column var name: String = "", - @ForeignKey(references = arrayOf(ForeignKeyReference(columnName = "authorId", foreignKeyColumnName = "id", notNull = NotNull(onNullConflict = ConflictAction.FAIL))), - tableClass = Author::class) - var authorId: String? = null) - - -/** - * Class has example of single foreign key with [ForeignKeyReference] as [PrimaryKey] - */ -@Table(database = TestDatabase::class) -class BlogPrimary(@PrimaryKey @ForeignKey var author: Author? = null, @Column var id: Int = 0) - -/** - * Example of simple foreign key object with one foreign key object thats [ForeignKey.stubbedRelationship] - * and [ForeignKey.deleteForeignKeyModel] and [ForeignKey.saveForeignKeyModel] - */ -@Table(database = TestDatabase::class) -class BlogStubbed(@PrimaryKey(autoincrement = true) var id: Int = 0, @Column var name: String = "", - @ForeignKey(stubbedRelationship = true, deleteForeignKeyModel = true, saveForeignKeyModel = true, - onDelete = ForeignKeyAction.CASCADE, onUpdate = ForeignKeyAction.RESTRICT) - var author: Author? = null) : LoadFromCursorListener { - override fun onLoadFromCursor(cursor: FlowCursor) { - - } -} - -class DoubleToDouble(val double: Double) - -@TypeConverter -class DoubleConverter : com.raizlabs.dbflow5.converter.TypeConverter() { - override fun getDBValue(model: DoubleToDouble?) = model?.double - - override fun getModelValue(data: Double?): DoubleToDouble? = data?.let { DoubleToDouble(data) } -} - -class Location(var latitude: DoubleToDouble? = DoubleToDouble(0.0), - var longitude: DoubleToDouble? = DoubleToDouble(0.0)) - -@Table(database = TestDatabase::class) -class Position(@PrimaryKey var id: Int = 0, @ColumnMap var location: Location? = null) - -@Table(database = TestDatabase::class) -class Position2(@PrimaryKey var id: Int = 0, - @ColumnMap(references = arrayOf( - ColumnMapReference(columnName = "latitude", columnMapFieldName = "latitude", - defaultValue = "40.6"), - ColumnMapReference(columnName = "longitude", columnMapFieldName = "longitude", - defaultValue = "55.5"))) - var location: Location? = null) - -class Location2(var latitude: DoubleToDouble? = DoubleToDouble(0.0), - var longitude: Double? = 0.0) - -@Table(database = TestDatabase::class) -class PositionWithTypeConverter(@PrimaryKey var id: Int = 0, - @ColumnMap(references = arrayOf(ColumnMapReference(columnName = "latitude", - columnMapFieldName = "latitude", typeConverter = DoubleConverter::class), - ColumnMapReference(columnName = "longitude", columnMapFieldName = "longitude"))) - var location: Location2? = null) diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/IndexModels.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/IndexModels.kt deleted file mode 100644 index 1b4ee29ff..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/IndexModels.kt +++ /dev/null @@ -1,38 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.Index -import com.raizlabs.dbflow5.annotation.IndexGroup -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import java.util.* - -/** - * Description: - */ - -@Table(database = TestDatabase::class, indexGroups = arrayOf(IndexGroup(number = 1, name = "firstIndex"), - IndexGroup(number = 2, name = "secondIndex"), - IndexGroup(number = 3, name = "thirdIndex"))) -class IndexModel { - @Index(indexGroups = intArrayOf(1, 2, 3)) - @PrimaryKey - var id: Int = 0 - - @Index(indexGroups = intArrayOf(1)) - @Column - var first_name: String? = null - - @Index(indexGroups = intArrayOf(2)) - @Column - var last_name: String? = null - - @Index(indexGroups = intArrayOf(3)) - @Column - var created_date: Date? = null - - @Index(indexGroups = intArrayOf(2, 3)) - @Column - var isPro: Boolean = false -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/InnerClassExample.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/InnerClassExample.kt deleted file mode 100644 index 633a1b718..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/InnerClassExample.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table - -/** - * Example ensuring static inner classes work. - */ -class Outer { - - @Table(database = TestDatabase::class) - class Inner(@PrimaryKey var id: Int = 0) -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/ManyToMany.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/ManyToMany.kt deleted file mode 100644 index 424a11e72..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/ManyToMany.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.ManyToMany -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table - -@ManyToMany(referencedTable = Song::class) -@Table(database = TestDatabase::class) -class Artist(@PrimaryKey(autoincrement = true) var id: Int = 0, - @Column var name: String = "") - -@Table(database = TestDatabase::class) -class Song(@PrimaryKey(autoincrement = true) var id: Int = 0, - @Column var name: String = "") \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/ManyToManyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/ManyToManyTest.kt deleted file mode 100644 index 63d9bb62c..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/ManyToManyTest.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.Artist -import com.raizlabs.dbflow5.models.Song -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertTrue -import org.junit.Test - -class ManyToManyTest : BaseUnitTest() { - - @Test - fun testCanCreateManyToMany() { - val artist = Artist(name = "Andrew Grosner") - val song = Song(name = "Livin' on A Prayer") - - artist.save() - song.save() - - val artistSong = Artist_Song() - artistSong.artist = artist - artistSong.song = song - assertTrue(artistSong.save()) - - - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/ModelViewTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/ModelViewTest.kt deleted file mode 100644 index d0399f14f..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/ModelViewTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.assertEquals -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.models.java.JavaModelView -import org.junit.Test - -class ModelViewTest : BaseUnitTest() { - - @Test - fun validateModelViewQuery() = database(TestDatabase::class) { - "SELECT `id` AS `authorId`,`first_name` || ' ' || `last_name` AS `authorName` FROM `Author`".assertEquals(AuthorView.getQuery()) - } - - @Test - fun validateJavaModelViewQuery() = database(TestDatabase::class) { - "SELECT `first_name` AS `firstName`,`id` AS `id`".assertEquals(JavaModelView.getQuery()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/ModelViews.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/ModelViews.kt deleted file mode 100644 index 3e44977f5..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/ModelViews.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.ColumnMap -import com.raizlabs.dbflow5.annotation.ModelView -import com.raizlabs.dbflow5.annotation.ModelViewQuery -import com.raizlabs.dbflow5.models.Author_Table.first_name -import com.raizlabs.dbflow5.models.Author_Table.id -import com.raizlabs.dbflow5.models.Author_Table.last_name -import com.raizlabs.dbflow5.query.From -import com.raizlabs.dbflow5.query.property.IProperty -import com.raizlabs.dbflow5.query.property.property -import com.raizlabs.dbflow5.query.select - -class AuthorName(var name: String = "", var age: Int = 0) - - -@ModelView(database = TestDatabase::class) -class AuthorView(@Column var authorId: Int = 0, @Column var authorName: String = "", - @ColumnMap var author: AuthorName? = null) { - - companion object { - @JvmStatic - @ModelViewQuery - fun getQuery(): From = (select(id.`as`("authorId"), - first_name.concatenate(" ".property as IProperty>) - .concatenate(last_name as IProperty>) - .`as`("authorName")) - from Author::class) - } -} - -@ModelView(database = TestDatabase::class, priority = 2, allFields = true) -class PriorityView(var name: String = "") { - - companion object { - @JvmStatic - @ModelViewQuery - fun getQuery(): From = select((first_name + last_name).`as`("name")) from Author::class - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/NonTypical/nonTypicalClassName.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/NonTypical/nonTypicalClassName.kt deleted file mode 100644 index d2cbd434d..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/NonTypical/nonTypicalClassName.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.raizlabs.dbflow5.models.NonTypical - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table - -/** - * Tests package name capitalized, class name is lower cased. - */ -@Table(database = TestDatabase::class) -class nonTypicalClassName(@PrimaryKey var id: Int = 0) \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/OneToManyModelTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/OneToManyModelTest.kt deleted file mode 100644 index 7e6df81e1..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/OneToManyModelTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.query.list -import com.raizlabs.dbflow5.query.result -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.structure.delete -import com.raizlabs.dbflow5.structure.exists -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertNull -import org.junit.Assert.assertTrue -import org.junit.Test - -class OneToManyModelTest : BaseUnitTest() { - - @Test - fun testOneToManyModel() { - database(TestDatabase::class) { - var testModel2 = TwoColumnModel("Greater", 4) - testModel2.save() - - testModel2 = TwoColumnModel("Lesser", 1) - testModel2.save() - - // assert we save - var oneToManyModel = OneToManyModel("HasOrders") - oneToManyModel.save() - assertTrue(oneToManyModel.exists()) - - // assert loading works as expected. - oneToManyModel = (select from OneToManyModel::class).result!! - assertNotNull(oneToManyModel.getRelatedOrders(this)) - assertTrue(!oneToManyModel.getRelatedOrders(this).isEmpty()) - - // assert the deletion cleared the variable - oneToManyModel.delete() - assertFalse(oneToManyModel.exists()) - assertNull(oneToManyModel.orders) - - // assert singular relationship was deleted. - val list = (select from TwoColumnModel::class).list - assertTrue(list.size == 1) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/OneToManyModels.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/OneToManyModels.kt deleted file mode 100644 index 1966dd72a..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/OneToManyModels.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.OneToMany -import com.raizlabs.dbflow5.annotation.OneToManyMethod -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.id -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.structure.BaseModel -import com.raizlabs.dbflow5.structure.oneToMany - -@Table(database = TestDatabase::class) -class OneToManyModel(@PrimaryKey var name: String? = null) { - - var orders: List? = null - - var models: List? = null - - @get:OneToMany(oneToManyMethods = [OneToManyMethod.ALL]) - var simpleModels by oneToMany { select from OneToManyBaseModel::class } - - @OneToMany(oneToManyMethods = [OneToManyMethod.ALL], - variableName = "orders", efficientMethods = false) - fun getRelatedOrders(wrapper: DatabaseWrapper): List { - var localOrders = orders - if (localOrders == null) { - localOrders = (select from TwoColumnModel::class where id.greaterThan(3)) - .queryList(wrapper) - } - orders = localOrders - return localOrders - } - - @OneToMany(oneToManyMethods = [OneToManyMethod.DELETE], - variableName = "models") - fun getRelatedModels(wrapper: DatabaseWrapper): List { - var localModels = models - if (localModels == null) { - localModels = (select from OneToManyBaseModel::class).queryList(wrapper) - } - models = localModels - return localModels - } - - -} - -@Table(database = TestDatabase::class) -class OneToManyBaseModel(@PrimaryKey var id: Int = 0) : BaseModel() \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/ParentChildCachingTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/ParentChildCachingTest.kt deleted file mode 100644 index 960013436..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/ParentChildCachingTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.query.result -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.structure.load -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * Description: - */ -class ParentChildCachingTest : BaseUnitTest() { - - - @Test - fun testCanLoadChildFromCache() = database(TestDatabase::class) { - val child = TestModelChild() - child.id = 1 - child.name = "Test child" - child.save() - - var parent = TestModelParent() - parent.id = 1 - parent.name = "Test parent" - parent.child = child - parent.save() - - parent = (select from TestModelParent::class).result!! - var parentChild = parent.child!! - parentChild = parentChild.load()!! - - assertEquals(1, parentChild.id) - assertEquals("Test child", parentChild.name) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/QueryModelTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/QueryModelTest.kt deleted file mode 100644 index fc926f541..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/QueryModelTest.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.models.Author_Table.id -import com.raizlabs.dbflow5.models.Blog_Table.author_id -import com.raizlabs.dbflow5.models.Blog_Table.name -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.structure.exists -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * Description: Tests to ensure we can load a Query model from the DB - */ -class QueryModelTest : BaseUnitTest() { - - @Test - fun testCanLoadAuthorBlogs() = database(TestDatabase::class) { - val author = Author(0, "Andrew", "Grosner") - author.save() - val blog = Blog(0, "My First Blog", author) - blog.save() - - assert(author.exists()) - assert(blog.exists()) - - val result = (select(name.withTable().`as`("blogName"), id.withTable().`as`("authorId"), - Blog_Table.id.withTable().`as`("blogId")) from Blog::class innerJoin - Author::class on (author_id.withTable() eq id.withTable())) - .queryCustomSingle(AuthorNameQuery::class.java, this)!! - assertEquals(author.id, result.authorId) - assertEquals(blog.id, result.blogId) - } -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/QueryModels.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/QueryModels.kt deleted file mode 100644 index c800b703f..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/QueryModels.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.QueryModel -import com.raizlabs.dbflow5.converter.TypeConverter -import com.raizlabs.dbflow5.data.Blob - -@QueryModel(database = TestDatabase::class, allFields = true) -class AuthorNameQuery(var blogName: String = "", - var authorId: Int = 0, var blogId: Int = 0) - - -@QueryModel(database = TestDatabase::class) -class CustomBlobModel(@Column var myBlob: MyBlob? = null) { - - class MyBlob(val blob: ByteArray) - - @com.raizlabs.dbflow5.annotation.TypeConverter - class MyTypeConverter : TypeConverter() { - - override fun getDBValue(model: MyBlob?) = model?.let { Blob(model.blob) } - - override fun getModelValue(data: Blob?) = data?.blob?.let { MyBlob(it) } - } -} - -@QueryModel(database = TestDatabase::class, allFields = true) -class AllFieldsQueryModel(var model: String? = null) \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/SimpleTestModels.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/SimpleTestModels.kt deleted file mode 100644 index 368d28415..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/SimpleTestModels.kt +++ /dev/null @@ -1,208 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.ColumnIgnore -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.annotation.ForeignKey -import com.raizlabs.dbflow5.annotation.ManyToMany -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.QueryModel -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.converter.TypeConverter -import com.raizlabs.dbflow5.data.Blob -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.query.SQLiteStatementListener -import com.raizlabs.dbflow5.structure.BaseModel -import java.math.BigDecimal -import java.math.BigInteger -import java.util.* - - -/** - * Description: - */ -@Table(database = TestDatabase::class) -class SimpleModel(@PrimaryKey var name: String? = "") - -@QueryModel(database = TestDatabase::class) -class SimpleCustomModel(@Column var name: String? = "") - -@Table(database = TestDatabase::class, insertConflict = ConflictAction.FAIL, updateConflict = ConflictAction.FAIL) -class NumberModel(@PrimaryKey var id: Int = 0) - -@Table(database = TestDatabase::class) -class CharModel(@PrimaryKey var id: Int = 0, @Column var exampleChar: Char? = null) - -@Table(database = TestDatabase::class) -class TwoColumnModel(@PrimaryKey var name: String? = "", @Column(defaultValue = "56") var id: Int = 0) - -@Table(database = TestDatabase::class, createWithDatabase = false) -class DontCreateModel(@PrimaryKey var id: Int = 0) - -enum class Difficulty { - EASY, - MEDIUM, - HARD -} - -@Table(database = TestDatabase::class) -class EnumModel(@PrimaryKey var id: Int = 0, @Column var difficulty: Difficulty? = Difficulty.EASY) - -@Table(database = TestDatabase::class, allFields = true) -open class AllFieldsModel(@PrimaryKey var name: String? = null, - var count: Int? = 0, - @Column(getterName = "getTruth") - var truth: Boolean = false, - internal val finalName: String = "", - @ColumnIgnore private val hidden: Int = 0) { - - companion object { - - // example field to ensure static not used. - var COUNT: Int = 0 - } -} - -@Table(database = TestDatabase::class, allFields = true) -class SubclassAllFields(@Column var order: Int = 0) : AllFieldsModel() - -@Table(database = TestDatabase::class, assignDefaultValuesFromCursor = false) -class DontAssignDefaultModel(@PrimaryKey var name: String? = null, - @Column(getterName = "getNullableBool") var nullableBool: Boolean? = null, - @Column var index: Int = 0) - -@Table(database = TestDatabase::class, orderedCursorLookUp = true) -class OrderCursorModel(@PrimaryKey var id: Int = 0, @Column var name: String? = "", - @Column var age: Int = 0) - -@Table(database = TestDatabase::class) -class TypeConverterModel(@PrimaryKey var id: Int = 0, - @Column(typeConverter = BlobConverter::class) var opaqueData: ByteArray? = null, - @Column var blob: Blob? = null, - @Column(typeConverter = CustomTypeConverter::class) - @PrimaryKey var customType: CustomType? = null) - -@Table(database = TestDatabase::class) -class EnumTypeConverterModel(@PrimaryKey var id: Int = 0, - @Column var blob: Blob? = null, - @Column var byteArray: ByteArray? = null, - @Column(typeConverter = CustomEnumTypeConverter::class) - var difficulty: Difficulty = Difficulty.EASY) - -@Table(database = TestDatabase::class, allFields = true) -class FeedEntry(@PrimaryKey var id: Int = 0, - var title: String? = null, - var subtitle: String? = null) - -@Table(database = TestDatabase::class) -@ManyToMany( - generatedTableClassName = "Refund", referencedTable = Transfer::class, - referencedTableColumnName = "refund_in", thisTableColumnName = "refund_out", - saveForeignKeyModels = true -) -data class Transfer(@PrimaryKey var transfer_id: UUID = UUID.randomUUID()) - -@Table(database = TestDatabase::class) -data class Transfer2( - @PrimaryKey - var id: UUID = UUID.randomUUID(), - @ForeignKey(stubbedRelationship = true) - var origin: Account? = null -) - -@Table(database = TestDatabase::class) -data class Account(@PrimaryKey var id: UUID = UUID.randomUUID()) - -@Table(database = TestDatabase::class) -class SqlListenerModel(@PrimaryKey var id: Int = 0) : SQLiteStatementListener { - - override fun onBindToInsertStatement(databaseStatement: DatabaseStatement) { - TODO("not implemented") - } - - override fun onBindToUpdateStatement(databaseStatement: DatabaseStatement) { - TODO("not implemented") - } - - override fun onBindToDeleteStatement(databaseStatement: DatabaseStatement) { - TODO("not implemented") - } -} - -class CustomType(var name: Int? = 0) - -class CustomTypeConverter : TypeConverter() { - override fun getDBValue(model: CustomType?) = model?.name - - override fun getModelValue(data: Int?) = if (data == null) { - null - } else { - CustomType(data) - } - -} - -class CustomEnumTypeConverter : TypeConverter() { - override fun getDBValue(model: Difficulty?) = model?.name?.substring(0..0) - - override fun getModelValue(data: String?) = when (data) { - "E" -> Difficulty.EASY - "M" -> Difficulty.MEDIUM - "H" -> Difficulty.HARD - else -> Difficulty.HARD - } - -} - -@com.raizlabs.dbflow5.annotation.TypeConverter -class BlobConverter : TypeConverter() { - - override fun getDBValue(model: ByteArray?): Blob? { - return if (model == null) null else Blob(model) - } - - override fun getModelValue(data: Blob?): ByteArray? { - return data?.blob - } -} - -@Table(database = TestDatabase::class) -class DefaultModel(@PrimaryKey @Column(defaultValue = "5") var id: Int? = 0, - @Column(defaultValue = "5.0") var location: Double? = 0.0, - @Column(defaultValue = "\"String\"") var name: String? = "") - -@Table(database = TestDatabase::class, cachingEnabled = true) -class TestModelChild : BaseModel() { - @PrimaryKey - var id: Long = 0 - - @Column - var name: String? = null -} - -@Table(database = TestDatabase::class) -class TestModelParent : BaseModel() { - @PrimaryKey - var id: Long = 0 - - @Column - var name: String? = null - - @ForeignKey(stubbedRelationship = true) - var child: TestModelChild? = null -} - -@Table(database = TestDatabase::class) -class NullableNumbers(@PrimaryKey var id: Int = 0, - @Column var f: Float? = null, - @Column var d: Double? = null, - @Column var l: Long? = null, - @Column var i: Int? = null, - @Column var bigDecimal: BigDecimal? = null, - @Column var bigInteger: BigInteger? = null) - -@Table(database = TestDatabase::class) -class NonNullKotlinModel(@PrimaryKey var name: String = "", - @Column var date: Date = Date(), - @Column var numb: Int = 0) \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/SimpleTestModelsTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/models/SimpleTestModelsTest.kt deleted file mode 100644 index be2fbd8eb..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/SimpleTestModelsTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.raizlabs.dbflow5.models - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.modelAdapter -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * Description: - */ -class SimpleTestModelsTest : BaseUnitTest() { - - @Test - fun validateCreationQuery() { - assertEquals("CREATE TABLE IF NOT EXISTS `TypeConverterModel`(" + - "`id` INTEGER, " + - "`opaqueData` BLOB, " + - "`blob` BLOB, " + - "`customType` INTEGER, " + - "PRIMARY KEY(`id`, `customType`))", modelAdapter().creationQuery) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/ants/AntHill.java b/tests/src/test/java/com/raizlabs/dbflow5/models/ants/AntHill.java deleted file mode 100644 index 54c0975cb..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/ants/AntHill.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.raizlabs.dbflow5.models.ants; - -import com.raizlabs.dbflow5.TestDatabase; -import com.raizlabs.dbflow5.annotation.PrimaryKey; -import com.raizlabs.dbflow5.annotation.Table; -import com.raizlabs.dbflow5.structure.BaseModel; - -@Table(database = TestDatabase.class) -public class AntHill extends BaseModel { - @PrimaryKey - public String hillId; -} - diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/ants/Ants.java b/tests/src/test/java/com/raizlabs/dbflow5/models/ants/Ants.java deleted file mode 100644 index 89b197e63..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/ants/Ants.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.raizlabs.dbflow5.models.ants; - -import com.raizlabs.dbflow5.TestDatabase; -import com.raizlabs.dbflow5.annotation.ForeignKey; -import com.raizlabs.dbflow5.annotation.ForeignKeyReference; -import com.raizlabs.dbflow5.annotation.PrimaryKey; -import com.raizlabs.dbflow5.annotation.Table; -import com.raizlabs.dbflow5.structure.BaseModel; - -@Table(database = TestDatabase.class) -public class Ants extends BaseModel { - @PrimaryKey - public String antId; - - @PrimaryKey - @ForeignKey(tableClass = AntHill.class, references = { - @ForeignKeyReference(columnName = "hillIdRef", foreignKeyColumnName = "hillId") - }) - public String hillId; -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/issue/Issue.java b/tests/src/test/java/com/raizlabs/dbflow5/models/issue/Issue.java deleted file mode 100644 index dc421b220..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/issue/Issue.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.raizlabs.dbflow5.models.issue; - -import com.raizlabs.dbflow5.TestDatabase; -import com.raizlabs.dbflow5.annotation.OneToMany; -import com.raizlabs.dbflow5.annotation.OneToManyMethod; -import com.raizlabs.dbflow5.annotation.PrimaryKey; -import com.raizlabs.dbflow5.annotation.Table; -import com.raizlabs.dbflow5.database.DatabaseWrapper; -import com.raizlabs.dbflow5.structure.BaseModel; - -import java.util.List; - -import static com.raizlabs.dbflow5.query.SQLite.select; - -/** - * Description: - */ - -@Table(database = TestDatabase.class) -public class Issue extends BaseModel { - - @PrimaryKey - String id; - - List subIssueList; - - @OneToMany(oneToManyMethods = {OneToManyMethod.SAVE, OneToManyMethod.DELETE}, variableName = "subIssueList") - public List getDbSubIssueList(DatabaseWrapper databaseWrapper) { - if (subIssueList == null || subIssueList.isEmpty()) { - subIssueList = select() - .from(SubIssue.class) - .where(SubIssue_Table.owningIssueId.eq(id)) - .queryList(databaseWrapper); - } - return subIssueList; - } -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/issue/Page.java b/tests/src/test/java/com/raizlabs/dbflow5/models/issue/Page.java deleted file mode 100644 index 28e0a327b..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/issue/Page.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.raizlabs.dbflow5.models.issue; - -import com.raizlabs.dbflow5.TestDatabase; -import com.raizlabs.dbflow5.annotation.Column; -import com.raizlabs.dbflow5.annotation.ForeignKey; -import com.raizlabs.dbflow5.annotation.PrimaryKey; -import com.raizlabs.dbflow5.annotation.Table; -import com.raizlabs.dbflow5.structure.BaseModel; - -/** - * Description: - */ -@Table(database = TestDatabase.class) -public class Page extends BaseModel { - - @PrimaryKey - @Column - String id; - - @PrimaryKey - String owningIssueId; - - @ForeignKey(stubbedRelationship = true) - SubIssue subIssue; -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/issue/SubIssue.java b/tests/src/test/java/com/raizlabs/dbflow5/models/issue/SubIssue.java deleted file mode 100644 index 7da052ad5..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/issue/SubIssue.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.raizlabs.dbflow5.models.issue; - -import com.raizlabs.dbflow5.TestDatabase; -import com.raizlabs.dbflow5.annotation.OneToMany; -import com.raizlabs.dbflow5.annotation.OneToManyMethod; -import com.raizlabs.dbflow5.annotation.PrimaryKey; -import com.raizlabs.dbflow5.annotation.Table; -import com.raizlabs.dbflow5.database.DatabaseWrapper; -import com.raizlabs.dbflow5.structure.BaseModel; - -import java.util.ArrayList; -import java.util.List; - -import static com.raizlabs.dbflow5.query.SQLite.select; - -/** - * Description: - */ - -@Table(database = TestDatabase.class) -public class SubIssue extends BaseModel { - - @PrimaryKey - String id; - - @PrimaryKey - String owningIssueId; - - List pageList; - - @OneToMany(oneToManyMethods = {OneToManyMethod.SAVE, OneToManyMethod.DELETE}, variableName = "pageList") - public List getDbPageList(DatabaseWrapper databaseWrapper) { - if (pageList == null) { - pageList = new ArrayList<>(); - } - if (pageList.isEmpty()) { - pageList = select() - .from(Page.class) - .where(Page_Table.owningIssueId.eq(owningIssueId), Page_Table.subIssue_id.eq(id)) - .queryList(databaseWrapper); - } - return pageList; - } -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/java/DatabaseModel.java b/tests/src/test/java/com/raizlabs/dbflow5/models/java/DatabaseModel.java deleted file mode 100644 index 5c174fd6c..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/java/DatabaseModel.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.raizlabs.dbflow5.models.java; - -import com.raizlabs.dbflow5.annotation.PrimaryKey; -import com.raizlabs.dbflow5.structure.BaseModel; - -public class DatabaseModel extends BaseModel { - @PrimaryKey - private Integer id; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/java/JavaModelView.java b/tests/src/test/java/com/raizlabs/dbflow5/models/java/JavaModelView.java deleted file mode 100644 index 30adc47ef..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/java/JavaModelView.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.raizlabs.dbflow5.models.java; - -import com.raizlabs.dbflow5.TestDatabase; -import com.raizlabs.dbflow5.annotation.Column; -import com.raizlabs.dbflow5.annotation.ModelView; -import com.raizlabs.dbflow5.annotation.ModelViewQuery; -import com.raizlabs.dbflow5.database.DatabaseWrapper; -import com.raizlabs.dbflow5.models.Author_Table; -import com.raizlabs.dbflow5.query.SQLite; -import com.raizlabs.dbflow5.sql.Query; - -@ModelView(database = TestDatabase.class) -public class JavaModelView { - - @ModelViewQuery - public static Query getQuery() { - return SQLite.select(Author_Table.first_name.as("firstName"), Author_Table.id.as("id")); - } - - @Column - String id; - - @Column - Integer firstName; - -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/models/java/otherpackage/ExampleModel.java b/tests/src/test/java/com/raizlabs/dbflow5/models/java/otherpackage/ExampleModel.java deleted file mode 100644 index 11e1b3862..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/models/java/otherpackage/ExampleModel.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.raizlabs.dbflow5.models.java.otherpackage; - -import com.raizlabs.dbflow5.TestDatabase; -import com.raizlabs.dbflow5.annotation.Column; -import com.raizlabs.dbflow5.annotation.Table; -import com.raizlabs.dbflow5.models.java.DatabaseModel; - -@Table(database = TestDatabase.class) -public class ExampleModel extends DatabaseModel { - @Column - String name; -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/paging/QueryDataSourceTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/paging/QueryDataSourceTest.kt deleted file mode 100644 index 77629c202..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/paging/QueryDataSourceTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -package com.raizlabs.dbflow5.paging - -import android.arch.paging.PagedList -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.assertThrowsException -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.query.set -import com.raizlabs.dbflow5.query.update -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * Description: - */ -class QueryDataSourceTest : BaseUnitTest() { - - @Test - fun testLoadInitialParams() { - database { - (0 until 100).forEach { SimpleModel("$it").save(this) } - - val factory = (select from SimpleModel::class).toDataSourceFactory(this) - val list = PagedList.Builder(factory.create(), - PagedList.Config.Builder() - .setPageSize(3) - .setPrefetchDistance(6) - .setEnablePlaceholders(true).build()) - .setFetchExecutor { it.run() } // run on main - .setNotifyExecutor { it.run() } - .build() - - assertEquals(100, list.size) - - list.forEachIndexed { index, simpleModel -> - list.loadAround(index) - assertEquals(index, simpleModel.name?.toInt()) - - // assert we don't run over somehow. - assertTrue(index < 100) - } - } - } - - @Test - fun testThrowsErrorOnInvalidType() { - database { - assertThrowsException(IllegalArgumentException::class) { - (update() set (SimpleModel_Table.name.eq("name"))) - .toDataSourceFactory(this) - .create() - } - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/provider/ContentProviderObjects.kt b/tests/src/test/java/com/raizlabs/dbflow5/provider/ContentProviderObjects.kt deleted file mode 100644 index 1e7bced14..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/provider/ContentProviderObjects.kt +++ /dev/null @@ -1,94 +0,0 @@ -package com.raizlabs.dbflow5.provider - -import com.raizlabs.dbflow5.annotation.Column -import com.raizlabs.dbflow5.annotation.Database -import com.raizlabs.dbflow5.annotation.ForeignKey -import com.raizlabs.dbflow5.annotation.ForeignKeyReference -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.annotation.provider.ContentProvider -import com.raizlabs.dbflow5.annotation.provider.ContentType -import com.raizlabs.dbflow5.annotation.provider.ContentUri -import com.raizlabs.dbflow5.annotation.provider.TableEndpoint -import com.raizlabs.dbflow5.config.DBFlowDatabase - - -/** - * Description: - */ -@ContentProvider(authority = ContentDatabase.AUTHORITY, database = ContentDatabase::class, - baseContentUri = ContentDatabase.BASE_CONTENT_URI) -@Database(version = ContentDatabase.VERSION) -abstract class ContentDatabase : DBFlowDatabase() { - companion object { - const val BASE_CONTENT_URI = "content://" - - const val AUTHORITY = "com.raizlabs.android.content.test.ContentDatabase" - - const val VERSION = 1 - } -} - -@TableEndpoint(name = ContentProviderModel.NAME, contentProvider = ContentDatabase::class) -@Table(database = ContentDatabase::class, name = ContentProviderModel.NAME, generateContentValues = true) -class ContentProviderModel(@PrimaryKey(autoincrement = true) - var id: Long = 0, - @Column - var notes: String? = null, - @Column - var title: String? = null) : BaseProviderModel() { - - override val deleteUri get() = TestContentProvider.ContentProviderModel.CONTENT_URI - - override val insertUri get() = TestContentProvider.ContentProviderModel.CONTENT_URI - - override val updateUri get() = TestContentProvider.ContentProviderModel.CONTENT_URI - - override val queryUri get() = TestContentProvider.ContentProviderModel.CONTENT_URI - - companion object { - - const val NAME = "ContentProviderModel" - - @ContentUri(path = NAME, type = "${ContentType.VND_MULTIPLE}${NAME}") - val CONTENT_URI = ContentUtils.buildUriWithAuthority(ContentDatabase.AUTHORITY) - } -} - -@Table(database = ContentDatabase::class, generateContentValues = true) -class NoteModel(@PrimaryKey(autoincrement = true) - var id: Long = 0, - - @ForeignKey(references = arrayOf(ForeignKeyReference(columnName = "providerModel", - foreignKeyColumnName = "id"))) - var contentProviderModel: ContentProviderModel? = null, - - @Column - var note: String? = null, - - @Column - var isOpen: Boolean = false) : BaseProviderModel() { - - override val deleteUri get() = TestContentProvider.NoteModel.CONTENT_URI - - override val insertUri get() = TestContentProvider.NoteModel.CONTENT_URI - - override val updateUri get() = TestContentProvider.NoteModel.CONTENT_URI - - override val queryUri get() = TestContentProvider.NoteModel.CONTENT_URI -} - -@Table(database = ContentDatabase::class, generateContentValues = true) -class TestSyncableModel(@PrimaryKey(autoincrement = true) - var id: Long = 0, - @Column - var name: String? = null) : BaseSyncableProviderModel() { - - override val deleteUri get() = TestContentProvider.TestSyncableModel.CONTENT_URI - - override val insertUri get() = TestContentProvider.TestSyncableModel.CONTENT_URI - - override val updateUri get() = TestContentProvider.TestSyncableModel.CONTENT_URI - - override val queryUri get() = TestContentProvider.TestSyncableModel.CONTENT_URI -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/provider/ContentProviderTests.kt b/tests/src/test/java/com/raizlabs/dbflow5/provider/ContentProviderTests.kt deleted file mode 100644 index 8209c4483..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/provider/ContentProviderTests.kt +++ /dev/null @@ -1,133 +0,0 @@ -package com.raizlabs.dbflow5.provider - -import android.content.ContentResolver -import android.content.pm.ProviderInfo -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.query.Delete.Companion.table -import com.raizlabs.dbflow5.query.Delete.Companion.tables -import com.raizlabs.dbflow5.query.result -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.structure.exists -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Before -import org.junit.Test -import org.robolectric.Robolectric -import org.robolectric.RuntimeEnvironment - -/** - * Description: - */ -class ContentProviderTests : BaseUnitTest() { - private val mockContentResolver: ContentResolver - get() = RuntimeEnvironment.application.contentResolver - - @Before - fun setUp() { - val info = ProviderInfo() - info.authority = TestContentProvider.AUTHORITY - Robolectric.buildContentProvider(TestContentProvider_Provider::class.java).create(info) - } - - @Test - fun testContentProviderUtils() { - database(ContentDatabase::class) { - tables(NoteModel::class.java, ContentProviderModel::class.java) - - var contentProviderModel = ContentProviderModel() - contentProviderModel.notes = "Test" - var uri = ContentUtils.insert(mockContentResolver, TestContentProvider.ContentProviderModel.CONTENT_URI, contentProviderModel) - assertEquals(TestContentProvider.ContentProviderModel.CONTENT_URI.toString() + "/" + contentProviderModel.id, uri.toString()) - assertTrue(contentProviderModel.exists()) - - contentProviderModel.notes = "NewTest" - val update = ContentUtils.update(mockContentResolver, TestContentProvider.ContentProviderModel.CONTENT_URI, contentProviderModel) - assertEquals(update.toLong(), 1) - assertTrue(contentProviderModel.exists()) - contentProviderModel = contentProviderModel.load(this)!! - assertEquals("NewTest", contentProviderModel.notes) - - val noteModel = NoteModel() - noteModel.note = "Test" - noteModel.contentProviderModel = contentProviderModel - uri = ContentUtils.insert(mockContentResolver, TestContentProvider.NoteModel.CONTENT_URI, noteModel) - assertEquals(TestContentProvider.NoteModel.CONTENT_URI.toString() + "/" + noteModel.id, uri.toString()) - assertTrue(noteModel.exists()) - - assertTrue(ContentUtils.delete(mockContentResolver, TestContentProvider.NoteModel.CONTENT_URI, noteModel) > 0) - assertTrue(!noteModel.exists()) - - assertTrue(ContentUtils.delete(mockContentResolver, TestContentProvider.ContentProviderModel.CONTENT_URI, contentProviderModel) > 0) - assertTrue(!contentProviderModel.exists()) - - tables(NoteModel::class.java, ContentProviderModel::class.java) - } - } - - @Test - fun testContentProviderNative() { - database(ContentDatabase::class) { - tables(NoteModel::class.java, ContentProviderModel::class.java) - - var contentProviderModel = ContentProviderModel(notes = "Test") - contentProviderModel.insert() - assertTrue(contentProviderModel.exists()) - - contentProviderModel.notes = "NewTest" - contentProviderModel.update() - contentProviderModel = contentProviderModel.load(this)!! - assertEquals("NewTest", contentProviderModel.notes) - - var noteModel = NoteModel(note = "Test", contentProviderModel = contentProviderModel) - noteModel.insert() - - noteModel.note = "NewTest" - noteModel.update() - noteModel = noteModel.load(this)!! - assertEquals("NewTest", noteModel.note) - - assertTrue(noteModel.exists()) - - noteModel.delete() - assertTrue(!noteModel.exists()) - - contentProviderModel.delete() - assertTrue(!contentProviderModel.exists()) - - tables(NoteModel::class.java, ContentProviderModel::class.java) - } - } - - @Test - fun testSyncableModel() { - database(ContentDatabase::class) { - table(this, TestSyncableModel::class.java) - - var testSyncableModel = TestSyncableModel(name = "Name") - testSyncableModel.save() - - assertTrue(testSyncableModel.exists()) - - testSyncableModel.name = "TestName" - testSyncableModel.update() - assertEquals(testSyncableModel.name, "TestName") - - testSyncableModel = (select from TestSyncableModel::class - where (TestSyncableModel_Table.id.`is`(testSyncableModel.id))).result!! - - var fromContentProvider = TestSyncableModel(id = testSyncableModel.id) - fromContentProvider = fromContentProvider.load(this)!! - - assertEquals(fromContentProvider.name, testSyncableModel.name) - assertEquals(fromContentProvider.id, testSyncableModel.id) - - testSyncableModel.delete() - assertFalse(testSyncableModel.exists()) - - table(this, TestSyncableModel::class.java) - } - } - -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/provider/RealContentProvider.kt b/tests/src/test/java/com/raizlabs/dbflow5/provider/RealContentProvider.kt deleted file mode 100644 index 5cc1676ca..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/provider/RealContentProvider.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.provider - -import android.content.ContentProvider -import android.content.ContentValues -import android.database.Cursor -import android.net.Uri -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.config.FlowConfig -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.database.DatabaseWrapper - -class RealContentProvider : ContentProvider() { - - lateinit var database: DatabaseWrapper - - override fun onCreate(): Boolean { - FlowManager.init(FlowConfig.Builder(context).build()) - database = database() - return true - } - - override fun query(uri: Uri, projection: Array?, selection: String?, selectionArgs: Array?, sortOrder: String?): Cursor? { - return null - } - - override fun getType(uri: Uri): String? { - return null - } - - override fun insert(uri: Uri, values: ContentValues?): Uri? { - return null - } - - override fun delete(uri: Uri, selection: String?, selectionArgs: Array?): Int { - return 0 - } - - override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array?): Int { - return 0 - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/provider/TestContentProvider.kt b/tests/src/test/java/com/raizlabs/dbflow5/provider/TestContentProvider.kt deleted file mode 100644 index 3290a797a..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/provider/TestContentProvider.kt +++ /dev/null @@ -1,137 +0,0 @@ -package com.raizlabs.dbflow5.provider - -import android.content.ContentValues -import android.content.Context -import android.net.Uri -import com.raizlabs.dbflow5.annotation.provider.ContentProvider -import com.raizlabs.dbflow5.annotation.provider.ContentType -import com.raizlabs.dbflow5.annotation.provider.ContentUri -import com.raizlabs.dbflow5.annotation.provider.Notify -import com.raizlabs.dbflow5.annotation.provider.NotifyMethod -import com.raizlabs.dbflow5.annotation.provider.PathSegment -import com.raizlabs.dbflow5.annotation.provider.TableEndpoint -import com.raizlabs.dbflow5.getContentValuesKey - -@ContentProvider(authority = TestContentProvider.AUTHORITY, database = ContentDatabase::class, - baseContentUri = TestContentProvider.BASE_CONTENT_URI) -object TestContentProvider { - - const val AUTHORITY = "com.raizlabs.dbflow5.test.provider" - - const val BASE_CONTENT_URI = "content://" - - private fun buildUri(vararg paths: String): Uri { - val builder = Uri.parse(BASE_CONTENT_URI + AUTHORITY).buildUpon() - for (path in paths) { - builder.appendPath(path) - } - return builder.build() - } - - @TableEndpoint(name = ContentProviderModel.ENDPOINT, contentProvider = ContentDatabase::class) - object ContentProviderModel { - - const val ENDPOINT = "ContentProviderModel" - - @JvmStatic - @ContentUri(path = ENDPOINT, - type = ContentType.VND_MULTIPLE + ENDPOINT) - var CONTENT_URI = buildUri(ENDPOINT) - - @JvmStatic - @ContentUri(path = ENDPOINT + "/#", - type = ContentType.VND_SINGLE + ENDPOINT, - segments = arrayOf(PathSegment(segment = 1, column = "id"))) - fun withId(id: Long): Uri { - return buildUri(id.toString()) - } - - @JvmStatic - @Notify(notifyMethod = NotifyMethod.INSERT, paths = arrayOf(ENDPOINT + "/#")) - fun onInsert(contentValues: ContentValues): Array { - val id = contentValues.getAsLong("id")!! - return arrayOf(withId(id)) - } - - } - - @TableEndpoint(name = NoteModel.ENDPOINT, contentProvider = ContentDatabase::class) - object NoteModel { - - const val ENDPOINT = "NoteModel" - - @ContentUri(path = ENDPOINT, type = ContentType.VND_MULTIPLE + ENDPOINT) - var CONTENT_URI = buildUri(ENDPOINT) - - @JvmStatic - @ContentUri(path = ENDPOINT + "/#", type = ContentType.VND_MULTIPLE + ENDPOINT, - segments = arrayOf(PathSegment(column = "id", segment = 1))) - fun withId(id: Long): Uri { - return buildUri(ENDPOINT, id.toString()) - } - - @JvmStatic - @ContentUri(path = ENDPOINT + "/#/#", - type = ContentType.VND_SINGLE + ContentProviderModel.ENDPOINT, - segments = arrayOf(PathSegment(column = "id", segment = 2))) - fun fromList(id: Long): Uri { - return buildUri(ENDPOINT, "fromList", id.toString()) - } - - @JvmStatic - @ContentUri(path = ENDPOINT + "/#/#", - type = ContentType.VND_SINGLE + ContentProviderModel.ENDPOINT, - segments = arrayOf(PathSegment(column = "id", segment = 1), - PathSegment(column = "isOpen", segment = 2))) - fun withOpenId(id: Long, isOpen: Boolean): Uri { - return buildUri(ENDPOINT, id.toString(), isOpen.toString()) - } - - @JvmStatic - @Notify(notifyMethod = NotifyMethod.INSERT, paths = arrayOf(ENDPOINT)) - fun onInsert(contentValues: ContentValues): Array { - val listId = contentValues.getAsLong(getContentValuesKey(contentValues, "providerModel"))!! - return arrayOf(ContentProviderModel.withId(listId), fromList(listId)) - } - - @JvmStatic - @Notify(notifyMethod = NotifyMethod.INSERT, paths = arrayOf(ENDPOINT)) - fun onInsert2(contentValues: ContentValues): Uri { - val listId = contentValues.getAsLong(getContentValuesKey(contentValues, "providerModel"))!! - return fromList(listId) - } - - @JvmStatic - @Notify(notifyMethod = NotifyMethod.UPDATE, paths = arrayOf(ENDPOINT + "/#")) - fun onUpdate(context: Context, uri: Uri): Array { - val noteId = java.lang.Long.valueOf(uri.pathSegments[1])!! - val c = context.contentResolver.query(uri, arrayOf("noteModel"), null, null, null) - c!!.moveToFirst() - val listId = c.getLong(c.getColumnIndex("providerModel")) - c.close() - - return arrayOf(withId(noteId), fromList(listId), ContentProviderModel.withId(listId)) - } - - @JvmStatic - @Notify(notifyMethod = NotifyMethod.DELETE, paths = arrayOf(ENDPOINT + "/#")) - fun onDelete(context: Context, uri: Uri): Array { - val noteId = java.lang.Long.valueOf(uri.pathSegments[1])!! - val c = context.contentResolver.query(uri, null, null, null, null) - c!!.moveToFirst() - val listId = c.getLong(c.getColumnIndex("providerModel")) - c.close() - - return arrayOf(withId(noteId), fromList(listId), ContentProviderModel.withId(listId)) - } - } - - @TableEndpoint(name = TestSyncableModel.ENDPOINT, contentProvider = ContentDatabase::class) - object TestSyncableModel { - - const val ENDPOINT = "TestSyncableModel" - - @ContentUri(path = ENDPOINT, type = "${ContentType.VND_MULTIPLE}${ENDPOINT}") - var CONTENT_URI = buildUri(ENDPOINT) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/query/cache/ModelLruCacheTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/query/cache/ModelLruCacheTest.kt deleted file mode 100644 index ea4fbb46c..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/query/cache/ModelLruCacheTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.raizlabs.dbflow5.query.cache - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.NumberModel -import org.junit.Assert -import org.junit.Test - -class ModelLruCacheTest : BaseUnitTest() { - - - @Test - fun validateCacheAddRemove() { - val cache = SimpleMapCache(10) - cache.addModel(1, NumberModel(1)) - - Assert.assertEquals(1, cache[1]!!.id) - Assert.assertEquals(1, cache.cache.size) - - cache.removeModel(1) - - Assert.assertTrue(cache.cache.isEmpty()) - } - - @Test - fun validateCacheClear() { - val cache = SimpleMapCache(10) - cache.addModel(1, NumberModel(1)) - cache.addModel(2, NumberModel(2)) - Assert.assertEquals(2, cache.cache.size) - - cache.clear() - - Assert.assertTrue(cache.cache.isEmpty()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/query/cache/SimpleMapCacheTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/query/cache/SimpleMapCacheTest.kt deleted file mode 100644 index adae8b6f6..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/query/cache/SimpleMapCacheTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.raizlabs.dbflow5.query.cache - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test - -class SimpleMapCacheTest : BaseUnitTest() { - - @Test - fun validateCacheAddRemove() { - val cache = SimpleMapCache(10) - cache.addModel("1", SimpleModel("1")) - - assertEquals("1", cache["1"]!!.name) - assertEquals(1, cache.cache.size) - - cache.removeModel("1") - - assertTrue(cache.cache.isEmpty()) - } - - @Test - fun validateCacheClear() { - val cache = SimpleMapCache(10) - cache.addModel("1", SimpleModel("1")) - cache.addModel("2", SimpleModel("2")) - assertEquals(2, cache.cache.size) - - cache.clear() - - assertTrue(cache.cache.isEmpty()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/query/list/FlowCursorIteratorTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/query/list/FlowCursorIteratorTest.kt deleted file mode 100644 index 89b4a1123..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/query/list/FlowCursorIteratorTest.kt +++ /dev/null @@ -1,76 +0,0 @@ -package com.raizlabs.dbflow5.query.list - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * Description: - */ -class FlowCursorIteratorTest : BaseUnitTest() { - - - @Test - fun testCanIterateFullList() { - var count = 0 - databaseForTable().beginTransactionAsync { db -> - (0..9).forEach { - SimpleModel("$it").save(db) - } - (select from SimpleModel::class).cursorList(db).iterator() - }.success { _, iterator -> - assertFalse(iterator.isClosed) - iterator.use { cursorIterator -> - cursorIterator.forEach { - assertEquals("$count", it.name) - count++ - } - } - assertTrue(iterator.isClosed) - }.execute() - } - - @Test - fun testCanIteratePartialList() { - databaseForTable().beginTransactionAsync { db -> - (0..9).forEach { - SimpleModel("$it").save(db) - } - - (select from SimpleModel::class).cursorList(db) - .iterator(2, 7) - }.success { _, iterator -> - var count = 0 - iterator.forEach { - assertEquals("${count + 2}", it.name) - count++ - } - assertEquals(7, count) - }.execute() - } - - @Test - fun testCanSupplyBadMaximumValue() { - databaseForTable().beginTransactionAsync { db -> - (0..9).forEach { - SimpleModel("$it").save() - } - - (select from SimpleModel::class).cursorList(db) - .iterator(2, Long.MAX_VALUE) - }.success { _, iterator -> - var count = 0 - iterator.forEach { - assertEquals("${count + 2}", it.name) - count++ - } - assertEquals(8, count) - }.execute() - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/query/list/FlowCursorListTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/query/list/FlowCursorListTest.kt deleted file mode 100644 index 2197c74cb..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/query/list/FlowCursorListTest.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.raizlabs.dbflow5.query.list - -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.times -import com.nhaarman.mockito_kotlin.verify -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.cursor -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * Description: - */ -class FlowCursorListTest : BaseUnitTest() { - - @Test - fun validateCursorPassed() { - databaseForTable { - val cursor = (select from SimpleModel::class).cursor - val list = FlowCursorList.Builder(select from SimpleModel::class, this) - .cursor(cursor) - .build() - - assertEquals(cursor, list.cursor) - } - } - - @Test - fun validateModelQueriable() { - databaseForTable { - val modelQueriable = (select from SimpleModel::class) - val list = FlowCursorList.Builder(modelQueriable, this) - .build() - - assertEquals(modelQueriable, list.modelQueriable) - } - } - - @Test - fun validateGetAll() { - databaseForTable { - (0..9).forEach { - SimpleModel("$it").save() - } - - val list = (select from SimpleModel::class).cursorList(this) - val all = list.all - assertEquals(list.count, all.size.toLong()) - } - } - - @Test - fun validateCursorChange() { - databaseForTable { - (0..9).forEach { - SimpleModel("$it").save() - } - - val list = (select from SimpleModel::class).cursorList(this) - - val listener = mock>() - list.addOnCursorRefreshListener(listener) - assertEquals(10, list.count) - SimpleModel("10").save() - list.refresh() - assertEquals(11, list.count) - - verify(listener).onCursorRefreshed(list) - - list.removeOnCursorRefreshListener(listener) - - list.refresh() - verify(listener, times(1)).onCursorRefreshed(list) - } - } -} - diff --git a/tests/src/test/java/com/raizlabs/dbflow5/runtime/DirectNotifierTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/runtime/DirectNotifierTest.kt deleted file mode 100644 index 683665faf..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/runtime/DirectNotifierTest.kt +++ /dev/null @@ -1,94 +0,0 @@ -package com.raizlabs.dbflow5.runtime - -import android.content.Context -import com.nhaarman.mockito_kotlin.mock -import com.nhaarman.mockito_kotlin.verify -import com.raizlabs.dbflow5.ImmediateTransactionManager2 -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.config.DatabaseConfig -import com.raizlabs.dbflow5.config.FlowConfig -import com.raizlabs.dbflow5.config.FlowManager -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.database.AndroidSQLiteOpenHelper -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.query.columnValues -import com.raizlabs.dbflow5.query.delete -import com.raizlabs.dbflow5.query.insert -import com.raizlabs.dbflow5.query.set -import com.raizlabs.dbflow5.query.update -import com.raizlabs.dbflow5.structure.ChangeAction -import com.raizlabs.dbflow5.structure.delete -import com.raizlabs.dbflow5.structure.insert -import com.raizlabs.dbflow5.structure.save -import com.raizlabs.dbflow5.structure.update -import org.junit.After -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mockito -import org.robolectric.RobolectricTestRunner -import org.robolectric.RuntimeEnvironment -import org.robolectric.annotation.Config - -@RunWith(RobolectricTestRunner::class) -@Config(manifest = Config.NONE) -class DirectNotifierTest { - - val context: Context - get() = RuntimeEnvironment.application - - @Before - fun setupTest() { - FlowManager.init(FlowConfig.Builder(context) - .database(DatabaseConfig.Builder(TestDatabase::class.java, - AndroidSQLiteOpenHelper.createHelperCreator(context)) - .transactionManagerCreator(::ImmediateTransactionManager2) - .build()).build()) - } - - @Test - fun validateCanNotifyDirect() { - val simpleModel = SimpleModel("Name") - - val modelChange = mock>() - DirectModelNotifier.get().registerForModelStateChanges(SimpleModel::class.java, modelChange) - - simpleModel.insert() - verify(modelChange).onModelChanged(simpleModel, ChangeAction.INSERT) - - simpleModel.update() - verify(modelChange).onModelChanged(simpleModel, ChangeAction.UPDATE) - - simpleModel.save() - verify(modelChange).onModelChanged(simpleModel, ChangeAction.CHANGE) - - simpleModel.delete() - verify(modelChange).onModelChanged(simpleModel, ChangeAction.DELETE) - } - - @Test - fun validateCanNotifyWrapperClasses() { - databaseForTable { - val modelChange = Mockito.mock(OnTableChangedListener::class.java) - DirectModelNotifier.get().registerForTableChanges(SimpleModel::class.java, modelChange) - - insert().columnValues(SimpleModel_Table.name to "name").executeInsert(this) - - verify(modelChange).onTableChanged(SimpleModel::class.java, ChangeAction.INSERT) - - (update() set SimpleModel_Table.name.eq("name2")).executeUpdateDelete(this) - - verify(modelChange).onTableChanged(SimpleModel::class.java, ChangeAction.UPDATE) - - delete().executeUpdateDelete(this) - - verify(modelChange).onTableChanged(SimpleModel::class.java, ChangeAction.DELETE) - } - } - - @After - fun teardown() { - FlowManager.destroy() - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/rx2/TransactionObservablesTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/rx2/TransactionObservablesTest.kt deleted file mode 100644 index 5c3d6f451..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/rx2/TransactionObservablesTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -package com.raizlabs.dbflow5.rx2 - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.config.database -import com.raizlabs.dbflow5.database.DatabaseWrapper -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.list -import com.raizlabs.dbflow5.query.result -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.reactivestreams.transaction.asMaybe -import com.raizlabs.dbflow5.reactivestreams.transaction.asSingle -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * Description: - */ -class TransactionObservablesTest : BaseUnitTest() { - - @Test - fun testObservableRun() { - var successCalled = false - var list: List? = null - database() - .beginTransactionAsync { db: DatabaseWrapper -> - (0 until 10).forEach { - SimpleModel("$it").save(db) - } - } - .asSingle() - .doAfterSuccess { - database() - .beginTransactionAsync { (select from SimpleModel::class).list } - .asSingle() - .subscribe { loadedList: MutableList -> - list = loadedList - successCalled = true - } - }.subscribe() - - assertTrue(successCalled) - assertEquals(10, list!!.size) - } - - @Test - fun testMaybe() { - var simpleModel: SimpleModel? = SimpleModel() - database() - .beginTransactionAsync { (select from SimpleModel::class).result } - .asMaybe() - .subscribe { - simpleModel = it - } - assertNull(simpleModel) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/CursorResultSubscriberTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/CursorResultSubscriberTest.kt deleted file mode 100644 index 286413352..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/CursorResultSubscriberTest.kt +++ /dev/null @@ -1,88 +0,0 @@ -package com.raizlabs.dbflow5.rx2.query - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.query.insert -import com.raizlabs.dbflow5.query.requireResult -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.reactivestreams.query.queryStreamResults -import com.raizlabs.dbflow5.reactivestreams.transaction.asFlowable -import com.raizlabs.dbflow5.structure.delete -import com.raizlabs.dbflow5.structure.insert -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Test - -class CursorResultSubscriberTest : BaseUnitTest() { - - @Test - fun testCanQueryStreamResults() { - databaseForTable { - (0..9).forEach { SimpleModel("$it").save() } - - var count = 0 - (select from SimpleModel::class) - .queryStreamResults(this) - .subscribe { - count++ - assert(it != null) - } - - assertEquals(10, count) - } - } - - @Test - fun testCanObserveOnTableChangesWithModelOps() { - var count = 0 - (select from SimpleModel::class) - .asFlowable { databaseWrapper, modelQueriable -> modelQueriable.queryList(databaseWrapper) } - .subscribe { - count++ - } - val model = SimpleModel("test") - model.save() - - model.delete() - - model.insert() - - assertEquals(4, count) // once for subscription, 3 for operations - } - - @Test - fun testCanObserveOnTableChangesWithTableOps() { - var count = 0 - var curList: MutableList = arrayListOf() - (select from SimpleModel::class) - .asFlowable { databaseWrapper, modelQueriable -> modelQueriable.queryList(databaseWrapper) } - .subscribe { - curList = it - count++ - } - insert(SimpleModel::class, SimpleModel_Table.name) - .values("test") - .executeInsert(databaseForTable()) - insert(SimpleModel::class, SimpleModel_Table.name) - .values("test1") - .executeInsert(databaseForTable()) - insert(SimpleModel::class, SimpleModel_Table.name) - .values("test2") - .executeInsert(databaseForTable()) - - - assertEquals(3, curList.size) - - val model = (select - from SimpleModel::class - where SimpleModel_Table.name.eq("test")).requireResult - model.delete() - - assertEquals(2, curList.size) - - assertEquals(5, count) // once for subscription, 4 for operations - } - -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/RXFlowableTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/RXFlowableTest.kt deleted file mode 100644 index b6ec090f9..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/RXFlowableTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -package com.raizlabs.dbflow5.rx2.query - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.Author -import com.raizlabs.dbflow5.models.Author_Table -import com.raizlabs.dbflow5.models.Blog -import com.raizlabs.dbflow5.models.Blog_Table -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.query.cast -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.reactivestreams.transaction.asFlowable -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * Description: - */ -class RXFlowableTest : BaseUnitTest() { - - @Test - fun testCanObserveChanges() { - - (0..100).forEach { SimpleModel("$it").save() } - - var list = mutableListOf() - var triggerCount = 0 - val subscription = (select from SimpleModel::class - where cast(SimpleModel_Table.name).asInteger().greaterThan(50)) - .asFlowable { db, modelQueriable -> modelQueriable.queryList(db) } - .subscribe { - list = it - triggerCount += 1 - } - - assertEquals(50, list.size) - subscription.dispose() - - SimpleModel("should not trigger").save() - assertEquals(1, triggerCount) - - } - - @Test - fun testObservesJoinTables() { - val joinOn = Blog_Table.name.withTable() - .eq(Author_Table.first_name.withTable() + " " + Author_Table.last_name.withTable()) - assertEquals("`Blog`.`name`=`Author`.`first_name`+' '+`Author`.`last_name`", joinOn.query) - - var list = mutableListOf() - var calls = 0 - (select from Blog::class - leftOuterJoin Author::class - on joinOn) - .asFlowable { db, modelQueriable -> modelQueriable.queryList(db) } - .subscribe { - calls++ - list = it - } - - val authors = (0 until 10).map { Author(it, firstName = "${it}name", lastName = "${it}last") } - (0 until 10).forEach { Blog(it, name = "${it}name ${it}last", author = authors[it]).save() } - - assertEquals(21, calls) // 1 for initial, 10 for each model object - assertEquals(10, list.size) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/RXQueryTests.kt b/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/RXQueryTests.kt deleted file mode 100644 index eabff4b6d..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/RXQueryTests.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.raizlabs.dbflow5.rx2.query - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.database.DatabaseStatement -import com.raizlabs.dbflow5.database.FlowCursor -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table.name -import com.raizlabs.dbflow5.query.insert -import com.raizlabs.dbflow5.query.property.Property -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.query.selectCountOf -import com.raizlabs.dbflow5.reactivestreams.transaction.asMaybe -import com.raizlabs.dbflow5.reactivestreams.transaction.asSingle -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Test - -class RXQueryTests : BaseUnitTest() { - - @Test - fun testCanQuery() { - SimpleModel("Name").save() - - var cursor: FlowCursor? = null - databaseForTable() - .beginTransactionAsync { (select from SimpleModel::class).cursor(it) } - .asMaybe() - .subscribe { - cursor = it - } - - assertEquals(1, cursor!!.count) - cursor!!.close() - } - - @Test - fun testCanCompileStatement() { - var databaseStatement: DatabaseStatement? = null - databaseForTable() - .beginTransactionAsync { - insert().columnValues(name.`is`("name")).compileStatement(it) - }.asSingle() - .subscribe { statement -> - databaseStatement = statement - } - databaseStatement!!.close() - } - - @Test - fun testCountMethod() { - SimpleModel("name").save() - SimpleModel("name2").save() - var count = 0L - databaseForTable() - .beginTransactionAsync { - (selectCountOf(Property.ALL_PROPERTY) from SimpleModel::class).longValue(it) - } - .asSingle() - .subscribe { value -> - count = value - } - - assertEquals(2, count) - } - - @Test - fun testInsertMethod() { - var count = 0L - databaseForTable() - .beginTransactionAsync { - (insert().columnValues(name.eq("name"))).executeInsert(it) - }.asSingle() - .subscribe { c -> - count = c - } - - assertEquals(1, count) - } - -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/RxModels.kt b/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/RxModels.kt deleted file mode 100644 index 14a7dd23c..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/rx2/query/RxModels.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.raizlabs.dbflow5.rx2.query - -import com.raizlabs.dbflow5.TestDatabase -import com.raizlabs.dbflow5.annotation.PrimaryKey -import com.raizlabs.dbflow5.annotation.Table -import com.raizlabs.dbflow5.reactivestreams.structure.BaseRXModel - - -@Table(database = TestDatabase::class, allFields = true) -class SimpleRXModel(@PrimaryKey var id: String = "") : BaseRXModel() \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/CaseTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/CaseTest.kt deleted file mode 100644 index 77f83bc95..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/CaseTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.query.case -import com.raizlabs.dbflow5.query.caseWhen -import com.raizlabs.dbflow5.query.property.propertyString -import org.junit.Assert.* -import org.junit.Test - -class CaseTest : BaseUnitTest() { - - @Test - fun simpleCaseTest() { - val case = case(propertyString("country")) - .whenever("USA") - .then("Domestic") - .`else`("Foreign") - assertEquals("CASE country WHEN 'USA' THEN 'Domestic' ELSE 'Foreign' END `Country`", - case.end("Country").query.trim()) - assertTrue(case.isEfficientCase) - } - - @Test - fun searchedCaseTest() { - val case = caseWhen(SimpleModel_Table.name.eq("USA")).then("Domestic") - .whenever(SimpleModel_Table.name.eq("CA")).then("Canada") - .`else`("Foreign") - assertEquals("CASE WHEN `name`='USA' THEN 'Domestic' WHEN `name`='CA' THEN 'Canada' ELSE 'Foreign'", - case.query.trim()) - assertFalse(case.isEfficientCase) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/DeleteTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/DeleteTest.kt deleted file mode 100644 index b1b5efb8d..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/DeleteTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.query.delete -import com.raizlabs.dbflow5.query.list -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.structure.save -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Test - -class DeleteTest : BaseUnitTest() { - - @Test - fun validateQuery() { - databaseForTable { - assertEquals("DELETE ", delete().query) - } - } - - @Test - fun validateDeletion() { - databaseForTable { - SimpleModel("name").save() - delete().execute(this) - assertFalse((select from SimpleModel::class).hasData(this)) - } - } - - @Test - fun validateDeletionWithQuery() { - databaseForTable { - SimpleModel("name").save() - SimpleModel("another name").save() - - val where = delete().where(SimpleModel_Table.name.`is`("name")) - assertEquals("DELETE FROM `SimpleModel` WHERE `name`='name'", where.query.trim()) - where.execute(this) - - assertEquals(1, (select from SimpleModel::class).list.size) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/ExistenceOperatorTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/ExistenceOperatorTest.kt deleted file mode 100644 index 9ca031d56..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/ExistenceOperatorTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.query.ExistenceOperator -import com.raizlabs.dbflow5.query.select -import org.junit.Assert.assertEquals -import org.junit.Test - -class ExistenceOperatorTest : BaseUnitTest() { - - - @Test - fun validateQuery() { - databaseForTable { - assertEquals("EXISTS (SELECT * FROM `SimpleModel` WHERE `name`='name')", - ExistenceOperator( - (select from SimpleModel::class - where SimpleModel_Table.name.eq("name"))) - .query.trim()) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/FromTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/FromTest.kt deleted file mode 100644 index 9b856d472..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/FromTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table.name -import com.raizlabs.dbflow5.models.TwoColumnModel -import com.raizlabs.dbflow5.models.TwoColumnModel_Table -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.id -import com.raizlabs.dbflow5.query.select -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test - -class FromTest : BaseUnitTest() { - - @Test - fun validateSimpleFrom() { - assertEquals("SELECT * FROM `SimpleModel`", (select from SimpleModel::class).query.trim()) - } - - @Test - fun validateProjectionFrom() { - assertEquals("SELECT `name` FROM `SimpleModel`", (select(name) from SimpleModel::class).query.trim()) - } - - @Test - fun validateMultipleProjection() { - assertEquals("SELECT `name`,`name`,`id` FROM `SimpleModel`", - (select(name, TwoColumnModel_Table.name, id) from SimpleModel::class).query.trim()) - } - - @Test - fun validateAlias() { - assertEquals("SELECT * FROM `SimpleModel` AS `Simple`", (select from SimpleModel::class `as` "Simple").query.trim()) - } - - @Test - fun validateJoins() { - val from = (select from SimpleModel::class - innerJoin TwoColumnModel::class - on name.eq(TwoColumnModel_Table.name.withTable())) - assertEquals("SELECT * FROM `SimpleModel` INNER JOIN `TwoColumnModel` ON `name`=`TwoColumnModel`.`name`", - from.query.trim()) - assertTrue(from.associatedTables.isNotEmpty()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/IndexTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/IndexTest.kt deleted file mode 100644 index f6c8f6a19..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/IndexTest.kt +++ /dev/null @@ -1,38 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.query.indexOn -import com.raizlabs.dbflow5.query.nameAlias -import org.junit.Assert.assertEquals -import org.junit.Test - -class IndexTest : BaseUnitTest() { - - @Test - fun validateBasicIndex() { - databaseForTable { - assertEquals("CREATE INDEX IF NOT EXISTS `index` ON `SimpleModel`(`name`)", - indexOn("index", SimpleModel_Table.name).query) - } - } - - @Test - fun validateUniqueIndex() { - databaseForTable { - assertEquals("CREATE UNIQUE INDEX IF NOT EXISTS `index` ON `SimpleModel`(`name`, `test`)", - indexOn("index").unique(true).and(SimpleModel_Table.name) - .and("test".nameAlias).query) - } - } - - @Test - fun validateBasicIndexNameAlias() { - databaseForTable { - assertEquals("CREATE INDEX IF NOT EXISTS `index` ON `SimpleModel`(`name`, `test`)", - indexOn("index", "name".nameAlias, "test".nameAlias).query) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/IndexedByTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/IndexedByTest.kt deleted file mode 100644 index 6b776f666..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/IndexedByTest.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.query.property.IndexProperty -import com.raizlabs.dbflow5.query.select -import org.junit.Assert.assertEquals -import org.junit.Test - -class IndexedByTest : BaseUnitTest() { - - @Test - fun validateQuery() { - databaseForTable { - val indexed = (select from SimpleModel::class) - .indexedBy(IndexProperty("Index", false, SimpleModel::class.java, SimpleModel_Table.name)) - assertEquals("SELECT * FROM `SimpleModel` INDEXED BY `Index`", indexed.query.trim()) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/InsertTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/InsertTest.kt deleted file mode 100644 index 96b97c4f5..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/InsertTest.kt +++ /dev/null @@ -1,95 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import android.content.ContentValues -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.database.set -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.TwoColumnModel -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.id -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.name -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.Operator -import com.raizlabs.dbflow5.query.OperatorGroup -import com.raizlabs.dbflow5.query.insert -import com.raizlabs.dbflow5.query.select -import org.junit.Assert.assertEquals -import org.junit.Test - -class InsertTest : BaseUnitTest() { - - @Test - fun validateInsert() { - databaseForTable { - assertEquals("INSERT INTO `SimpleModel` VALUES('something')", - insert().values("something").query.trim()) - } - } - - @Test - fun validateInsertOr() { - databaseForTable { - assertEquals("INSERT OR REPLACE INTO `SimpleModel` VALUES('something')", - insert().orReplace().values("something").query.trim()) - assertEquals("INSERT OR FAIL INTO `SimpleModel` VALUES('something')", - insert().orFail().values("something").query.trim()) - assertEquals("INSERT OR IGNORE INTO `SimpleModel` VALUES('something')", - insert().orIgnore().values("something").query.trim()) - assertEquals("INSERT OR REPLACE INTO `SimpleModel` VALUES('something')", - insert().orReplace().values("something").query.trim()) - assertEquals("INSERT OR ROLLBACK INTO `SimpleModel` VALUES('something')", - insert().orRollback().values("something").query.trim()) - assertEquals("INSERT OR ABORT INTO `SimpleModel` VALUES('something')", - insert().orAbort().values("something").query.trim()) - } - } - - @Test - fun validateInsertProjection() { - databaseForTable { - assertEquals("INSERT INTO `TwoColumnModel`(`name`, `id`) VALUES('name', 'id')", - insert().columns(name, id).values("name", "id").query.trim()) - } - } - - @Test - fun validateSelect() { - databaseForTable { - assertEquals("INSERT INTO `TwoColumnModel` SELECT * FROM `SimpleModel`", - insert().select(select from SimpleModel::class).query.trim()) - } - } - - @Test - fun validateColumns() { - databaseForTable { - assertEquals("INSERT INTO `TwoColumnModel`(`name`, `id`) VALUES('name', 'id')", - insert().asColumns().values("name", "id").query.trim()) - assertEquals("INSERT INTO `TwoColumnModel`(`name`, `id`) VALUES('name', 'id')", - insert().columns("name", "id").values("name", "id").query.trim()) - assertEquals("INSERT INTO `TwoColumnModel`(`name`, `id`) VALUES('name', 'id')", - insert().columns(listOf(name, id)).values("name", "id").query.trim()) - } - } - - @Test - fun validateColumnValues() { - databaseForTable { - assertEquals("INSERT INTO `TwoColumnModel`(`name`, `id`) VALUES('name', 0)", - insert().columnValues(name.eq("name"), id.eq(0)).query.trim()) - assertEquals("INSERT INTO `TwoColumnModel`(`name`, `id`) VALUES('name', 0)", - insert().columnValues(Operator.op(NameAlias.builder("name").build()).eq("name"), - id.eq(0)).query.trim()) - assertEquals("INSERT INTO `TwoColumnModel`(`name`, `id`) VALUES('name', 0)", - insert().columnValues(OperatorGroup.clause().andAll(name.eq("name"), id.eq(0))).query.trim()) - - val contentValues = ContentValues() - contentValues["name"] = "name" - contentValues["id"] = 0.toInt() - - assertEquals("INSERT INTO `TwoColumnModel`(`name`, `id`) VALUES('name', 0)", - insert().columnValues(contentValues).query.trim()) - - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/JoinTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/JoinTest.kt deleted file mode 100644 index a1f93ed7f..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/JoinTest.kt +++ /dev/null @@ -1,86 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.models.TwoColumnModel -import com.raizlabs.dbflow5.models.TwoColumnModel_Table -import com.raizlabs.dbflow5.query.select -import org.junit.Assert.assertEquals -import org.junit.Test - - -class JoinTest : BaseUnitTest() { - - @Test - fun validateAliasJoin() { - databaseForTable { - assertEquals("SELECT * FROM `SimpleModel` INNER JOIN `TwoColumnModel` AS `Name` ON `TwoColumnModel`.`name`=`name`", - ((select from SimpleModel::class innerJoin - TwoColumnModel::class).`as`("Name") on TwoColumnModel_Table.name.withTable().eq(SimpleModel_Table.name)).query.trim()) - } - } - - @Test - fun testInnerJoin() { - databaseForTable { - val join = select from SimpleModel::class innerJoin - TwoColumnModel::class on TwoColumnModel_Table.name.withTable().eq(SimpleModel_Table.name) - assertEquals("SELECT * FROM `SimpleModel` INNER JOIN `TwoColumnModel` ON `TwoColumnModel`.`name`=`name`", - join.query.trim()) - } - } - - @Test - fun testLeftOuterJoin() { - databaseForTable { - val join = select from SimpleModel::class leftOuterJoin - TwoColumnModel::class on TwoColumnModel_Table.name.withTable().eq(SimpleModel_Table.name) - assertEquals("SELECT * FROM `SimpleModel` LEFT OUTER JOIN `TwoColumnModel` ON `TwoColumnModel`.`name`=`name`", - join.query.trim()) - } - } - - @Test - fun testCrossJoin() { - databaseForTable { - val join = select from SimpleModel::class crossJoin - TwoColumnModel::class on TwoColumnModel_Table.name.withTable().eq(SimpleModel_Table.name) - assertEquals("SELECT * FROM `SimpleModel` CROSS JOIN `TwoColumnModel` ON `TwoColumnModel`.`name`=`name`", - join.query.trim()) - } - } - - @Test - fun testMultiJoin() { - databaseForTable { - val join = select from SimpleModel::class innerJoin - TwoColumnModel::class on TwoColumnModel_Table.name.withTable().eq(SimpleModel_Table.name) crossJoin - TwoColumnModel::class on TwoColumnModel_Table.id.withTable().eq(SimpleModel_Table.name) - assertEquals("SELECT * FROM `SimpleModel` INNER JOIN `TwoColumnModel` ON `TwoColumnModel`.`name`=`name`" + - " CROSS JOIN `TwoColumnModel` ON `TwoColumnModel`.`id`=`name`", - join.query.trim()) - } - } - - @Test - fun testInnerJoinOnUsing() { - databaseForTable { - val join = select from SimpleModel::class innerJoin - TwoColumnModel::class using SimpleModel_Table.name.withTable() - assertEquals("SELECT * FROM `SimpleModel` INNER JOIN `TwoColumnModel` USING (`SimpleModel`.`name`)", - join.query.trim()) - } - } - - @Test - fun testNaturalJoin() { - databaseForTable { - val join = (select from SimpleModel::class naturalJoin - TwoColumnModel::class).end() - assertEquals("SELECT * FROM `SimpleModel` NATURAL JOIN `TwoColumnModel`", - join.query.trim()) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/MethodTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/MethodTest.kt deleted file mode 100644 index 2310c8a44..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/MethodTest.kt +++ /dev/null @@ -1,77 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.id -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.name -import com.raizlabs.dbflow5.query.avg -import com.raizlabs.dbflow5.query.cast -import com.raizlabs.dbflow5.query.count -import com.raizlabs.dbflow5.query.date -import com.raizlabs.dbflow5.query.datetime -import com.raizlabs.dbflow5.query.groupConcat -import com.raizlabs.dbflow5.query.ifNull -import com.raizlabs.dbflow5.query.max -import com.raizlabs.dbflow5.query.min -import com.raizlabs.dbflow5.query.nullIf -import com.raizlabs.dbflow5.query.replace -import com.raizlabs.dbflow5.query.strftime -import com.raizlabs.dbflow5.query.sum -import com.raizlabs.dbflow5.query.total -import com.raizlabs.dbflow5.sql.SQLiteType -import org.junit.Assert.assertEquals -import org.junit.Test - -class MethodTest : BaseUnitTest() { - - @Test - fun testMainMethods() { - assertEquals("AVG(`name`, `id`)", avg(name, id).query) - assertEquals("COUNT(`name`, `id`)", count(name, id).query) - assertEquals("GROUP_CONCAT(`name`, `id`)", groupConcat(name, id).query) - assertEquals("MAX(`name`, `id`)", max(name, id).query) - assertEquals("MIN(`name`, `id`)", min(name, id).query) - assertEquals("SUM(`name`, `id`)", sum(name, id).query) - assertEquals("TOTAL(`name`, `id`)", total(name, id).query) - assertEquals("CAST(`name` AS INTEGER)", cast(name).`as`(SQLiteType.INTEGER).query) - assertEquals("REPLACE(`name`, 'Andrew', 'Grosner')", replace(name, "Andrew", "Grosner").query) - } - - @Test - fun test_strftime() { - assertEquals("strftime('%s', 'now')", strftime("%s", "now").query) - } - - @Test - fun test_dateMethod() { - assertEquals("date('now', 'start of month', '+1 month')", - date("now", "start of month", "+1 month").query) - } - - @Test - fun test_datetimeMethod() { - assertEquals("datetime(1092941466, 'unix epoch')", - datetime(1092941466, "unix epoch").query) - } - - @Test - fun testIfNull() { - assertEquals("IFNULL(`name`, `id`)", ifNull(name, id).query) - } - - @Test - fun testNulllIf() { - assertEquals("NULLIF(`name`, `id`)", nullIf(name, id).query) - } - - @Test - fun testOpMethods() { - assertEquals("AVG(`name` + `id`)", avg(name + id).query) - assertEquals("AVG(`name` + `id`)", (avg(name) + id).query) - assertEquals("AVG(`name` - `id`)", avg(name - id).query) - assertEquals("AVG(`name` - `id`)", (avg(name) - id).query) - assertEquals("AVG(`name` / `id`)", avg(name / id).query) - assertEquals("AVG(`name` * `id`)", (avg(name) * id).query) - assertEquals("AVG(`name` % `id`)", avg(name % id).query) - assertEquals("AVG(`name` % `id`)", (avg(name) % id).query) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/NameAliasTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/NameAliasTest.kt deleted file mode 100644 index 5688d8c60..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/NameAliasTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.`as` -import com.raizlabs.dbflow5.query.nameAlias -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Test - -class NameAliasTest : BaseUnitTest() { - - @Test - fun testSimpleCase() { - assertEquals("`name`", "name".nameAlias.query) - } - - @Test - fun testAlias() { - assertEquals("`name` AS `alias`", "name".`as`("alias").fullQuery) - } - - @Test - fun validateBuilder() { - val nameAlias = NameAlias.builder("name") - .keyword("DISTINCT") - .`as`("Alias") - .withTable("MyTable") - .shouldAddIdentifierToAliasName(false) - .shouldAddIdentifierToName(false) - .shouldStripAliasName(false) - .shouldStripIdentifier(false).build() - assertEquals("DISTINCT", nameAlias.keyword) - assertEquals("Alias", nameAlias.aliasName()) - assertEquals("Alias", nameAlias.aliasNameRaw()) - assertEquals("`MyTable`", nameAlias.tableName) - assertFalse(nameAlias.shouldStripAliasName) - assertFalse(nameAlias.shouldStripIdentifier) - assertEquals("Alias", nameAlias.nameAsKey) - assertEquals("DISTINCT `MyTable`.name AS Alias", nameAlias.fullQuery) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/OperatorGroupTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/OperatorGroupTest.kt deleted file mode 100644 index 43cfed123..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/OperatorGroupTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.assertEquals -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.id -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.name -import com.raizlabs.dbflow5.query.OperatorGroup -import com.raizlabs.dbflow5.query.and -import com.raizlabs.dbflow5.query.andAll -import com.raizlabs.dbflow5.query.or -import com.raizlabs.dbflow5.query.orAll -import org.junit.Test - -class OperatorGroupTest : BaseUnitTest() { - - - @Test - fun validateCommaSeparated() { - "(`name`='name', `id`=0)".assertEquals(OperatorGroup.clause().setAllCommaSeparated(true).andAll(name.eq("name"), id.eq(0))) - } - - @Test - fun validateParanthesis() { - "`name`='name'".assertEquals(OperatorGroup.nonGroupingClause(name.eq("name")).setUseParenthesis(false)) - } - - @Test - fun validateOr() { - "(`name`='name' OR `id`=0)".assertEquals(name.eq("name") or id.eq(0)) - } - - @Test - fun validateOrAll() { - "(`name`='name' OR `id`=0 OR `name`='test')".assertEquals(name.eq("name") orAll arrayListOf(id.eq(0), name.eq("test"))) - } - - @Test - - fun validateAnd() { - "(`name`='name' AND `id`=0)".assertEquals(name.eq("name") and id.eq(0)) - } - - @Test - fun validateAndAll() { - "(`name`='name' AND `id`=0 AND `name`='test')".assertEquals(name.eq("name") andAll arrayListOf(id.eq(0), name.eq("test"))) - } - -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/OperatorTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/OperatorTest.kt deleted file mode 100644 index c3248a397..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/OperatorTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.annotation.Collate -import com.raizlabs.dbflow5.assertEquals -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.id -import com.raizlabs.dbflow5.query.op -import com.raizlabs.dbflow5.query.select -import org.junit.Test - -class OperatorTest : BaseUnitTest() { - - @Test - fun testEquals() { - "`name`='name'".assertEquals("name".op().eq("name")) - "`name`='name'".assertEquals("name".op().`is`("name")) - } - - @Test - fun testNotEquals() { - "`name`!='name'".assertEquals("name".op().notEq("name")) - "`name`!='name'".assertEquals("name".op().isNot("name")) - } - - @Test - fun testLike() { - "`name` LIKE 'name'".assertEquals("name".op().like("name")) - "`name` NOT LIKE 'name'".assertEquals("name".op().notLike("name")) - "`name` GLOB 'name'".assertEquals("name".op().glob("name")) - } - - @Test - fun testMath() { - "`name`>'name'".assertEquals("name".op().greaterThan("name")) - "`name`>='name'".assertEquals("name".op().greaterThanOrEq("name")) - "`name`<'name'".assertEquals("name".op().lessThan("name")) - "`name`<='name'".assertEquals("name".op().lessThanOrEq("name")) - "`name`+'name'".assertEquals("name".op() + "name") - "`name`-'name'".assertEquals("name".op() - "name") - "`name`/'name'".assertEquals("name".op() / "name") - "`name`*'name'".assertEquals("name".op() * "name") - "`name`%'name'".assertEquals("name".op() % "name") - } - - @Test - fun testCollate() { - "`name` COLLATE NOCASE".assertEquals("name".op() collate Collate.NOCASE) - "`name` COLLATE NOCASE".assertEquals("name".op() collate "NOCASE") - } - - @Test - fun testBetween() { - "`id` BETWEEN 6 AND 7".assertEquals(id.between(6) and 7) - } - - @Test - fun testIn() { - databaseForTable { - "`id` IN (5,6,7,8,9)".assertEquals(id.`in`(5, 6, 7, 8) and 9) - "`id` NOT IN (SELECT * FROM `SimpleModel`)".assertEquals(id.notIn(select from SimpleModel::class)) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/OrderByTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/OrderByTest.kt deleted file mode 100644 index 8fb7eef24..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/OrderByTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.annotation.Collate -import com.raizlabs.dbflow5.assertEquals -import com.raizlabs.dbflow5.models.SimpleModel_Table.name -import com.raizlabs.dbflow5.query.OrderBy -import com.raizlabs.dbflow5.query.collate -import com.raizlabs.dbflow5.query.nameAlias -import org.junit.Test - -class OrderByTest : BaseUnitTest() { - - - @Test - fun validateBasicOrderBy() { - "`name` ASC".assertEquals(OrderBy.fromProperty(name).ascending()) - } - - @Test - fun validateDescendingOrderBy() { - "`name` DESC".assertEquals(OrderBy.fromNameAlias("name".nameAlias).descending()) - } - - @Test - fun validateCollate() { - "`name` COLLATE RTRIM ASC".assertEquals(OrderBy.fromProperty(name).ascending() collate Collate.RTRIM) - } - - @Test - fun validateCustomOrdrBy() { - "`name` ASC This is custom".assertEquals(OrderBy.fromString("`name` ASC This is custom")) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/SelectTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/SelectTest.kt deleted file mode 100644 index c748fc61f..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/SelectTest.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.assertEquals -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.TwoColumnModel -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.id -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.name -import com.raizlabs.dbflow5.query.select -import org.junit.Test - -class SelectTest : BaseUnitTest() { - - @Test - fun validateSelect() { - databaseForTable { - "SELECT `name`,`id` FROM `TwoColumnModel`".assertEquals(select(name, id) from TwoColumnModel::class) - } - } - - @Test - fun validateSelectDistinct() { - databaseForTable { - "SELECT DISTINCT `name` FROM `SimpleModel`".assertEquals(select(name).distinct() from SimpleModel::class) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/SetTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/SetTest.kt deleted file mode 100644 index 182a6a105..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/SetTest.kt +++ /dev/null @@ -1,28 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.assertEquals -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table.name -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.id -import com.raizlabs.dbflow5.query.set -import com.raizlabs.dbflow5.query.update -import org.junit.Test - -class SetTest : BaseUnitTest() { - - @Test - fun validateSetWithConditions() { - databaseForTable { - "UPDATE `SimpleModel` SET `name`='name'".assertEquals(update() set name.`is`("name")) - } - } - - @Test - fun validateMultipleConditions() { - databaseForTable { - "UPDATE `SimpleModel` SET `name`='name', `id`=0".assertEquals(update() set name.eq("name") and id.eq(0)) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/TriggerTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/TriggerTest.kt deleted file mode 100644 index 8a5949f8c..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/TriggerTest.kt +++ /dev/null @@ -1,69 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.assertEquals -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table.name -import com.raizlabs.dbflow5.models.TwoColumnModel -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.id -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.cast -import com.raizlabs.dbflow5.query.columnValues -import com.raizlabs.dbflow5.query.createTempTrigger -import com.raizlabs.dbflow5.query.createTrigger -import com.raizlabs.dbflow5.query.insert -import com.raizlabs.dbflow5.query.insertOn -import com.raizlabs.dbflow5.query.property.property -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.query.updateOn -import com.raizlabs.dbflow5.sql.SQLiteType -import com.raizlabs.dbflow5.structure.insert -import org.junit.Assert.assertNotNull -import org.junit.Test - -class TriggerTest : BaseUnitTest() { - - @Test - fun validateBasicTrigger() { - databaseForTable { - ("CREATE TRIGGER IF NOT EXISTS `MyTrigger` AFTER INSERT ON `SimpleModel` " + - "\nBEGIN" + - "\nINSERT INTO `TwoColumnModel`(`name`) VALUES(`new`.`name`);" + - "\nEND").assertEquals(createTrigger("MyTrigger").after() insertOn SimpleModel::class begin - insert(TwoColumnModel::class).columnValues(name to NameAlias.ofTable("new", "name"))) - } - } - - @Test - fun validateUpdateTriggerMultiline() { - databaseForTable { - ("CREATE TEMP TRIGGER IF NOT EXISTS `MyTrigger` BEFORE UPDATE ON `SimpleModel` " + - "\nBEGIN" + - "\nINSERT INTO `TwoColumnModel`(`name`) VALUES(`new`.`name`);" + - "\nINSERT INTO `TwoColumnModel`(`id`) VALUES(CAST(`new`.`name` AS INTEGER));" + - "\nEND") - .assertEquals( - ( - createTempTrigger("MyTrigger").before() updateOn SimpleModel::class - begin - insert(TwoColumnModel::class, name).values(NameAlias.ofTable("new", "name")) - and - insert(TwoColumnModel::class, id).values( - cast(NameAlias.ofTable("new", "name").property).`as`(SQLiteType.INTEGER)))) - } - } - - @Test - fun validateTriggerWorks() { - databaseForTable { - val trigger = createTrigger("MyTrigger").after() insertOn SimpleModel::class begin - insert(TwoColumnModel::class).columnValues(name to NameAlias.ofTable("new", "name")) - trigger.enable(this) - SimpleModel("Test").insert() - - val result = select from TwoColumnModel::class where (name eq "Test") - assertNotNull(result) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/UnsafeStringOperatorTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/UnsafeStringOperatorTest.kt deleted file mode 100644 index c7d233120..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/UnsafeStringOperatorTest.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.assertEquals -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.UnSafeStringOperator -import com.raizlabs.dbflow5.query.select -import org.junit.Test - -class UnsafeStringOperatorTest : BaseUnitTest() { - - @Test - fun testCanIncludeInQuery() { - databaseForTable { - val op = UnSafeStringOperator("name = ?, id = ?, test = ?", arrayOf("'name'", "0", "'test'")) - "name = 'name', id = 0, test = 'test'".assertEquals(op) - "SELECT * FROM `SimpleModel` WHERE name = 'name', id = 0, test = 'test'".assertEquals(select from SimpleModel::class where op) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/UpdateTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/UpdateTest.kt deleted file mode 100644 index 2724e0e3b..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/UpdateTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.annotation.ConflictAction -import com.raizlabs.dbflow5.assertEquals -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.NumberModel -import com.raizlabs.dbflow5.models.NumberModel_Table.id -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table.name -import com.raizlabs.dbflow5.query.property.Property -import com.raizlabs.dbflow5.query.set -import com.raizlabs.dbflow5.query.update -import org.junit.Test - -class UpdateTest : BaseUnitTest() { - - @Test - fun validateUpdateRollback() { - databaseForTable { - "UPDATE OR ROLLBACK `SimpleModel`".assertEquals(update().orRollback()) - } - } - - @Test - fun validateUpdateFail() { - databaseForTable { - "UPDATE OR FAIL `SimpleModel`".assertEquals(update().orFail()) - } - } - - @Test - fun validateUpdateIgnore() { - databaseForTable { - "UPDATE OR IGNORE `SimpleModel`".assertEquals(update().orIgnore()) - } - } - - @Test - fun validateUpdateReplace() { - databaseForTable { - "UPDATE OR REPLACE `SimpleModel`".assertEquals(update().orReplace()) - } - } - - @Test - fun validateUpdateAbort() { - databaseForTable { - "UPDATE OR ABORT `SimpleModel`".assertEquals(update().orAbort()) - } - } - - @Test - fun validateSetQuery() { - databaseForTable { - "UPDATE `SimpleModel` SET `name`='name'".assertEquals(update() set (name eq "name")) - } - } - - @Test - fun validateWildcardQuery() { - databaseForTable { - "UPDATE OR FAIL `NumberModel` SET `id`=? WHERE `id`=?".assertEquals(update().or(ConflictAction.FAIL) - .set(id.eq(Property.WILDCARD)) - .where(id.eq(Property.WILDCARD))) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/WhereTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/WhereTest.kt deleted file mode 100644 index f987c406f..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/WhereTest.kt +++ /dev/null @@ -1,180 +0,0 @@ -package com.raizlabs.dbflow5.sql.language - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.assertEquals -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table.name -import com.raizlabs.dbflow5.models.TwoColumnModel -import com.raizlabs.dbflow5.models.TwoColumnModel_Table.id -import com.raizlabs.dbflow5.query.OrderBy.Companion.fromNameAlias -import com.raizlabs.dbflow5.query.Where -import com.raizlabs.dbflow5.query.groupBy -import com.raizlabs.dbflow5.query.having -import com.raizlabs.dbflow5.query.list -import com.raizlabs.dbflow5.query.nameAlias -import com.raizlabs.dbflow5.query.or -import com.raizlabs.dbflow5.query.result -import com.raizlabs.dbflow5.query.select -import com.raizlabs.dbflow5.query.update -import org.junit.Assert.assertTrue -import org.junit.Assert.fail -import org.junit.Test - -class WhereTest : BaseUnitTest() { - - @Test - fun validateBasicWhere() { - databaseForTable { - val query = select from SimpleModel::class where name.`is`("name") - "SELECT * FROM `SimpleModel` WHERE `name`='name'".assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateComplexQueryWhere() { - databaseForTable { - val query = select from SimpleModel::class where name.`is`("name") or id.eq(1) and (id.`is`(0) or name.eq("hi")) - "SELECT * FROM `SimpleModel` WHERE `name`='name' OR `id`=1 AND (`id`=0 OR `name`='hi')".assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateGroupBy() { - databaseForTable { - val query = select from SimpleModel::class where name.`is`("name") groupBy name - "SELECT * FROM `SimpleModel` WHERE `name`='name' GROUP BY `name`".assertEquals(query) - assertCanCopyQuery(query) - - } - } - - @Test - fun validateGroupByNameAlias() { - databaseForTable { - val query = (select from SimpleModel::class where name.`is`("name")).groupBy("name".nameAlias, "id".nameAlias) - "SELECT * FROM `SimpleModel` WHERE `name`='name' GROUP BY `name`,`id`".assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateGroupByNameProps() { - databaseForTable { - val query = (select from SimpleModel::class where name.`is`("name")).groupBy(name, id) - "SELECT * FROM `SimpleModel` WHERE `name`='name' GROUP BY `name`,`id`".assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateHaving() { - databaseForTable { - val query = select from SimpleModel::class where name.`is`("name") having name.like("That") - "SELECT * FROM `SimpleModel` WHERE `name`='name' HAVING `name` LIKE 'That'".assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateLimit() { - databaseForTable { - val query = select from SimpleModel::class where name.`is`("name") limit 10 - "SELECT * FROM `SimpleModel` WHERE `name`='name' LIMIT 10".assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateOffset() { - databaseForTable { - val query = select from SimpleModel::class where name.`is`("name") offset 10 - "SELECT * FROM `SimpleModel` WHERE `name`='name' OFFSET 10".assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateWhereExists() { - databaseForTable { - val query = (select from SimpleModel::class - whereExists (select(name) from SimpleModel::class where name.like("Andrew"))) - ("SELECT * FROM `SimpleModel` " + - "WHERE EXISTS (SELECT `name` FROM `SimpleModel` WHERE `name` LIKE 'Andrew')").assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateOrderByWhere() { - databaseForTable { - val query = (select from SimpleModel::class - where name.eq("name")).orderBy(name, true) - ("SELECT * FROM `SimpleModel` WHERE `name`='name' ORDER BY `name` ASC").assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateOrderByWhereAlias() { - databaseForTable { - val query = (select from SimpleModel::class - where name.eq("name")).orderBy("name".nameAlias, true) - ("SELECT * FROM `SimpleModel` " + - "WHERE `name`='name' ORDER BY `name` ASC").assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateOrderBy() { - databaseForTable { - val query = (select from SimpleModel::class - where name.eq("name") orderBy fromNameAlias("name".nameAlias).ascending()) - ("SELECT * FROM `SimpleModel` " + - "WHERE `name`='name' ORDER BY `name` ASC").assertEquals(query) - assertCanCopyQuery(query) - } - } - - private fun assertCanCopyQuery(query: Where) { - val actual = query.cloneSelf() - query.assertEquals(actual) - assertTrue(actual !== query) - } - - @Test - fun validateOrderByAll() { - databaseForTable { - val query = (select from TwoColumnModel::class - where name.eq("name")) - .orderByAll(listOf( - fromNameAlias("name".nameAlias).ascending(), - fromNameAlias("id".nameAlias).descending())) - ("SELECT * FROM `TwoColumnModel` " + - "WHERE `name`='name' ORDER BY `name` ASC,`id` DESC").assertEquals(query) - assertCanCopyQuery(query) - } - } - - @Test - fun validateNonSelectThrowError() { - databaseForTable { - try { - update().set(name.`is`("name")).result - fail("Non select passed") - } catch (i: IllegalArgumentException) { - // expected - } - - try { - update().set(name.`is`("name")).list - fail("Non select passed") - } catch (i: IllegalArgumentException) { - // expected - } - } - } -} diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/BytePropertyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/BytePropertyTest.kt deleted file mode 100644 index 563bf32c7..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/BytePropertyTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.property.Property -import org.junit.Assert.assertEquals -import org.junit.Test - -class BytePropertyTest : BaseUnitTest() { - - @Test - fun testOperators() { - val prop = Property(SimpleModel::class.java, "Prop") - assertEquals("`Prop`=5", prop.`is`(5).query.trim()) - assertEquals("`Prop`=5", prop.eq(5).query.trim()) - assertEquals("`Prop`!=5", prop.notEq(5).query.trim()) - assertEquals("`Prop`!=5", prop.isNot(5).query.trim()) - assertEquals("`Prop`>5", prop.greaterThan(5).query.trim()) - assertEquals("`Prop`>=5", prop.greaterThanOrEq(5).query.trim()) - assertEquals("`Prop`<5", prop.lessThan(5).query.trim()) - assertEquals("`Prop`<=5", prop.lessThanOrEq(5).query.trim()) - assertEquals("`Prop` BETWEEN 5 AND 6", prop.between(5).and(6).query.trim()) - assertEquals("`Prop` IN (5,6,7,8)", prop.`in`(5, 6, 7, 8).query.trim()) - assertEquals("`Prop` NOT IN (5,6,7,8)", prop.notIn(5, 6, 7, 8).query.trim()) - assertEquals("`Prop`=`Prop` + 5", prop.concatenate(5).query.trim()) - } - - @Test - fun testAlias() { - val prop = Property(SimpleModel::class.java, "Prop", "Alias") - assertEquals("`Prop` AS `Alias`", prop.toString().trim()) - - val prop2 = Property(SimpleModel::class.java, - NameAlias.builder("Prop") - .shouldAddIdentifierToName(false) - .`as`("Alias") - .shouldAddIdentifierToAliasName(false) - .build()) - assertEquals("Prop AS Alias", prop2.toString().trim()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/CharPropertyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/CharPropertyTest.kt deleted file mode 100644 index b959d2f25..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/CharPropertyTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.property.Property -import org.junit.Assert.assertEquals -import org.junit.Test - -class CharPropertyTest : BaseUnitTest() { - - @Test - fun testOperators() { - val prop = Property(SimpleModel::class.java, "Prop") - assertEquals("`Prop`='5'", prop.`is`('5').query.trim()) - assertEquals("`Prop`='5'", prop.eq('5').query.trim()) - assertEquals("`Prop`!='5'", prop.notEq('5').query.trim()) - assertEquals("`Prop`!='5'", prop.isNot('5').query.trim()) - assertEquals("`Prop`>'5'", prop.greaterThan('5').query.trim()) - assertEquals("`Prop`>='5'", prop.greaterThanOrEq('5').query.trim()) - assertEquals("`Prop`<'5'", prop.lessThan('5').query.trim()) - assertEquals("`Prop`<='5'", prop.lessThanOrEq('5').query.trim()) - assertEquals("`Prop` BETWEEN '5' AND '6'", prop.between('5').and('6').query.trim()) - assertEquals("`Prop` IN ('5','6','7','8')", prop.`in`('5', '6', '7', '8').query.trim()) - assertEquals("`Prop` NOT IN ('5','6','7','8')", prop.notIn('5', '6', '7', '8').query.trim()) - assertEquals("`Prop`=`Prop` || '5'", prop.concatenate('5').query.trim()) - } - - @Test - fun testAlias() { - val prop = Property(SimpleModel::class.java, "Prop", "Alias") - assertEquals("`Prop` AS `Alias`", prop.toString().trim()) - - val prop2 = Property(SimpleModel::class.java, - NameAlias.builder("Prop") - .shouldAddIdentifierToName(false) - .`as`("Alias") - .shouldAddIdentifierToAliasName(false) - .build()) - assertEquals("Prop AS Alias", prop2.toString().trim()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/DoublePropertyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/DoublePropertyTest.kt deleted file mode 100644 index e12e4912c..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/DoublePropertyTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.property.Property -import org.junit.Assert.assertEquals -import org.junit.Test - -class DoublePropertyTest : BaseUnitTest() { - - @Test - fun testOperators() { - val prop = Property(SimpleModel::class.java, "Prop") - assertEquals("`Prop`=5.0", prop.`is`(5.0).query.trim()) - assertEquals("`Prop`=5.0", prop.eq(5.0).query.trim()) - assertEquals("`Prop`!=5.0", prop.notEq(5.0).query.trim()) - assertEquals("`Prop`!=5.0", prop.isNot(5.0).query.trim()) - assertEquals("`Prop`>5.0", prop.greaterThan(5.0).query.trim()) - assertEquals("`Prop`>=5.0", prop.greaterThanOrEq(5.0).query.trim()) - assertEquals("`Prop`<5.0", prop.lessThan(5.0).query.trim()) - assertEquals("`Prop`<=5.0", prop.lessThanOrEq(5.0).query.trim()) - assertEquals("`Prop` BETWEEN 5.0 AND 6.0", prop.between(5.0).and(6.0).query.trim()) - assertEquals("`Prop` IN (5.0,6.0,7.0,8.0)", prop.`in`(5.0, 6.0, 7.0, 8.0).query.trim()) - assertEquals("`Prop` NOT IN (5.0,6.0,7.0,8.0)", prop.notIn(5.0, 6.0, 7.0, 8.0).query.trim()) - assertEquals("`Prop`=`Prop` + 5.0", prop.concatenate(5.0).query.trim()) - } - - @Test - fun testAlias() { - val prop = Property(SimpleModel::class.java, "Prop", "Alias") - assertEquals("`Prop` AS `Alias`", prop.toString().trim()) - - val prop2 = Property(SimpleModel::class.java, - NameAlias.builder("Prop") - .shouldAddIdentifierToName(false) - .`as`("Alias") - .shouldAddIdentifierToAliasName(false) - .build()) - assertEquals("Prop AS Alias", prop2.toString().trim()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/FloatPropertyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/FloatPropertyTest.kt deleted file mode 100644 index 348baf360..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/FloatPropertyTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.property.Property -import org.junit.Assert.assertEquals -import org.junit.Test - -class FloatPropertyTest : BaseUnitTest() { - - @Test - fun testOperators() { - val prop = Property(SimpleModel::class.java, "Prop") - assertEquals("`Prop`=5.0", prop.`is`(5f).query.trim()) - assertEquals("`Prop`=5.0", prop.eq(5f).query.trim()) - assertEquals("`Prop`!=5.0", prop.notEq(5f).query.trim()) - assertEquals("`Prop`!=5.0", prop.isNot(5f).query.trim()) - assertEquals("`Prop`>5.0", prop.greaterThan(5f).query.trim()) - assertEquals("`Prop`>=5.0", prop.greaterThanOrEq(5f).query.trim()) - assertEquals("`Prop`<5.0", prop.lessThan(5f).query.trim()) - assertEquals("`Prop`<=5.0", prop.lessThanOrEq(5f).query.trim()) - assertEquals("`Prop` BETWEEN 5.0 AND 6.0", prop.between(5f).and(6f).query.trim()) - assertEquals("`Prop` IN (5.0,6.0,7.0,8.0)", prop.`in`(5f, 6f, 7f, 8f).query.trim()) - assertEquals("`Prop` NOT IN (5.0,6.0,7.0,8.0)", prop.notIn(5f, 6f, 7f, 8f).query.trim()) - assertEquals("`Prop`=`Prop` + 5.0", prop.concatenate(5f).query.trim()) - } - - @Test - fun testAlias() { - val prop = Property(SimpleModel::class.java, "Prop", "Alias") - assertEquals("`Prop` AS `Alias`", prop.toString().trim()) - - val prop2 = Property(SimpleModel::class.java, - NameAlias.builder("Prop") - .shouldAddIdentifierToName(false) - .`as`("Alias") - .shouldAddIdentifierToAliasName(false) - .build()) - assertEquals("Prop AS Alias", prop2.toString().trim()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/IndexPropertyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/IndexPropertyTest.kt deleted file mode 100644 index 419cf934d..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/IndexPropertyTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.models.SimpleModel_Table -import com.raizlabs.dbflow5.query.property.IndexProperty -import org.junit.Assert.assertEquals -import org.junit.Test - -class IndexPropertyTest : BaseUnitTest() { - - - @Test - fun validateIndexProperty() { - databaseForTable { - val prop = IndexProperty("Index", true, SimpleModel::class.java, - SimpleModel_Table.name) - prop.createIfNotExists(this) - prop.drop(this) - assertEquals("`Index`", prop.indexName) - } - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/IntPropertyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/IntPropertyTest.kt deleted file mode 100644 index 04dfe9aa3..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/IntPropertyTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.property.Property -import org.junit.Assert.assertEquals -import org.junit.Test - -class IntPropertyTest : BaseUnitTest() { - - @Test - fun testOperators() { - val prop = Property(SimpleModel::class.java, "Prop") - assertEquals("`Prop`=5", prop.`is`(5).query.trim()) - assertEquals("`Prop`=5", prop.eq(5).query.trim()) - assertEquals("`Prop`!=5", prop.notEq(5).query.trim()) - assertEquals("`Prop`!=5", prop.isNot(5).query.trim()) - assertEquals("`Prop`>5", prop.greaterThan(5).query.trim()) - assertEquals("`Prop`>=5", prop.greaterThanOrEq(5).query.trim()) - assertEquals("`Prop`<5", prop.lessThan(5).query.trim()) - assertEquals("`Prop`<=5", prop.lessThanOrEq(5).query.trim()) - assertEquals("`Prop` BETWEEN 5 AND 6", prop.between(5).and(6).query.trim()) - assertEquals("`Prop` IN (5,6,7,8)", prop.`in`(5, 6, 7, 8).query.trim()) - assertEquals("`Prop` NOT IN (5,6,7,8)", prop.notIn(5, 6, 7, 8).query.trim()) - assertEquals("`Prop`=`Prop` + 5", prop.concatenate(5).query.trim()) - } - - @Test - fun testAlias() { - val prop = Property(SimpleModel::class.java, "Prop", "Alias") - assertEquals("`Prop` AS `Alias`", prop.toString().trim()) - - val prop2 = Property(SimpleModel::class.java, - NameAlias.builder("Prop") - .shouldAddIdentifierToName(false) - .`as`("Alias") - .shouldAddIdentifierToAliasName(false) - .build()) - assertEquals("Prop AS Alias", prop2.toString().trim()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/LongPropertyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/LongPropertyTest.kt deleted file mode 100644 index b9ef8175c..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/LongPropertyTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.property.Property -import org.junit.Assert.assertEquals -import org.junit.Test - -class LongPropertyTest : BaseUnitTest() { - - @Test - fun testOperators() { - val prop = Property(SimpleModel::class.java, "Prop") - assertEquals("`Prop`=5", prop.`is`(5).query.trim()) - assertEquals("`Prop`=5", prop.eq(5).query.trim()) - assertEquals("`Prop`!=5", prop.notEq(5).query.trim()) - assertEquals("`Prop`!=5", prop.isNot(5).query.trim()) - assertEquals("`Prop`>5", prop.greaterThan(5).query.trim()) - assertEquals("`Prop`>=5", prop.greaterThanOrEq(5).query.trim()) - assertEquals("`Prop`<5", prop.lessThan(5).query.trim()) - assertEquals("`Prop`<=5", prop.lessThanOrEq(5).query.trim()) - assertEquals("`Prop` BETWEEN 5 AND 6", prop.between(5).and(6).query.trim()) - assertEquals("`Prop` IN (5,6,7,8)", prop.`in`(5, 6, 7, 8).query.trim()) - assertEquals("`Prop` NOT IN (5,6,7,8)", prop.notIn(5, 6, 7, 8).query.trim()) - assertEquals("`Prop`=`Prop` + 5", prop.concatenate(5).query.trim()) - } - - @Test - fun testAlias() { - val prop = Property(SimpleModel::class.java, "Prop", "Alias") - assertEquals("`Prop` AS `Alias`", prop.toString().trim()) - - val prop2 = Property(SimpleModel::class.java, - NameAlias.builder("Prop") - .shouldAddIdentifierToName(false) - .`as`("Alias") - .shouldAddIdentifierToAliasName(false) - .build()) - assertEquals("Prop AS Alias", prop2.toString().trim()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/PropertyFactoryTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/PropertyFactoryTest.kt deleted file mode 100644 index 672b78786..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/PropertyFactoryTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.config.databaseForTable -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.property.property -import com.raizlabs.dbflow5.query.property.propertyString -import com.raizlabs.dbflow5.query.select -import org.junit.Assert.assertEquals -import org.junit.Test - -class PropertyFactoryTest : BaseUnitTest() { - - @Test - fun testPrimitives() { - assertEquals("'c'", 'c'.property.query) - assertEquals("5", 5.property.query) - assertEquals("5.0", 5.0.property.query) - assertEquals("5.0", 5.0f.property.query) - assertEquals("5", 5L.property.query) - assertEquals("5", 5.toShort().property.query) - assertEquals("5", 5.toByte().property.query) - val nullable: Any? = null - assertEquals("NULL", nullable.property.query) - databaseForTable { - assertEquals("(SELECT * FROM `SimpleModel`)", (select from SimpleModel::class).property.query) - } - assertEquals("SomethingCool", propertyString("SomethingCool").query) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/PropertyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/PropertyTest.kt deleted file mode 100644 index 80aee56b1..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/PropertyTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.property.Property -import org.junit.Assert -import org.junit.Test - -class PropertyTest : BaseUnitTest() { - - @Test - fun testOperators() { - val prop = Property(SimpleModel::class.java, "Prop") - Assert.assertEquals("`Prop`='5'", prop.`is`("5").query.trim()) - Assert.assertEquals("`Prop`='5'", prop.eq("5").query.trim()) - Assert.assertEquals("`Prop`!='5'", prop.notEq("5").query.trim()) - Assert.assertEquals("`Prop`!='5'", prop.isNot("5").query.trim()) - Assert.assertEquals("`Prop` LIKE '5'", prop.like("5").query.trim()) - Assert.assertEquals("`Prop` NOT LIKE '5'", prop.notLike("5").query.trim()) - Assert.assertEquals("`Prop` GLOB '5'", prop.glob("5").query.trim()) - Assert.assertEquals("`Prop`>'5'", prop.greaterThan("5").query.trim()) - Assert.assertEquals("`Prop`>='5'", prop.greaterThanOrEq("5").query.trim()) - Assert.assertEquals("`Prop`<'5'", prop.lessThan("5").query.trim()) - Assert.assertEquals("`Prop`<='5'", prop.lessThanOrEq("5").query.trim()) - Assert.assertEquals("`Prop` BETWEEN '5' AND '6'", prop.between("5").and("6").query.trim()) - Assert.assertEquals("`Prop` IN ('5','6','7','8')", prop.`in`("5", "6", "7", "8").query.trim()) - Assert.assertEquals("`Prop` NOT IN ('5','6','7','8')", prop.notIn("5", "6", "7", "8").query.trim()) - Assert.assertEquals("`Prop`=`Prop` || '5'", prop.concatenate("5").query.trim()) - } - - @Test - fun testAlias() { - val prop = Property(SimpleModel::class.java, "Prop", "Alias") - Assert.assertEquals("`Prop` AS `Alias`", prop.toString().trim()) - - val prop2 = Property(SimpleModel::class.java, - NameAlias.builder("Prop") - .shouldAddIdentifierToName(false) - .`as`("Alias") - .shouldAddIdentifierToAliasName(false) - .build()) - Assert.assertEquals("Prop AS Alias", prop2.toString().trim()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/ShortPropertyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/ShortPropertyTest.kt deleted file mode 100644 index 0e54eb960..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/ShortPropertyTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.property.Property -import org.junit.Assert.assertEquals -import org.junit.Test - -class ShortPropertyTest : BaseUnitTest() { - - @Test - fun testOperators() { - val prop = Property(SimpleModel::class.java, "Prop") - assertEquals("`Prop`=5", prop.`is`(5).query.trim()) - assertEquals("`Prop`=5", prop.eq(5).query.trim()) - assertEquals("`Prop`!=5", prop.notEq(5).query.trim()) - assertEquals("`Prop`!=5", prop.isNot(5).query.trim()) - assertEquals("`Prop`>5", prop.greaterThan(5).query.trim()) - assertEquals("`Prop`>=5", prop.greaterThanOrEq(5).query.trim()) - assertEquals("`Prop`<5", prop.lessThan(5).query.trim()) - assertEquals("`Prop`<=5", prop.lessThanOrEq(5).query.trim()) - assertEquals("`Prop` BETWEEN 5 AND 6", prop.between(5).and(6).query.trim()) - assertEquals("`Prop` IN (5,6,7,8)", prop.`in`(5, 6, 7, 8).query.trim()) - assertEquals("`Prop` NOT IN (5,6,7,8)", prop.notIn(5, 6, 7, 8).query.trim()) - assertEquals("`Prop`=`Prop` + 5", prop.concatenate(5).query.trim()) - } - - @Test - fun testAlias() { - val prop = Property(SimpleModel::class.java, "Prop", "Alias") - assertEquals("`Prop` AS `Alias`", prop.toString().trim()) - - val prop2 = Property(SimpleModel::class.java, - NameAlias.builder("Prop") - .shouldAddIdentifierToName(false) - .`as`("Alias") - .shouldAddIdentifierToAliasName(false) - .build()) - assertEquals("Prop AS Alias", prop2.toString().trim()) - } -} \ No newline at end of file diff --git a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/TypeConvertedPropertyTest.kt b/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/TypeConvertedPropertyTest.kt deleted file mode 100644 index e0c5a0446..000000000 --- a/tests/src/test/java/com/raizlabs/dbflow5/sql/language/property/TypeConvertedPropertyTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.raizlabs.dbflow5.sql.language.property - -import com.raizlabs.dbflow5.BaseUnitTest -import com.raizlabs.dbflow5.converter.DateConverter -import com.raizlabs.dbflow5.converter.TypeConverter -import com.raizlabs.dbflow5.models.Difficulty -import com.raizlabs.dbflow5.models.EnumTypeConverterModel_Table -import com.raizlabs.dbflow5.models.SimpleModel -import com.raizlabs.dbflow5.query.NameAlias -import com.raizlabs.dbflow5.query.property.TypeConvertedProperty -import org.junit.Assert.assertEquals -import org.junit.Test -import java.util.* - -class TypeConvertedPropertyTest : BaseUnitTest() { - - - @Test - fun testTypeConverter() { - val property = TypeConvertedProperty(SimpleModel::class.java, "Prop", true, - object : TypeConvertedProperty.TypeConverterGetter { - override fun getTypeConverter(modelClass: Class<*>): TypeConverter<*, *> = DateConverter() - }) - assertEquals("`Prop`", property.toString()) - - val date = Date() - assertEquals("`Prop`=${date.time}", property.eq(date).query) - - assertEquals("`SimpleModel`.`Prop`=${date.time}", property.withTable().eq(date).query) - - val inverted = property.invertProperty() - assertEquals("`Prop`=5050505", inverted.eq(5050505).query) - } - - @Test - fun testCustomEnumTypeConverter() { - - assertEquals("`difficulty`='H'", EnumTypeConverterModel_Table.difficulty.eq(Difficulty.HARD).query) - assertEquals("`EnumTypeConverterModel`.`difficulty`='H'", EnumTypeConverterModel_Table.difficulty.withTable().eq(Difficulty.HARD).query) - assertEquals("`et`.`difficulty`='H'", EnumTypeConverterModel_Table.difficulty.withTable(NameAlias.tableNameBuilder("et").build()).eq(Difficulty.HARD).query) - } -} \ No newline at end of file diff --git a/usage2/ContentProviderGeneration.md b/usage2/ContentProviderGeneration.md index fd461cb72..fe6f1e601 100644 --- a/usage2/ContentProviderGeneration.md +++ b/usage2/ContentProviderGeneration.md @@ -15,7 +15,7 @@ In order to define a `ContentProvider`, you must define it in a placeholder clas baseContentUri = TestContentProvider.BASE_CONTENT_URI) public class TestContentProvider { - public static final String AUTHORITY = "com.raizlabs.dbflow5.test.provider"; + public static final String AUTHORITY = "com.dbflow5.test.provider"; public static final String BASE_CONTENT_URI = "content://"; @@ -36,7 +36,7 @@ public class TestDatabase { public static final int VERSION = "1"; - public static final String AUTHORITY = "com.raizlabs.dbflow5.test.provider"; + public static final String AUTHORITY = "com.dbflow5.test.provider"; public static final String BASE_CONTENT_URI = "content://"; @@ -49,7 +49,7 @@ In other applications or your current's `AndroidManifest.xml` add the **generate ```xml ``` diff --git a/usage2/Intro.md b/usage2/Intro.md index 39bfafd30..5e06f124f 100644 --- a/usage2/Intro.md +++ b/usage2/Intro.md @@ -63,7 +63,7 @@ Since DBFlow uses annotation processing, which is run pre-proguard phase, the configuration is highly minimal: ``` --keep class * extends com.raizlabs.dbflow5.config.DatabaseHolder { *; } +-keep class * extends com.dbflow5.config.DatabaseHolder { *; } ``` ## Sections diff --git a/usage2/KotlinSupport.md b/usage2/KotlinSupport.md index fde094179..74824a419 100644 --- a/usage2/KotlinSupport.md +++ b/usage2/KotlinSupport.md @@ -2,15 +2,6 @@ DBFlow supports Kotlin out of the box and is fairly easily to use and implement. -To add useful Kotlin-specific extensions: -``` -dependencies { - compile "com.github.Raizlabs.DBFlow:dbflow-kotlinextensions:${dbflow_version}@aar" -} - -``` -We also support [kotlin extensions for RX 1 + 2](RXSupport.md)! - ## Classes DBFlow Classes are beautifully concise to write: diff --git a/usage2/Migrations.md b/usage2/Migrations.md index b9ca5e593..d8a93b87f 100644 --- a/usage2/Migrations.md +++ b/usage2/Migrations.md @@ -105,7 +105,7 @@ For renaming tables, you should rename the `Model` class' `@Table(name = "{newNa this `Migration`. The reason is that DBFlow will know the new name only and the existing database will get caught up on it through this migration. Any new database created on a device will automatically have the new table name. -For adding columns, we only support `SQLiteType` (all supported ones [here](https://www.sqlite.org/datatype3.html)) operations to add or remove columns. This is to enforce that the columns are created properly. If a column needs to be a `TypeConverter` column, use the database value from it. We map the associated type of the database field to a `SQLiteType` in [SQLiteType.java](/dbflow/src/main/java/com/raizlabs/android/dbflow/sql/SQLiteType.java). So if you have a `DateConverter` that specifies a `Date` column converted to `Long`, then you should look up `Long` in the `Map`. In this case `Long` converts to `INTEGER`. +For adding columns, we only support `SQLiteType` (all supported ones [here](https://www.sqlite.org/datatype3.html)) operations to add or remove columns. This is to enforce that the columns are created properly. If a column needs to be a `TypeConverter` column, use the database value from it. We map the associated type of the database field to a `SQLiteType` in [SQLiteType.kt](/dbflow/src/main/java/com/dbflow5/sql/SQLiteType.kt). So if you have a `DateConverter` that specifies a `Date` column converted to `Long`, then you should look up `Long` in the `Map`. In this case `Long` converts to `INTEGER`. ```java diff --git a/usage2/Relationships.md b/usage2/Relationships.md index 6692dc434..48dc2a187 100644 --- a/usage2/Relationships.md +++ b/usage2/Relationships.md @@ -230,7 +230,7 @@ A class can use both: @Table(database = TestDatabase.class) @ManyToMany(referencedTable = TestModel1.class) @MultipleManyToMany({@ManyToMany(referencedTable = TestModel2.class), - @ManyToMany(referencedTable = com.raizlabs.dbflow5.test.sql.TestModel3.class)}) + @ManyToMany(referencedTable = com.dbflow5.test.sql.TestModel3.class)}) public class ManyToManyModel extends BaseModel { @PrimaryKey diff --git a/usage2/TypeConverters.md b/usage2/TypeConverters.md index 31def043a..1b32dee16 100644 --- a/usage2/TypeConverters.md +++ b/usage2/TypeConverters.md @@ -27,7 +27,7 @@ This example creates a `TypeConverter` for a field that is `JSONObject` and conv ```java -@com.raizlabs.dbflow5.annotation.TypeConverter +@com.dbflow5.annotation.TypeConverter public class JSONConverter extends TypeConverter { @Override diff --git a/usage2/including-in-project.md b/usage2/including-in-project.md index 1b58dfa29..ab013a81e 100644 --- a/usage2/including-in-project.md +++ b/usage2/including-in-project.md @@ -6,61 +6,67 @@ DBFlow has a number of artifacts that you can include in the project. **Core:** Contains the main annotations and misc classes that are shared across all of DBFlow. -**DBFlow: **The main library artifact used in conjunction with the previous two artifacts. +**DBFlow:** The main library artifact used in conjunction with the previous two artifacts. -**SCLCipher Support:** Replaces most of inner database interaction with an [Encrypted Database](https://www.zetetic.net/sqlcipher/) that's useful for sensitive information. DBFlow contains wrapper around most of the implementation, so adding it is minimal. +**Coroutines:** Adds coroutine support for queries. -**Kotlin: **DBFlow has Kotlin extensions support for the library, enabling more concise syntax and tons of inline helper methods! Also most of the public library API is annotated with `@Nullable` or `@NonNull`, providing nice interop when used in Kotlin. +**RX Java:** Enable applications to be reactive by listening to DB changes and ensuring your subscribers are up-to-date. -**RXJava: **RX1 and RX2 supported. Wraps around normal DB operations by providing RXJava support for Model CRUD updates and SQLite wrapper language. Also Kotlin extensions exist for RX-specific methods. +**Paging:** Android architecture component paging library support for queries via `QueryDataSource`. + +**SQLCipher:** Easy database encryption support in this library. ### Add the jitpack.io repository This repo is used to publish the artifacts. It also enables [dynamic builds](https://jitpack.io/docs/), allowing you to specify specific branches or commit hashes of the project to include outside of normal releases. -```Groovy +```groovy + allProjects { repositories { + google() // required to find the project's artifacts + // place last maven { url "https://www.jitpack.io" } } } ``` -```Groovy +Add artifacts to your project: - apply plugin: 'kotlin-kapt' // required for Kotlin +```groovy - def dbflow_version = "xxxx" // reference the releases tab on Github for latest versions - // or you can grab a 10-digit commit hash of any commit in the project that builds. + apply plugin: 'kotlin-kapt' // only required for kotlin consumers. + + def dbflow_version = "5.0.0-alpha1" + // or 10-digit short-hash of a specific commit. (Useful for bugs fixed in develop, but not in a release yet) dependencies { - annotationProcessor "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}" - // use kapt for kotlin apt if you're a Kotlin user - kapt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}" + // Use if Kotlin user. + kapt "com.github.agrosner.dbflow:processor:${dbflow_version}" + + // Annotation Processor + // if only using Java, use this. If using Kotlin do NOT use this. + annotationProcessor "com.github.agrosner.dbflow:processor:${dbflow_version}" - compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}" - compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}" + + // core set of libraries + compile "com.github.agrosner.dbflow:core:${dbflow_version}" + compile "com.github.agrosner.dbflow:lib:${dbflow_version}" // sql-cipher database encryption (optional) - compile "com.github.Raizlabs.DBFlow:dbflow-sqlcipher:${dbflow_version}" + compile "com.github.agrosner.dbflow:sqlcipher:${dbflow_version}" compile "net.zetetic:android-database-sqlcipher:${sqlcipher_version}@aar" - // kotlin extensions - compile "com.github.Raizlabs.DBFlow:dbflow-kotlinextensions:${dbflow_version}" - - // RXJava 1 support - compile "com.github.Raizlabs.DBFlow:dbflow-rx:${dbflow_version}" - - // RXJava 1 Kotlin Extensions Support - compile "com.github.Raizlabs.DBFlow:dbflow-rx-kotlinextensions:${dbflow_version}" - // RXJava 2 support - compile "com.github.Raizlabs.DBFlow:dbflow-rx2:${dbflow_version}" + compile "com.github.agrosner.dbflow:reactive-streams:${dbflow_version}" + + // Kotlin Coroutines + compile "com.github.agrosner.dbflow:coroutines:${dbflow_version}" - // RXJava 2 Kotlin Extensions Support - compile "com.github.Raizlabs.DBFlow:dbflow-rx2-kotlinextensions:${dbflow_version}" + // Android Architecture Components Paging Library Support + compile "com.github.agrosner.dbflow:paging:${dbflow_version}" } diff --git a/usage2/proguard.md b/usage2/proguard.md index 3c27c2978..0c40189c3 100644 --- a/usage2/proguard.md +++ b/usage2/proguard.md @@ -3,7 +3,7 @@ Since DBFlow uses annotation processing, which is run pre-proguard phase, the configuration is highly minimal. Also since we combine all generated files into the `GeneratedDatabaseHolder`, any other class generated can be obfuscated. ``` --keep class * extends com.raizlabs.dbflow5.config.DatabaseHolder { *; } +-keep class * extends com.dbflow5.config.DatabaseHolder { *; } ``` This also works on modules from other library projects that use DBFlow.