Since getEntries
returns a raw List
, it could hold anything.
The warning-free approach is to create a new List<SyndEntry>
, then cast each element of the sf.getEntries()
result to SyndEntry
before adding it to your new list. Collections.checkedList
does not do this checking for you—although it would have been possible to implement it to do so.
By doing your own cast up front, you're "complying with the warranty terms" of Java generics: if a ClassCastException
is raised, it will be associated with a cast in the source code, not an invisible cast inserted by the compiler.