X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=sources%2Fhv-collector-commandline%2Fsrc%2Fmain%2Fkotlin%2Forg%2Fonap%2Fdcae%2Fcollectors%2Fveshv%2Fcommandline%2FWrongArgumentError.kt;h=3e4814f89ed69b799100e74bc0ae561afcc0df82;hb=c775e8677cdbf69f2b1c1390d225329c658c0ee2;hp=f3749b35549f3adffc6e753397a27fdb3987d094;hpb=c7a3e0738abf581640059587dbb81790339340c9;p=dcaegen2%2Fcollectors%2Fhv-ves.git diff --git a/sources/hv-collector-commandline/src/main/kotlin/org/onap/dcae/collectors/veshv/commandline/WrongArgumentError.kt b/sources/hv-collector-commandline/src/main/kotlin/org/onap/dcae/collectors/veshv/commandline/WrongArgumentError.kt index f3749b35..3e4814f8 100644 --- a/sources/hv-collector-commandline/src/main/kotlin/org/onap/dcae/collectors/veshv/commandline/WrongArgumentError.kt +++ b/sources/hv-collector-commandline/src/main/kotlin/org/onap/dcae/collectors/veshv/commandline/WrongArgumentError.kt @@ -19,7 +19,6 @@ */ package org.onap.dcae.collectors.veshv.commandline -import arrow.core.Option import org.apache.commons.cli.HelpFormatter import org.apache.commons.cli.Options @@ -53,17 +52,15 @@ data class WrongArgumentError( private fun getOptions() = cmdLineOptionsList.map { it.option }.fold(Options(), Options::addOption) companion object { - fun generateRequiredParametersNote(cmdLineOptionsList: List): String { - val requiredParams = Option.fromNullable(cmdLineOptionsList.filter { it.required } - .takeUnless { it.isEmpty() }) - return requiredParams.fold( - { "" }, - { - it.map { commandLineOption -> commandLineOption.option.opt } + fun generateRequiredParametersNote(cmdLineOptionsList: List): String = + cmdLineOptionsList.filter { it.required }.let { requiredParams -> + if (requiredParams.isEmpty()) + "" + else + requiredParams.map { commandLineOption -> commandLineOption.option.opt } .joinToString(prefix = "Required parameters: ", separator = ", ") - } - ) - } + } + } }