Skip to content

Commit

Permalink
extract function for crystal map get statement generation
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrill-halter-ergon committed Jul 24, 2024
1 parent bf23fe1 commit b0b5d02
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,21 @@ class CblFieldHolder(field: Field, classPaths: List<String>, subEntityNameSuffix

deprecated?.addDeprecated(dbField, propertyBuilder)

val mDocPhrase = if (useMDocChanges) "mDocChanges, mDoc" else "mDoc, mutableMapOf()"
crystalWrapGetStatement(getter, if (useMDocChanges) "mDocChanges, mDoc" else "mDoc, mutableMapOf()", typeConvertersByConvertedClass)
crystalWrapSetStatement(setter, if (useMDocChanges) "mDocChanges" else "mDoc", typeConvertersByConvertedClass, "value")

if (comment.isNotEmpty()) {
propertyBuilder.addKdoc(KDocGeneration.generate(comment))
}

return propertyBuilder.setter(setter.build()).getter(getter.build()).build()
}

fun crystalWrapGetStatement(
getter: FunSpec.Builder,
mDocPhrase: String,
typeConvertersByConvertedClass: Map<TypeName, TypeConverterHolderForEntityGeneration>
) {
if (isNonConvertibleClass) {
if (isIterable) {
getter.addStatement(
Expand Down Expand Up @@ -156,14 +170,6 @@ class CblFieldHolder(field: Field, classPaths: List<String>, subEntityNameSuffix
)
}
}

crystalWrapSetStatement(setter, if (useMDocChanges) "mDocChanges" else "mDoc", typeConvertersByConvertedClass, "value")

if (comment.isNotEmpty()) {
propertyBuilder.addKdoc(KDocGeneration.generate(comment))
}

return propertyBuilder.setter(setter.build()).getter(getter.build()).build()
}

fun crystalWrapSetStatement(
Expand Down

0 comments on commit b0b5d02

Please sign in to comment.