Skip to content

Commit

Permalink
Add missing spread operators to CqlTemplate kotlin extensions.
Browse files Browse the repository at this point in the history
Closes #1434
  • Loading branch information
mp911de committed Sep 20, 2023
1 parent e29bb2f commit aa6aab6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun <T : Any> AsyncCqlOperations.queryForObject(
entityClass: KClass<T>,
vararg args: Any
): CompletableFuture<T?> =
queryForObject(cql, entityClass.java, args)
queryForObject(cql, entityClass.java, *args)

/**
* Extension for [AsyncCqlOperations.queryForObject] leveraging reified type parameters.
Expand All @@ -68,7 +68,7 @@ inline fun <reified T : Any> AsyncCqlOperations.queryForObject(
cql: String,
vararg args: Any
): CompletableFuture<T?> =
queryForObject(cql, T::class.java, args)
queryForObject(cql, T::class.java, *args)

/**
* Extension for [AsyncCqlOperations.queryForObject] leveraging reified type parameters.
Expand All @@ -78,7 +78,7 @@ fun <T : Any> AsyncCqlOperations.queryForObject(
vararg args: Any,
function: (Row, Int) -> T
): CompletableFuture<T?> =
queryForObject(cql, RowMapper { row, i -> function(row, i) }, *args)
queryForObject(cql, { row, i -> function(row, i) }, *args)

/**
* Extension for [AsyncCqlOperations.queryForObject] providing a [KClass] based variant.
Expand Down Expand Up @@ -114,7 +114,7 @@ inline fun <reified T : Any> AsyncCqlOperations.queryForList(
cql: String,
vararg args: Any
): CompletableFuture<List<T>> =
queryForList(cql, T::class.java, args)
queryForList(cql, T::class.java, *args)

/**
* Extension for [AsyncCqlOperations.queryForList] providing a [KClass] based variant.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ inline fun <reified T : Any> CqlOperations.queryForObject(cql: String): T? =
*/
@Deprecated("Since 2.2, use the reified variant", replaceWith = ReplaceWith("queryForObject<T>(cql, args)"))
fun <T : Any> CqlOperations.queryForObject(cql: String, entityClass: KClass<T>, vararg args: Any): T? =
queryForObject(cql, entityClass.java, args)
queryForObject(cql, entityClass.java, *args)

/**
* Extension for [CqlOperations.queryForObject] leveraging reified type parameters.
*/
inline fun <reified T : Any> CqlOperations.queryForObject(cql: String, vararg args: Any): T? =
queryForObject(cql, T::class.java, args)
queryForObject(cql, T::class.java, *args)

/**
* Extension for [CqlOperations.queryForObject] leveraging reified type parameters.
*/
fun <T : Any> CqlOperations.queryForObject(cql: String, vararg args: Any, function: (Row, Int) -> T): T? =
queryForObject(cql, function, args)
queryForObject(cql, function, *args)

/**
* Extension for [CqlOperations.queryForObject] providing a [KClass] based variant.
Expand All @@ -85,7 +85,7 @@ inline fun <reified T : Any> CqlOperations.queryForList(cql: String): List<T> =
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
inline fun <reified T : Any> CqlOperations.queryForList(cql: String, vararg args: Any): List<T> =
queryForList(cql, T::class.java, args)
queryForList(cql, T::class.java, *args)

/**
* Extension for [CqlOperations.queryForList] providing a [KClass] based variant.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ inline fun <reified T : Any> ReactiveCqlOperations.queryForObject(cql: String):
*/
@Deprecated("Since 2.2, use the reified variant", replaceWith = ReplaceWith("queryForObject<T>(cql, args)"))
fun <T : Any> ReactiveCqlOperations.queryForObject(cql: String, entityClass: KClass<T>, vararg args: Any): Mono<T> =
queryForObject(cql, entityClass.java, args)
queryForObject(cql, entityClass.java, *args)

/**
* Extension for [ReactiveCqlOperations.queryForObject] leveraging reified type parameters.
*/
inline fun <reified T : Any> ReactiveCqlOperations.queryForObject(cql: String, vararg args: Any): Mono<T> =
queryForObject(cql, T::class.java, args)
queryForObject(cql, T::class.java, *args)

/**
* Extension for [ReactiveCqlOperations.queryForObject] leveraging reified type parameters.
*/
fun <T : Any> ReactiveCqlOperations.queryForObject(cql: String, vararg args: Any, function: (Row, Int) -> T): Mono<T> =
queryForObject(cql, function, args)
queryForObject(cql, function, *args)

