Ok,I will read more carefully the documentation th...
# getting-started
f
Ok,I will read more carefully the documentation then 😉
google 3
l
Just
ctrl+space
the hell out of the ide 😅
😀 1
f
One more question 😞
Copy code
val type: BotFlowNodeLinkType = BotFlowNodeLinkType.get(
                    it.camundaInputParameters
                            .filter { param -> param.getAttributeValue("name") == "btn_type" }
                            .map { it.textContent }
                            .firstOrNull()
                            ?: throw  MissingBtnTypeException(it.camundaInputParameters))
                    ?: throw  MissingBtnTypeException(it.camundaInputParameters)
I would like to throw an exception if firstOrNull return null
but I need to put it 2 times otherwises, I need to put BotFlowNodLinkType?
the other solution is to put !! at the end
l
just use
first
instead of
firstOrNull
?
e
Because
firstOfNull
returns
Type?
instead of
Type
, @lovis’s answer should be most appropriate
l
Also,
first(predicate)
will throw if not found
f
If I try to use first, I got an emptyList exception 😞
l
maybe you could change
BotFlowNodeLinkType.get()
then, that it accepts
null
? Then you only have to throw once
f
Yes it seems to be the best solution