Eric
12/18/2024, 2:40 PMMutableSet
have orphanRemoval = true
on the @OneToMany
annotation, but I can't figure out a good way to detect that using reflection. This works, but I don't like using toString
since that might change. Is there another way that I'm missing that I could use to find all properties that are not an immutable Set?
@Test
fun test() {
val valid = LotEntity::class.declaredMemberProperties
.asSequence()
.filter { it.returnType.isSubtypeOf(Collection::class.starProjectedType) }
.filterNot { it.returnType.toString().startsWith("kotlin.collections.Set") }
.mapNotNull { it.javaField?.getAnnotation(OneToMany::class.java) }
.all { oneToMany -> oneToMany.orphanRemoval }
println(valid)
}