mardi 10 mai 2016

Get `ParametrizedType` object from dynamic element type

When the element type is not dynamic, it is easy to create a Type object representing a collection of that type:

Type listType = new TypeToken<ObservableList<ElementType>>(){}.getType();

But this is not possible here as my elementType is a dynamic value:

Type elementType = ((ParameterizedType) typeOfT).getActualTypeArguments()[0];
Type listType = // ???

Now I would like listType to represent an ObservableList<> which type parameter should be elementType. Is there a way to do so?





Aucun commentaire:

Enregistrer un commentaire