Skip to content

Commit

Permalink
Merge pull request #62 from zeoflow/bug/key-name-wrong-format
Browse files Browse the repository at this point in the history
Fixed Wrong-Key format
  • Loading branch information
teogor authored Jun 30, 2022
2 parents fdf756d + 91d1999 commit 3600a81
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ data class City(
@Observable
val country: String,

@KeyName("population_count")
@Observable
@Default(PopulationDefault::class)
val population: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class EntityBuilder(
"return %T().get(%T[%S, field])",
getType(field.functionsType!!.typeName),
types.Memo(),
field.keyName
field.storeKeyName
)
.build()
)
Expand All @@ -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) {
Expand All @@ -156,7 +156,7 @@ class EntityBuilder(
.addStatement(
"return %T[%S, field]",
types.Memo(),
field.keyName
field.storeKeyName
)
.build()
)
Expand All @@ -165,7 +165,7 @@ class EntityBuilder(
.addStatement(
"%T.put(%S, value)",
types.Memo(),
field.keyName
field.storeKeyName
)
if (field.isObservable) {
funcSetter.addStatement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3600a81

Please sign in to comment.