Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 11 additions & 5 deletions lib/src/main/kotlin/xyz/block/domainapi/DomainApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,21 @@ sealed class UserInteraction<REQUIREMENT_ID> {
* Represents an input into the system for a requirement.
*/
@Serializable
sealed class Input<REQUIREMENT_ID>(val id: REQUIREMENT_ID, val result: ResultCode) {
sealed class Input<REQUIREMENT_ID> {
abstract val id: REQUIREMENT_ID
abstract val result: ResultCode

/**
* Represents the response to a server sent to the client.
*
* @param id The id of the requirement. This is typically an enumeration.
* @param code The result of attempting to overcome the hurdle.
*/
@Serializable
open class HurdleResponse<REQUIREMENT_ID>(id: REQUIREMENT_ID, code: ResultCode) :
Input<REQUIREMENT_ID>(id, code)
open class HurdleResponse<REQUIREMENT_ID>(
override val id: REQUIREMENT_ID,
override val result: ResultCode
) : Input<REQUIREMENT_ID>()

/**
* A result sent to the business process as part of a resume operation. If there is specific data
Expand All @@ -190,8 +195,9 @@ sealed class Input<REQUIREMENT_ID>(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<REQUIREMENT_ID>(id: REQUIREMENT_ID) :
Input<REQUIREMENT_ID>(id, ResultCode.CLEARED)
open class ResumeResult<REQUIREMENT_ID>(override val id: REQUIREMENT_ID) : Input<REQUIREMENT_ID>() {
override val result: ResultCode = ResultCode.CLEARED
}
}

/** The possible results of attempting to overcome a hurdle. */
Expand Down