Skip to content

Commit 15d258e

Browse files
committed
Better vararg handling
1 parent 07cb132 commit 15d258e

File tree

1 file changed

+4
-14
lines changed
  • src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/elements

1 file changed

+4
-14
lines changed

src/main/kotlin/org/mybatis/dynamic/sql/util/kotlin/elements/CaseDSLs.kt

+4-14
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,14 @@ class KSimpleCaseDSL<T : Any> : KElseDSL {
6565
}
6666
internal val whenConditions = mutableListOf<SimpleCaseWhenCondition<T>>()
6767

68-
fun `when`(firstCondition: VisitableCondition<T>, vararg subsequentConditions: VisitableCondition<T>) =
68+
fun `when`(vararg conditions: VisitableCondition<T>) =
6969
SimpleCaseThenGatherer { thenValue ->
70-
val allConditions = buildList {
71-
add(firstCondition)
72-
addAll(subsequentConditions)
73-
}
74-
75-
whenConditions.add(ConditionBasedWhenCondition(allConditions, thenValue))
70+
whenConditions.add(ConditionBasedWhenCondition(conditions.asList(), thenValue))
7671
}
7772

78-
fun `when`(firstValue: T, vararg subsequentValues: T) =
73+
fun `when`(vararg values: T) =
7974
SimpleCaseThenGatherer { thenValue ->
80-
val allConditions = buildList {
81-
add(firstValue)
82-
addAll(subsequentValues)
83-
}
84-
85-
whenConditions.add(BasicWhenCondition(allConditions, thenValue))
75+
whenConditions.add(BasicWhenCondition(values.asList(), thenValue))
8676
}
8777

8878
override infix fun `else`(column: BasicColumn) {

0 commit comments

Comments
 (0)