diff --git a/languages/javalang/builder-renderer/java-builder-client/src/main/kotlin/io/vrap/codegen/languages/javalang/client/builder/producers/JavaModelClassFileProducer.kt b/languages/javalang/builder-renderer/java-builder-client/src/main/kotlin/io/vrap/codegen/languages/javalang/client/builder/producers/JavaModelClassFileProducer.kt index 4a4a9519..dbdce596 100644 --- a/languages/javalang/builder-renderer/java-builder-client/src/main/kotlin/io/vrap/codegen/languages/javalang/client/builder/producers/JavaModelClassFileProducer.kt +++ b/languages/javalang/builder-renderer/java-builder-client/src/main/kotlin/io/vrap/codegen/languages/javalang/client/builder/producers/JavaModelClassFileProducer.kt @@ -1,5 +1,6 @@ package io.vrap.codegen.languages.javalang.client.builder.producers +import com.google.common.collect.Lists import io.vrap.codegen.languages.extensions.isPatternProperty import io.vrap.codegen.languages.extensions.toComment import io.vrap.codegen.languages.java.base.JavaSubTemplates @@ -12,10 +13,8 @@ import io.vrap.rmf.codegen.rendering.utils.keepIndentation import io.vrap.rmf.codegen.types.VrapArrayType import io.vrap.rmf.codegen.types.VrapObjectType import io.vrap.rmf.codegen.types.VrapTypeProvider -import io.vrap.rmf.raml.model.types.BooleanInstance -import io.vrap.rmf.raml.model.types.ObjectType -import io.vrap.rmf.raml.model.types.Property -import io.vrap.rmf.raml.model.types.UnionType +import io.vrap.rmf.raml.model.types.* +import io.vrap.rmf.raml.model.types.Annotation class JavaModelClassFileProducer constructor(override val vrapTypeProvider: VrapTypeProvider, @AllObjectTypes private val allObjectTypes: List) : JavaObjectTypeExtensions, JavaEObjectTypeExtensions, FileProducer { @@ -28,6 +27,17 @@ class JavaModelClassFileProducer constructor(override val vrapTypeProvider: Vrap val vrapType = vrapTypeProvider.doSwitch(type).toJavaVType() as VrapObjectType + val implements = Lists.newArrayList(vrapType.simpleClassName, "ModelBase") + .plus( + when (val ex = type.getAnnotation("java-impl-implements") ) { + is Annotation -> { + (ex.value as StringInstance).value.escapeAll() + } + else -> null + } + ) + .filterNotNull() + val content = """ |package ${vrapType.`package`.toJavaPackage()}; | @@ -53,7 +63,7 @@ class JavaModelClassFileProducer constructor(override val vrapTypeProvider: Vrap | */ |<${JavaSubTemplates.generatedAnnotation}>${if (type.markDeprecated()) """ |@Deprecated""" else ""} - |public class ${vrapType.simpleClassName}Impl implements ${vrapType.simpleClassName}, ModelBase { + |public class ${vrapType.simpleClassName}Impl implements ${implements.joinToString(separator = ", ")} { | | <${type.beanFields().escapeAll()}> | @@ -65,6 +75,7 @@ class JavaModelClassFileProducer constructor(override val vrapTypeProvider: Vrap | | <${type.equalsMethod().escapeAll()}> | + | <${type.getAnnotation("java-impl-mixin")?.value?.value?.let { (it as String).escapeAll()} ?: ""}> |} """.trimMargin().keepIndentation() return TemplateFile(