no.ks.kes.demoapp.ShippedBasketsProjection.kt Maven / Gradle / Ivy
package no.ks.kes.demoapp
import no.ks.kes.lib.Projection
import java.util.*
class Shipments : Projection() {
private val created: MutableMap> = mutableMapOf()
private val failed: MutableSet = mutableSetOf()
private val missing: MutableSet = mutableSetOf()
init {
on { created.put(it.eventData.basketId, it.eventData.items) }
on { failed.add(it.eventData.basketId) }
on { missing.add(it.eventData.basketId) }
}
@Synchronized
fun getShipments(basketId: UUID): Map? =
created[basketId]
@Synchronized
fun isFailedShipment(basketId: UUID): Boolean = failed.contains(basketId)
@Synchronized
fun isMissingShipment(basketId: UUID): Boolean = missing.contains(basketId)
}