From 4bec05f50c0967902dbe8561b421a8a4d10d9aad Mon Sep 17 00:00:00 2001 From: Teodor G Date: Fri, 1 Jul 2022 02:34:50 +0300 Subject: [PATCH 1/2] [KeyName] fixed worng key name format --- .../com/zeoflow/memo/processor/entity/EntityBuilder.kt | 8 ++++---- .../java/com/zeoflow/memo/processor/entity/EntityField.kt | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/memo-processor/src/main/java/com/zeoflow/memo/processor/entity/EntityBuilder.kt b/memo-processor/src/main/java/com/zeoflow/memo/processor/entity/EntityBuilder.kt index fc562c4..3996234 100644 --- a/memo-processor/src/main/java/com/zeoflow/memo/processor/entity/EntityBuilder.kt +++ b/memo-processor/src/main/java/com/zeoflow/memo/processor/entity/EntityBuilder.kt @@ -127,7 +127,7 @@ class EntityBuilder( "return %T().get(%T[%S, field])", getType(field.functionsType!!.typeName), types.Memo(), - field.keyName + field.storeKeyName ) .build() ) @@ -136,7 +136,7 @@ class EntityBuilder( .addStatement( "%T.put(%S, %T().set(value))", types.Memo(), - field.keyName, + field.storeKeyName, getType(field.functionsType!!.typeName) ) if (field.isObservable) { @@ -156,7 +156,7 @@ class EntityBuilder( .addStatement( "return %T[%S, field]", types.Memo(), - field.keyName + field.storeKeyName ) .build() ) @@ -165,7 +165,7 @@ class EntityBuilder( .addStatement( "%T.put(%S, value)", types.Memo(), - field.keyName + field.storeKeyName ) if (field.isObservable) { funcSetter.addStatement( diff --git a/memo-processor/src/main/java/com/zeoflow/memo/processor/entity/EntityField.kt b/memo-processor/src/main/java/com/zeoflow/memo/processor/entity/EntityField.kt index e009014..cbde1e8 100644 --- a/memo-processor/src/main/java/com/zeoflow/memo/processor/entity/EntityField.kt +++ b/memo-processor/src/main/java/com/zeoflow/memo/processor/entity/EntityField.kt @@ -13,16 +13,18 @@ class EntityField(var xFieldElement: XFieldElement) { var functionsType: XType? = null val className: ClassName val keyName: String + val storeKeyName: String val isObservable: Boolean val isListener: Boolean init { - keyName = if (xFieldElement.hasAnnotation(KeyName::class)) { + storeKeyName = if (xFieldElement.hasAnnotation(KeyName::class)) { val keyNameAnnotation = xFieldElement.getAnnotation(KeyName::class)!!.value keyNameAnnotation.value } else { xFieldElement.name } + keyName = xFieldElement.name className = getType(xFieldElement.type.typeName) isObservable = xFieldElement.hasAnnotation(Observable::class) isListener = xFieldElement.hasAnnotation(Listener::class) From 91d19991238b73ffd5708d2499aec33546c2e800 Mon Sep 17 00:00:00 2001 From: Teodor G Date: Fri, 1 Jul 2022 02:35:30 +0300 Subject: [PATCH 2/2] [Demo] added example for the wrong-key format --- app-kotlin/src/main/java/com/zeoflow/memo/demo/entities/City.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app-kotlin/src/main/java/com/zeoflow/memo/demo/entities/City.kt b/app-kotlin/src/main/java/com/zeoflow/memo/demo/entities/City.kt index bcdcb4d..6c8ab13 100644 --- a/app-kotlin/src/main/java/com/zeoflow/memo/demo/entities/City.kt +++ b/app-kotlin/src/main/java/com/zeoflow/memo/demo/entities/City.kt @@ -23,6 +23,7 @@ data class City( @Observable val country: String, + @KeyName("population_count") @Observable @Default(PopulationDefault::class) val population: Int,