Since Gson 2.8.0, you can use TypeToken#getParameterized(Type rawType, Type... typeArguments)
to create the TypeToken
, then getType()
should do the trick.
For example:
TypeToken.getParameterized(ArrayList.class, myClass).getType()
More Related Contents:
- How do I find out what type each object is in a ArrayList?
- Trouble with Gson serializing an ArrayList of POJO’s
- why is it that we can’t use ArrayList.get(-1) to get the last element of the ArrayList in java? it works in python though [closed]
- How to arrange the datas to display in array by given string of days in java?
- When to use LinkedList over ArrayList in Java?
- Convert ArrayList to String[] array [duplicate]
- How to find an object in an ArrayList by property
- Avoiding instanceof in Java
- Sorting arraylist in alphabetical order (case insensitive)
- Is a Java string really immutable?
- How to get the MethodInfo of a Java 8 method reference?
- How do I intercept a method invocation with standard java features (no AspectJ etc)?
- How to deserialize a list using GSON or another JSON library in Java?
- Is it bad practice to use Reflection in Unit testing? [duplicate]
- How to remove element from ArrayList by checking its value?
- System.out is declared as static final and initialized with null? [duplicate]
- Java Reflection: Create an implementing class
- Field.get(obj) returns all nulls on injected CDI managed beans, while manually invoking getters return correct values
- How to find the length of an array list? [duplicate]
- How can I slice an ArrayList out of an ArrayList in Java?
- Java seek a method with specific annotation and its annotation element
- How to get the line number of a method?
- How can I convert ArrayList to ArrayList?
- Remove empty collections from a JSON with Gson
- How can I determine the type of a generic field in Java?
- casting Arrays.asList causing exception: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
- Jsonpath with Jackson or Gson
- Time complexity of contains(Object o), in an ArrayList of Objects
- Java – Gson parsing nested within nested
- Vector vs Collections.synchronizedList(ArrayList)