mirror of
https://github.com/corda/corda.git
synced 2025-02-21 09:51:57 +00:00
Minor: add more javadoc
This commit is contained in:
parent
3636f137b0
commit
07e01388d2
@ -93,13 +93,14 @@ inline fun <reified T : CommandData> Collection<AuthenticatedObject<CommandData>
|
|||||||
filter { if (parties == null) true else it.signingParties.containsAll(parties) }.
|
filter { if (parties == null) true else it.signingParties.containsAll(parties) }.
|
||||||
map { AuthenticatedObject(it.signers, it.signingParties, it.value as T) }
|
map { AuthenticatedObject(it.signers, it.signingParties, it.value as T) }
|
||||||
|
|
||||||
|
/** Ensures that a transaction has only one command that is of the given type, otherwise throws an exception. */
|
||||||
inline fun <reified T : CommandData> Collection<AuthenticatedObject<CommandData>>.requireSingleCommand() = try {
|
inline fun <reified T : CommandData> Collection<AuthenticatedObject<CommandData>>.requireSingleCommand() = try {
|
||||||
select<T>().single()
|
select<T>().single()
|
||||||
} catch (e: NoSuchElementException) {
|
} catch (e: NoSuchElementException) {
|
||||||
throw IllegalStateException("Required ${T::class.qualifiedName} command") // Better error message.
|
throw IllegalStateException("Required ${T::class.qualifiedName} command") // Better error message.
|
||||||
}
|
}
|
||||||
|
|
||||||
// For Java
|
/** Ensures that a transaction has only one command that is of the given type, otherwise throws an exception. */
|
||||||
fun <C : CommandData> Collection<AuthenticatedObject<CommandData>>.requireSingleCommand(klass: Class<C>) =
|
fun <C : CommandData> Collection<AuthenticatedObject<CommandData>>.requireSingleCommand(klass: Class<C>) =
|
||||||
mapNotNull { @Suppress("UNCHECKED_CAST") if (klass.isInstance(it.value)) it as AuthenticatedObject<C> else null }.single()
|
mapNotNull { @Suppress("UNCHECKED_CAST") if (klass.isInstance(it.value)) it as AuthenticatedObject<C> else null }.single()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user