/**
* Extension for [ReactiveCqlOperations.queryForObject] providing a [KClass] based variant.
Expand All @@ -87,7 +87,7 @@ inline fun <reified T : Any> ReactiveCqlOperations.queryForFlux(cql: String): Fl
*/
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
inline fun <reified T : Any> ReactiveCqlOperations.queryForFlux(cql: String, vararg args: Any): Flux<T> =
queryForFlux(cql, T::class.java, args)
queryForFlux(cql, T::class.java, *args)

/**
* Extension for [ReactiveCqlOperations.queryForFlux] providing a [KClass] based variant.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ class CqlOperationsExtensionsUnitTests {
fun `queryForObject(String, KClass, array) extension should call its Java counterpart`() {

operations.queryForObject("", Person::class, "foo", "bar")
verify { operations.queryForObject("", Person::class.java, arrayOf("foo", "bar")) }
verify { operations.queryForObject("", Person::class.java, "foo", "bar") }
}

@Test // DATACASS-484
fun `queryForObject(String, array) extension should call its Java counterpart`() {

operations.queryForObject<Person>("", "foo", "bar")
verify { operations.queryForObject("", Person::class.java, arrayOf("foo", "bar")) }
verify { operations.queryForObject("", Person::class.java, "foo", "bar") }
}

@Test // DATACASS-484
Expand All @@ -67,7 +67,7 @@ class CqlOperationsExtensionsUnitTests {
operations.queryForObject(
eq(""),
any<RowMapper<Int>>(),
eq(arrayOf(3))
eq(3)
)
}
}
Expand Down Expand Up @@ -101,7 +101,7 @@ class CqlOperationsExtensionsUnitTests {
fun `queryForList(String, array) extension should call its Java counterpart`() {

operations.queryForList<Person>("", "foo", "bar")
verify { operations.queryForList("", Person::class.java, arrayOf("foo", "bar")) }
verify { operations.queryForList("", Person::class.java, "foo", "bar") }
}

@Test // DATACASS-484
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ class LegacyAsyncCqlOperationsExtensionsUnitTests {
fun `queryForObject(String, KClass, array) extension should call its Java counterpart`() {

operations.queryForObject("", Person::class, "foo", "bar")
verify { operations.queryForObject("", Person::class.java, arrayOf("foo", "bar")) }
verify { operations.queryForObject("", Person::class.java, "foo", "bar") }
}

@Test // DATACASS-484
fun `queryForObject(String, array) extension should call its Java counterpart`() {

operations.queryForObject<Person>("", "foo", "bar")
verify { operations.queryForObject("", Person::class.java, arrayOf("foo", "bar")) }
verify { operations.queryForObject("", Person::class.java, "foo", "bar") }
}

@Test // DATACASS-484
Expand Down Expand Up @@ -96,7 +96,7 @@ class LegacyAsyncCqlOperationsExtensionsUnitTests {
fun `queryForList(String, array) extension should call its Java counterpart`() {

operations.queryForList<Person>("", "foo", "bar")
verify { operations.queryForList("", Person::class.java, arrayOf("foo", "bar")) }
verify { operations.queryForList("", Person::class.java, "foo", "bar") }
}

@Test // DATACASS-484
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ class ReactiveCqlOperationsExtensionsUnitTests {
fun `queryForObject(String, KClass, array) extension should call its Java counterpart`() {

operations.queryForObject("", Person::class, "foo", "bar")
verify { operations.queryForObject("", Person::class.java, arrayOf("foo", "bar")) }
verify { operations.queryForObject("", Person::class.java, "foo", "bar") }
}

@Test // DATACASS-484
fun `queryForObject(String, array) extension should call its Java counterpart`() {

operations.queryForObject<Person>("", "foo", "bar")
verify { operations.queryForObject("", Person::class.java, arrayOf("foo", "bar")) }
verify { operations.queryForObject("", Person::class.java, "foo", "bar") }
}

@Test // DATACASS-484
Expand All @@ -67,7 +67,7 @@ class ReactiveCqlOperationsExtensionsUnitTests {
operations.queryForObject(
eq(""),
any<RowMapper<Int>>(),
eq(arrayOf(3))
eq(3)
)
}
}
Expand Down Expand Up @@ -101,7 +101,7 @@ class ReactiveCqlOperationsExtensionsUnitTests {
fun `queryForFlux(String, array) extension should call its Java counterpart`() {

operations.queryForFlux<Person>("", "foo", "bar")
verify { operations.queryForFlux("", Person::class.java, arrayOf("foo", "bar")) }
verify { operations.queryForFlux("", Person::class.java, "foo", "bar") }
}

@Test // DATACASS-484
Expand Down

0 comments on commit aa6aab6

Please sign in to comment.