libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 0a44db6147a3041de0039c48b85f865b8b1b26e2
parent a9b19b40109ff361498439025780f105ccecaaf5
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Mon, 17 Feb 2020 17:42:58 +0100

improve use of smart cast

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 20++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -967,22 +967,14 @@ fun main() { EbicsAccountInfoEntity.new(id = it.id) { this.subscriber = getSubscriberEntityFromId(customerIdAtNexus) accountHolder = it.accountHolder - iban = when (it.accountNumberList?.get(0)) { - is EbicsTypes.GeneralAccountNumber -> { - (it.accountNumberList?.get(0) as EbicsTypes.GeneralAccountNumber).value - } - is EbicsTypes.NationalAccountNumber -> { - (it.accountNumberList?.get(0) as EbicsTypes.NationalAccountNumber).value - } + iban = when (val firstAccount = it.accountNumberList?.get(0)) { + is EbicsTypes.GeneralAccountNumber -> firstAccount.value + is EbicsTypes.NationalAccountNumber -> firstAccount.value else -> throw UnknownBankAccountType(HttpStatusCode.NotFound) } - bankCode = when (it.bankCodeList?.get(0)) { - is EbicsTypes.GeneralBankCode -> { - (it.bankCodeList?.get(0) as EbicsTypes.GeneralBankCode).value - } - is EbicsTypes.NationalBankCode -> { - (it.bankCodeList?.get(0) as EbicsTypes.GeneralBankCode).value - } + bankCode = when (val firstBankCode = it.bankCodeList?.get(0)) { + is EbicsTypes.GeneralBankCode -> firstBankCode.value + is EbicsTypes.NationalBankCode -> firstBankCode.value else -> throw UnknownBankAccountType(HttpStatusCode.NotFound) } }