@Test public void testGetGenericTypeTokens() { TypeToken source = new TypeToken<List<String>>() {}; List<TypeToken<?>> typeTokens = TypeTokenUtils.extractGenericTypeTokens(source); assertEquals(typeTokens.size(), 1); assertEquals(typeTokens.get(0), TypeToken.of(String.class)); }
public static List<TypeToken<?>> extractGenericTypeTokens(TypeToken<?> typeToken) { List<TypeToken<?>> typeTokens = new ArrayList<>(); try { Type[] types = ((ParameterizedType) typeToken.getType()).getActualTypeArguments(); for (Type type : types) { typeTokens.add(TypeToken.of(type)); } } catch (ClassCastException e) { } return typeTokens; }
TypeTokenUtils { public static List<TypeToken<?>> extractGenericTypeTokens(TypeToken<?> typeToken) { List<TypeToken<?>> typeTokens = new ArrayList<>(); try { Type[] types = ((ParameterizedType) typeToken.getType()).getActualTypeArguments(); for (Type type : types) { typeTokens.add(TypeToken.of(type)); } } catch (ClassCastException e) { } return typeTokens; } }
TypeTokenUtils { public static List<TypeToken<?>> extractGenericTypeTokens(TypeToken<?> typeToken) { List<TypeToken<?>> typeTokens = new ArrayList<>(); try { Type[] types = ((ParameterizedType) typeToken.getType()).getActualTypeArguments(); for (Type type : types) { typeTokens.add(TypeToken.of(type)); } } catch (ClassCastException e) { } return typeTokens; }  }
TypeTokenUtils { public static List<TypeToken<?>> extractGenericTypeTokens(TypeToken<?> typeToken) { List<TypeToken<?>> typeTokens = new ArrayList<>(); try { Type[] types = ((ParameterizedType) typeToken.getType()).getActualTypeArguments(); for (Type type : types) { typeTokens.add(TypeToken.of(type)); } } catch (ClassCastException e) { } return typeTokens; }  static TypeToken<?> extractElementTypeToken(TypeToken<?> typeToken); static List<TypeToken<?>> extractGenericTypeTokens(TypeToken<?> typeToken); }
TypeTokenUtils { public static List<TypeToken<?>> extractGenericTypeTokens(TypeToken<?> typeToken) { List<TypeToken<?>> typeTokens = new ArrayList<>(); try { Type[] types = ((ParameterizedType) typeToken.getType()).getActualTypeArguments(); for (Type type : types) { typeTokens.add(TypeToken.of(type)); } } catch (ClassCastException e) { } return typeTokens; }  static TypeToken<?> extractElementTypeToken(TypeToken<?> typeToken); static List<TypeToken<?>> extractGenericTypeTokens(TypeToken<?> typeToken);  }