From 3a9a62c370dec85b6c8d27f27d7bf888aa287b0c Mon Sep 17 00:00:00 2001 From: Sven Braune Date: Wed, 19 Apr 2023 10:51:41 +0200 Subject: [PATCH] # added reduced models and basedOn models resulting interfaces to generated parent class --- .../crystalprocessor/generation/model/EntityGeneration.kt | 1 + .../crystalprocessor/generation/model/WrapperGeneration.kt | 1 + .../crystalprocessor/model/entity/BaseEntityHolder.kt | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/generation/model/EntityGeneration.kt b/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/generation/model/EntityGeneration.kt index 12636ae9..4aa7636c 100644 --- a/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/generation/model/EntityGeneration.kt +++ b/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/generation/model/EntityGeneration.kt @@ -59,6 +59,7 @@ class EntityGeneration { .addModifiers(KModifier.PUBLIC) .addSuperinterface(TypeUtil.iEntity()) .addSuperinterface(holder.interfaceTypeName) + .addSuperinterfaces(holder.collectAllChildInterfaces()) .addProperty(holder.dbNameProperty()) .addFunction(EnsureTypesGeneration.ensureTypes(holder, false)) .addFunction(CblDefaultGeneration.addDefaults(holder, false)) diff --git a/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/generation/model/WrapperGeneration.kt b/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/generation/model/WrapperGeneration.kt index 291a2f61..a8ea0827 100644 --- a/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/generation/model/WrapperGeneration.kt +++ b/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/generation/model/WrapperGeneration.kt @@ -19,6 +19,7 @@ class WrapperGeneration { .addSuperinterface(TypeUtil.mapSupport()) .addModifiers(KModifier.PUBLIC) .addSuperinterface(holder.interfaceTypeName) + .addSuperinterfaces(holder.collectAllChildInterfaces()) .addFunction(EnsureTypesGeneration.ensureTypes(holder, true)) .addFunction(CblDefaultGeneration.addDefaults(holder, true)) .addFunction(CblConstantGeneration.addConstants(holder, true)) diff --git a/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/model/entity/BaseEntityHolder.kt b/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/model/entity/BaseEntityHolder.kt index 7d37f28b..9164783d 100644 --- a/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/model/entity/BaseEntityHolder.kt +++ b/crystal-map-processor/src/main/java/com/schwarz/crystalprocessor/model/entity/BaseEntityHolder.kt @@ -55,4 +55,10 @@ abstract class BaseEntityHolder(val sourceElement: ISourceModel) : IClassModel b val interfaceTypeName: TypeName get() = ClassName(sourcePackage, interfaceSimpleName) + + fun collectAllChildInterfaces(): List { + val basedOnInterfaceTypeNames = basedOn.map { it.interfaceTypeName } + val reducesModelsInterfaceTypeNames = reducesModels.map { ClassName(sourcePackage, "I${it.namePrefix}$sourceClazzSimpleName") } + return listOf(*basedOnInterfaceTypeNames.toTypedArray(), *reducesModelsInterfaceTypeNames.toTypedArray()) + } }