From 2193dced0a68bb45d458632f339e31814d655ba0 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Thu, 3 Dec 2015 11:07:25 +0000 Subject: [PATCH] Minor: add docs for the cash DSL extensions --- src/main/kotlin/contracts/Cash.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/kotlin/contracts/Cash.kt b/src/main/kotlin/contracts/Cash.kt index f02f78b9ff..10b7869542 100644 --- a/src/main/kotlin/contracts/Cash.kt +++ b/src/main/kotlin/contracts/Cash.kt @@ -234,8 +234,13 @@ class Cash : Contract { } // Small DSL extensions. + +/** Sums the cash states in the list that are owned by the given key, throwing an exception if there are none. */ fun Iterable.sumCashBy(owner: PublicKey) = filterIsInstance().filter { it.owner == owner }.map { it.amount }.sumOrThrow() +/** Sums the cash states in the list, throwing an exception if there are none. */ fun Iterable.sumCash() = filterIsInstance().map { it.amount }.sumOrThrow() +/** Sums the cash states in the list, returning null if there are none. */ fun Iterable.sumCashOrNull() = filterIsInstance().map { it.amount }.sumOrNull() +/** Sums the cash states in the list, returning zero of the given currency if there are none. */ fun Iterable.sumCashOrZero(currency: Currency) = filterIsInstance().map { it.amount }.sumOrZero(currency)