joinAllOrNull
Compute the join (least upper bound) of all values in contributions, or null if the list is empty.
This is the empty-safe variant of joinAll: identical behaviour for non-empty input, but returns null instead of throwing when contributions is empty. Useful when the contribution set is built dynamically and may legitimately be empty.
Samples
val r1 = ReplicaId("r1")
val r2 = ReplicaId("r2")
// Empty list — returns null instead of throwing.
val empty = joinAllOrNull(emptyList<CoordinationFree<GCounter>>())
check(empty == null)
// Non-empty list — same result as joinAll.
val contributions = listOf(
CoordinationFree(GCounter.of(r1 to 10L)),
CoordinationFree(GCounter.of(r2 to 20L)),
)
val merged = joinAllOrNull(contributions)
check(merged?.state?.value == 30L)Content copied to clipboard