From 3cf6416f4c179619499c974cb4a0a9c5138406bb Mon Sep 17 00:00:00 2001 From: Alejandro Metke Jimenez Date: Thu, 4 Dec 2025 17:02:48 +1000 Subject: [PATCH] Add serialisation plugin and fix hurdle and hurdle responses class structure to be serialisable automatically --- lib/build.gradle.kts | 1 + .../main/kotlin/xyz/block/domainapi/DomainApi.kt | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 93c1ad1..e56965a 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -2,6 +2,7 @@ plugins { id("java-library") id("org.jetbrains.kotlin.jvm") id("com.vanniktech.maven.publish") version "0.34.0" + kotlin("plugin.serialization") version "1.9.0" } repositories { diff --git a/lib/src/main/kotlin/xyz/block/domainapi/DomainApi.kt b/lib/src/main/kotlin/xyz/block/domainapi/DomainApi.kt index 9d8c3fd..a593ccf 100644 --- a/lib/src/main/kotlin/xyz/block/domainapi/DomainApi.kt +++ b/lib/src/main/kotlin/xyz/block/domainapi/DomainApi.kt @@ -170,7 +170,10 @@ sealed class UserInteraction { * Represents an input into the system for a requirement. */ @Serializable -sealed class Input(val id: REQUIREMENT_ID, val result: ResultCode) { +sealed class Input { + abstract val id: REQUIREMENT_ID + abstract val result: ResultCode + /** * Represents the response to a server sent to the client. * @@ -178,8 +181,10 @@ sealed class Input(val id: REQUIREMENT_ID, val result: ResultCod * @param code The result of attempting to overcome the hurdle. */ @Serializable - open class HurdleResponse(id: REQUIREMENT_ID, code: ResultCode) : - Input(id, code) + open class HurdleResponse( + override val id: REQUIREMENT_ID, + override val result: ResultCode + ) : Input() /** * A result sent to the business process as part of a resume operation. If there is specific data @@ -190,8 +195,9 @@ sealed class Input(val id: REQUIREMENT_ID, val result: ResultCod * @param id The id of the requirement whose result is needed to resume the process. */ @Serializable - open class ResumeResult(id: REQUIREMENT_ID) : - Input(id, ResultCode.CLEARED) + open class ResumeResult(override val id: REQUIREMENT_ID) : Input() { + override val result: ResultCode = ResultCode.CLEARED + } } /** The possible results of attempting to overcome a hurdle. */