Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for cross-module object transformers
- Loading branch information
Showing
15 changed files
with
205 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ | |
/captures | ||
**/db | ||
/db | ||
**/debug/assets/*.sql | ||
**/*debug/assets/*.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...bmodule/src/main/java/com/siimkinks/sqlitemagic/another/AnotherSubmoduleDatabaseConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package com.siimkinks.sqlitemagic.another | ||
|
||
import com.siimkinks.sqlitemagic.annotation.SubmoduleDatabase | ||
import com.siimkinks.sqlitemagic.submodule.DbTransformers | ||
|
||
@SubmoduleDatabase("another") | ||
@SubmoduleDatabase("another", externalTransformers = [DbTransformers::class]) | ||
interface AnotherSubmoduleDatabaseConfig |
11 changes: 11 additions & 0 deletions
11
...ubmodule/src/main/java/com/siimkinks/sqlitemagic/another/ModelWithExternalTransformers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.siimkinks.sqlitemagic.another | ||
|
||
import com.siimkinks.sqlitemagic.annotation.Id | ||
import com.siimkinks.sqlitemagic.annotation.Table | ||
import java.util.* | ||
|
||
@Table | ||
data class ModelWithExternalTransformers( | ||
@Id val localId: Long?, | ||
val date: Date | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...magic-tests/submodule/src/main/java/com/siimkinks/sqlitemagic/submodule/DbTransformers.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.siimkinks.sqlitemagic.submodule | ||
|
||
import com.siimkinks.sqlitemagic.annotation.transformer.DbValueToObject | ||
import com.siimkinks.sqlitemagic.annotation.transformer.ObjectToDbValue | ||
import java.util.* | ||
|
||
object DbTransformers { | ||
@JvmStatic | ||
@DbValueToObject | ||
fun dbValueToDate(dbValue: Long?): Date? = dbValue?.let(::Date) | ||
|
||
@JvmStatic | ||
@ObjectToDbValue | ||
fun dateToDbValue(date: Date?): Long? = date?.time | ||
} |
Oops, something went wrong.