-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added BeforeMigrationRule and AfterMigrationRule
- Loading branch information
Showing
12 changed files
with
129 additions
and
39 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
21 changes: 0 additions & 21 deletions
21
RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/rules/FieldRules.kt
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/rules/LifecycleRule.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,16 @@ | ||
package dev.matrix.roomigrant.compiler.rules | ||
|
||
import dev.matrix.roomigrant.compiler.Database | ||
import com.squareup.kotlinpoet.CodeBlock | ||
|
||
/** | ||
* @author matrixdev | ||
*/ | ||
data class LifecycleRule( | ||
val state: Database, | ||
val holder: RulesHolder, | ||
val methodName: String) { | ||
|
||
fun getInvokeCode(databaseArgName: String) = CodeBlock.of("%T.%L.%L($databaseArgName)\n", state.migrationListClassName, holder.name, methodName) | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/rules/Rules.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,42 @@ | ||
package dev.matrix.roomigrant.compiler.rules | ||
|
||
/** | ||
* @author matrixdev | ||
*/ | ||
class Rules { | ||
|
||
private val fieldRules = HashMap<String, FieldRule>() | ||
private val beforeRules = HashMap<String, LifecycleRule>() | ||
private val afterRules = HashMap<String, LifecycleRule>() | ||
|
||
fun getFieldRule(version1: Int, version2: Int, table: String, field: String): FieldRule? { | ||
return fieldRules[packFieldRuleKey(version1, version2, table, field)] | ||
} | ||
|
||
fun putFieldRule(version1: Int, version2: Int, table: String, field: String, rule: FieldRule) { | ||
fieldRules[packFieldRuleKey(version1, version2, table, field)] = rule | ||
} | ||
|
||
fun getBeforeRule(version1: Int, version2: Int): LifecycleRule? { | ||
return beforeRules[packLifecycleRuleKey(version1, version2)] | ||
} | ||
|
||
fun putBeforeRule(version1: Int, version2: Int, rule: LifecycleRule) { | ||
beforeRules[packLifecycleRuleKey(version1, version2)] = rule | ||
} | ||
|
||
fun getAfterRule(version1: Int, version2: Int): LifecycleRule? { | ||
return afterRules[packLifecycleRuleKey(version1, version2)] | ||
} | ||
|
||
fun putAfterRule(version1: Int, version2: Int, rule: LifecycleRule) { | ||
afterRules[packLifecycleRuleKey(version1, version2)] = rule | ||
} | ||
|
||
private fun packLifecycleRuleKey(version1: Int, version2: Int) = | ||
"$version1-$version2" | ||
|
||
private fun packFieldRuleKey(version1: Int, version2: Int, table: String, field: String) = | ||
"$version1-$version2-$table-$field" | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
RoomigrantLib/src/main/java/dev/matrix/roomigrant/AfterMigrationRule.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,10 @@ | ||
package dev.matrix.roomigrant | ||
|
||
/** | ||
* @author matrixdev | ||
*/ | ||
@Target(AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.SOURCE) | ||
annotation class AfterMigrationRule( | ||
val version1: Int, | ||
val version2: Int) |
10 changes: 10 additions & 0 deletions
10
RoomigrantLib/src/main/java/dev/matrix/roomigrant/BeforeMigrationRule.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,10 @@ | ||
package dev.matrix.roomigrant | ||
|
||
/** | ||
* @author matrixdev | ||
*/ | ||
@Target(AnnotationTarget.FUNCTION) | ||
@Retention(AnnotationRetention.SOURCE) | ||
annotation class BeforeMigrationRule( | ||
val version1: Int, | ||
val version2: Int) |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Sun Jul 15 21:42:25 EEST 2018 | ||
#Tue Dec 18 12:36:59 EET 2018 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip |