Tutorial starter code - Unchecked cast from DataProvider to ListDataProvider

I’m facing an issue that I don’t know how to solve. Can someone help me?

I’ve just added the @SuppressWarnings annotation, but I’m interested if someone can provide an explanation and a better solution.

You can also grid.getListDataView().getItem(0)

In both cases you are expecting the grid to be inmemory, that’s the reason you are casting with a warning.

If I understand correctly, there’s no way to get rid of this warning because type checking can’t be performed on something that is stored in RAM?

No. The grid is returning a Data provider. You can cast it to a listdataprovider because you are using a list before.

The code with the listdataview should not give you a warning

I don’t understand.
I copied the source code from your GitHub repo.
And I got several warnings from the get-go.
I was able to remove all warnings except the one I’ve mentioned in my first post. Should I ignore this warning, or is there something wrong with the code?

It’s just a warning. Java is a type safe language and casting something into something else results in such a warning to make sure you know what you do. You can suppress this warning.

@quirky-zebra Thank you for clarifying.