From 15d258e42126f7af414e940089202516162794d7 Mon Sep 17 00:00:00 2001 From: Jeff Butler Date: Wed, 1 May 2024 10:18:15 -0400 Subject: [PATCH] Better vararg handling --- .../sql/util/kotlin/elements/CaseDSLs.kt | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/elements/CaseDSLs.kt b/src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/elements/CaseDSLs.kt index cd735f43a..027b5b187 100644 --- a/src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/elements/CaseDSLs.kt +++ b/src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/elements/CaseDSLs.kt @@ -65,24 +65,14 @@ class KSimpleCaseDSL : KElseDSL { } internal val whenConditions = mutableListOf>() - fun `when`(firstCondition: VisitableCondition, vararg subsequentConditions: VisitableCondition) = + fun `when`(vararg conditions: VisitableCondition) = SimpleCaseThenGatherer { thenValue -> - val allConditions = buildList { - add(firstCondition) - addAll(subsequentConditions) - } - - whenConditions.add(ConditionBasedWhenCondition(allConditions, thenValue)) + whenConditions.add(ConditionBasedWhenCondition(conditions.asList(), thenValue)) } - fun `when`(firstValue: T, vararg subsequentValues: T) = + fun `when`(vararg values: T) = SimpleCaseThenGatherer { thenValue -> - val allConditions = buildList { - add(firstValue) - addAll(subsequentValues) - } - - whenConditions.add(BasicWhenCondition(allConditions, thenValue)) + whenConditions.add(BasicWhenCondition(values.asList(), thenValue)) } override infix fun `else`(column: BasicColumn) {