Skip to content

Commit

Permalink
feat: Support super type token in SagaEvent (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb authored Apr 1, 2024
1 parent 9f4783b commit 2430796
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/kotlin/org/rooftop/netx/api/SagaEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ sealed class SagaEvent(
return event
}

fun <T : Any> decodeEvent(typeReference: TypeReference<T>): T =
codec.decode(
event ?: throw NullPointerException("Cannot decode event cause event is null"),
typeReference
)

fun <T : Any> decodeEvent(type: Class<T>): T = decodeEvent(type.kotlin)

fun <T : Any> decodeEvent(type: KClass<T>): T =
Expand Down

0 comments on commit 2430796

Please sign in to comment.