If ElementType is a statically known type, it is "easy" to create a Type object representing a collection of ElementTypes:
Type listType = new TypeToken<ObservableList<ElementType>>(){}.getType();
But this is not possible here as my elementType is a dynamic value, only known at runtime:
@Override
public ListProperty<?> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws
JsonParseException {
Type elementType = ((ParameterizedType) typeOfT).getActualTypeArguments()[0];
Type listType = // ??? create the type representing a ObservableList<elementType>
ObservableList<?> list = context.deserialize(json, listType);
return new SimpleListProperty<>(list);
}
Now I would like listType to represent an ObservableList<> which type parameter should be the value of elementType. Is there a way to do so?