mirror of
https://github.com/corda/corda.git
synced 2025-01-30 16:14:39 +00:00
Minor: simplify the implementation of requireThat{} a little bit (reviewed by Roger).
This commit is contained in:
parent
8b94325039
commit
a1759016a8
@ -48,14 +48,14 @@ infix fun Amount<Currency>.issuedBy(deposit: PartyAndReference) = Amount(quantit
|
||||
|
||||
//// Requirements /////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Requirements {
|
||||
infix fun String.by(expr: Boolean) {
|
||||
object Requirements {
|
||||
@Suppress("NOTHING_TO_INLINE") // Inlining this takes it out of our committed ABI.
|
||||
infix inline fun String.by(expr: Boolean) {
|
||||
if (!expr) throw IllegalArgumentException("Failed requirement: $this")
|
||||
}
|
||||
}
|
||||
|
||||
val R = Requirements()
|
||||
inline fun <R> requireThat(body: Requirements.() -> R) = R.body()
|
||||
inline fun <R> requireThat(body: Requirements.() -> R) = Requirements.body()
|
||||
|
||||
//// Authenticated commands ///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user