spring-projects / spring-projects/spring-data-mongodb
Remove deprecations for methods taking KClass? [DATAMONGO-2395]
@christophstrobl is already working on this.
Since Dec 30, 2020.
- Dominant language
- Java
- Stars
- 1.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Johan Haleby opened DATAMONGO-2395 and commented
Hi,
In Spring Data MongoDB 2.1.x I have code that looks like this:
fun createCollectionsIfNotExists(vararg entityClasses: KClass<*>) = entityClasses.forEach { entityClass ->
if (!mongo.collectionExists(entityClass)) {
mongo.createCollection(entityClass)
}
}
createCollectionsIfNotExists(MongoDTO1::class, MongoDTO2::class, MongoDTO3::class, MongoDTO4::class)
In 2.2 "collectionExists" and "createCollection" has been deprecated in favor of reified counterparts. However invoking the reified methods is difficult if you just have "KClass" (see https://stackoverflow.com/questions/55399737/calling-a-fun-with-reified-type-parameter-if-you-just-have-a-kclass-object). Is there a recommended approach to deal with situations like the one I have in 2.2 or could both method variants be retained (i.e. both KClass and the reified version)?
Affects: 2.2 GA (Moore)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.