libeufin

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

commit 3a1e451d2610bcbb8cb8e1dfdc2f7ad145630bc4
parent 0227be3bb73effe104d5dd53e721f920d7e23eb4
Author: Florian Dold <florian.dold@gmail.com>
Date:   Wed, 25 Sep 2019 15:09:34 +0200

refactor 'if' into 'when'

Diffstat:
Msrc/main/kotlin/Main.kt | 46++++++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt @@ -69,30 +69,32 @@ fun main() { } logger.info(bodyDocument.documentElement.localName) - if ("ebicsHEVRequest" == bodyDocument.documentElement.localName) { - val hevResponse = HEVResponse( - "000000", - "EBICS_OK", - arrayOf( - ProtocolAndVersion("H003", "02.40"), - ProtocolAndVersion("H004", "02.50") + when (bodyDocument.documentElement.localName) { + "ebicsHEVRequest" -> { + val hevResponse = HEVResponse( + "000000", + "EBICS_OK", + arrayOf( + ProtocolAndVersion("H003", "02.40"), + ProtocolAndVersion("H004", "02.50") + ) ) - ) - - val jaxbHEV: JAXBElement<HEVResponseDataType> = hevResponse.makeHEVResponse() - val responseText: String? = xmlProcess.getStringFromJaxb(jaxbHEV) - // FIXME: check if String is actually non-NULL! - call.respondText(contentType = ContentType.Application.Xml, - status = HttpStatusCode.OK) {responseText.toString()} - return@post + + val jaxbHEV: JAXBElement<HEVResponseDataType> = hevResponse.makeHEVResponse() + val responseText: String? = xmlProcess.getStringFromJaxb(jaxbHEV) + // FIXME: check if String is actually non-NULL! + call.respondText(contentType = ContentType.Application.Xml, + status = HttpStatusCode.OK) {responseText.toString()} + return@post + } + else -> { + /* Log to console and return "unknown type" */ + logger.info("Unknown message, just logging it!") + call.respondText(contentType = ContentType.Application.Xml, + status = HttpStatusCode.NotFound) {"Not found"} + return@post + } } - - /* Log to console and return "unknown type" */ - logger.info("Unknown message, just logging it!") - call.respondText(contentType = ContentType.Application.Xml, - status = HttpStatusCode.NotFound) {"Not found"} - return@post - } } }