@Test public void testGetNoGenericClassOfSet() throws Exception { assertThat(Inspector.getGenericClassOfList(methodWithStringResponse.getReturnType(), methodWithStringResponse.getGenericReturnType()), is(nullValue())); }
public static Class<?> getGenericClassOfList(Class<?> type, Type listGenericClass) { if(type.isArray()) { return type.getComponentType(); } if (listGenericClass instanceof ParameterizedType) { for (Type typeArgument : ((ParameterizedType) listGenericClass).getActualTypeArguments()) { return (Class<?>) typeArgument; } } return null; }
Inspector { public static Class<?> getGenericClassOfList(Class<?> type, Type listGenericClass) { if(type.isArray()) { return type.getComponentType(); } if (listGenericClass instanceof ParameterizedType) { for (Type typeArgument : ((ParameterizedType) listGenericClass).getActualTypeArguments()) { return (Class<?>) typeArgument; } } return null; } }
Inspector { public static Class<?> getGenericClassOfList(Class<?> type, Type listGenericClass) { if(type.isArray()) { return type.getComponentType(); } if (listGenericClass instanceof ParameterizedType) { for (Type typeArgument : ((ParameterizedType) listGenericClass).getActualTypeArguments()) { return (Class<?>) typeArgument; } } return null; }  }
Inspector { public static Class<?> getGenericClassOfList(Class<?> type, Type listGenericClass) { if(type.isArray()) { return type.getComponentType(); } if (listGenericClass instanceof ParameterizedType) { for (Type typeArgument : ((ParameterizedType) listGenericClass).getActualTypeArguments()) { return (Class<?>) typeArgument; } } return null; }  static Class<?> getGenericClassOfList(Class<?> type, Type listGenericClass); static boolean isListSetOrArray(Class<?> propertyType); static boolean isMap(Class<?> propertyType); }
Inspector { public static Class<?> getGenericClassOfList(Class<?> type, Type listGenericClass) { if(type.isArray()) { return type.getComponentType(); } if (listGenericClass instanceof ParameterizedType) { for (Type typeArgument : ((ParameterizedType) listGenericClass).getActualTypeArguments()) { return (Class<?>) typeArgument; } } return null; }  static Class<?> getGenericClassOfList(Class<?> type, Type listGenericClass); static boolean isListSetOrArray(Class<?> propertyType); static boolean isMap(Class<?> propertyType);  }