@@ -236,12 +236,23 @@ class MetaModelGenerator(val outputDir: Path) {
236
236
for (feature in concept.directFeaturesAndConflicts()) {
237
237
when (val data = feature.data) {
238
238
is PropertyData -> {
239
- val optionalString = String ::class .asTypeName().copy(nullable = true )
240
- addProperty(PropertySpec .builder(feature.validName, optionalString)
239
+ val accessorClass = when (data.type) {
240
+ PropertyType .STRING -> StringPropertyAccessor ::class
241
+ PropertyType .BOOLEAN -> BooleanPropertyAccessor ::class
242
+ PropertyType .INT -> IntPropertyAccessor ::class
243
+ }
244
+ addProperty(PropertySpec .builder(feature.validName, data.type.asKotlinType())
241
245
.addModifiers(KModifier .OVERRIDE )
242
246
.mutable(true )
243
- .delegate(""" ${PropertyAccessor :: class .qualifiedName} (unwrap(), "${feature.originalName} ")""" )
247
+ .delegate(""" ${accessorClass .qualifiedName} (unwrap(), "${feature.originalName} ")""" )
244
248
.build())
249
+ if (data.type != PropertyType .STRING ) {
250
+ addProperty(PropertySpec .builder(" _raw_" + feature.validName, PropertyType .STRING .asKotlinType())
251
+ .addModifiers(KModifier .OVERRIDE )
252
+ .mutable(true )
253
+ .delegate(""" ${StringPropertyAccessor ::class .qualifiedName} (unwrap(), "${feature.originalName} ")""" )
254
+ .build())
255
+ }
245
256
}
246
257
is ChildLinkData -> {
247
258
// TODO resolve link.type and ensure it exists
@@ -276,10 +287,14 @@ class MetaModelGenerator(val outputDir: Path) {
276
287
for (feature in concept.directFeatures()) {
277
288
when (val data = feature.data) {
278
289
is PropertyData -> {
279
- val optionalString = String ::class .asTypeName().copy(nullable = true )
280
- addProperty(PropertySpec .builder(feature.validName, optionalString)
290
+ addProperty(PropertySpec .builder(feature.validName, data.type.asKotlinType())
281
291
.mutable(true )
282
292
.build())
293
+ if (data.type != PropertyType .STRING ) {
294
+ addProperty(PropertySpec .builder(" _raw_" + feature.validName, PropertyType .STRING .asKotlinType())
295
+ .mutable(true )
296
+ .build())
297
+ }
283
298
}
284
299
is ChildLinkData -> {
285
300
// TODO resolve link.type and ensure it exists
@@ -301,6 +316,13 @@ class MetaModelGenerator(val outputDir: Path) {
301
316
}
302
317
}
303
318
319
+ fun PropertyType.asKotlinType (): TypeName {
320
+ return when (this ) {
321
+ PropertyType .STRING -> String ::class .asTypeName().copy(nullable = true )
322
+ PropertyType .BOOLEAN -> Boolean ::class .asTypeName()
323
+ PropertyType .INT -> Int ::class .asTypeName()
324
+ }
325
+ }
304
326
fun ConceptRef.conceptWrapperImplType () = ClassName (languageName, conceptName.conceptWrapperImplName())
305
327
fun ConceptRef.conceptWrapperInterfaceType () = ClassName (languageName, conceptName.conceptWrapperInterfaceName())
306
328
fun ConceptRef.nodeWrapperImplType () = ClassName (languageName, conceptName.nodeWrapperImplName())
0 commit comments