I have the following Kotlin code:
fun handleResult(clazz: Any){
val store = App.getBoxStore();
if(clazz is List<*> && clazz.size > 0){
val items: List<*> = clazz;
val item = items.get(0);
val box = store.boxFor(item!!::class.java)
box.put(items)
}
}
It takes a object, checks if it is a collection and if it is, takes a item to check the class of the collection items, create a Box from a library called ObjectBox which is an database, and them put the list of items in the database.
However, i get the following error in the Box.put statment:
Error:(45, 17) None of the following functions can be called with the
arguments supplied:
public open fun put(@Nullable vararg p0: Nothing!): Unit defined in
io.objectbox.Box
public open fun put(@Nullable p0: (Nothing..Collection<Nothing!>?)):
Unit defined in io.objectbox.Box
public open fun put(p0: Nothing!): Long defined in io.objectbox.Box
The signature of the method I want to use is:
public void put(@Nullable Collection<T> entities)
It recivies a Collection of a generic type, as a list is a collection, it should work.
I've also explicitly casted it to a List, but it still says the same thing.
Thanks!