d only give us a raw List {@code java.lang.reflect.Type} might provide some value:
Type listOfStringType = ...; // firstly, how to obtain this? Doable, but not straightforward. List<String> listOfString = (List<String>) typesafe.obtain(listOfStringType, ...); // nongeneric Type would necessitate a cast
The "type literal" concept was introduced to provide an alternative, i.e.:
class Typesafe { <T> T obtain(TypeLiteral<T> type, ...); }
Consuming code looks like:
List<String> listOfString = typesafe.obtain(new TypeLiteral<List<String>>() {}, ...);
This has the effect of "jumping up" a level to tie a {@code java.lang.reflect.Type}to a type variable while simultaneously making it short work to obtain a {@code Type} instance for any given type, inline.
Additionally {@link TypeLiteral} implements the {@link Typed} interface whichis a generalization of this concept, and which may be implemented in custom classes. It is suggested that APIs be defined in terms of the interface, in the following manner:
<T> T obtain(Typed<T> typed, ...);
@version $Id: TypeLiteral.java 1552665 2013-12-20 13:43:53Z britter $
@since 3.2