From b0b5d0269c1e460383c6cd90ad87c31bae5676c0 Mon Sep 17 00:00:00 2001 From: Cyrill Halter Date: Wed, 24 Jul 2024 16:42:21 +0200 Subject: [PATCH] extract function for crystal map get statement generation --- .../model/field/CblFieldHolder.kt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/model/field/CblFieldHolder.kt b/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/model/field/CblFieldHolder.kt index 946bee2c..b8cb6410 100644 --- a/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/model/field/CblFieldHolder.kt +++ b/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/model/field/CblFieldHolder.kt @@ -90,7 +90,21 @@ class CblFieldHolder(field: Field, classPaths: List, 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 + ) { if (isNonConvertibleClass) { if (isIterable) { getter.addStatement( @@ -156,14 +170,6 @@ class CblFieldHolder(field: Field, classPaths: List, 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(