@SuppressWarnings("unchecked")
should be fine here: we know each wrapper class W
declares its TYPE
field as a Class<W>
, - probably just add a comment to explain that rational.
Note that Guava already has Primitives.unwrap
to handle this for you, in case you're using it.