I have a class Identifier<T>
which essentially is a type-safe wrapper around a UUID (so class Foo
contains an Identifier<Foo>
).
The FooStore
class has a method List<Identifier<Foo>> bulkReadIdentifiers()
.
In another class, I need to turn this List<Identifier<Foo>>
into a List<UUID>
. Implementing a method that does this for Foo
is trivial, but how do I declare the method so that it works for arbitrary classes, i.e. Bar
instead of Foo
?
The method List<UUID> extractUuids(List<Identifier<?>> identifiers)
causes compile errors because the ?
does not match Foo
. Can this be solved without using a hack that involves raw lists and/or @SuppressWarnings
?
You can make the method generic: