@Test public void testGetTypeArgumentAndClassUsingGenericArray() throws Exception { Method method1 = getMethod("array"); List<ClassTypePair> ctp1 = ReflectionHelper.getTypeArgumentAndClass(method1.getGenericParameterTypes()[0]); assertThat(ctp1.get(0).rawClass()).isEqualTo(String[].class); assertThat(ctp1.get(0).type()).isInstanceOf(GenericArrayType.class); }
public static List<ClassTypePair> getTypeArgumentAndClass(final Type type) throws IllegalArgumentException { final Type[] types = getTypeArguments(type); if (types == null) { return Collections.emptyList(); } List<ClassTypePair> list = new ArrayList<>(); for (Type t : types) { list.add(new ClassTypePair(erasure(t), t)); } return list; }
ReflectionHelper { public static List<ClassTypePair> getTypeArgumentAndClass(final Type type) throws IllegalArgumentException { final Type[] types = getTypeArguments(type); if (types == null) { return Collections.emptyList(); } List<ClassTypePair> list = new ArrayList<>(); for (Type t : types) { list.add(new ClassTypePair(erasure(t), t)); } return list; } }
ReflectionHelper { public static List<ClassTypePair> getTypeArgumentAndClass(final Type type) throws IllegalArgumentException { final Type[] types = getTypeArguments(type); if (types == null) { return Collections.emptyList(); } List<ClassTypePair> list = new ArrayList<>(); for (Type t : types) { list.add(new ClassTypePair(erasure(t), t)); } return list; } private  ReflectionHelper(); }
ReflectionHelper { public static List<ClassTypePair> getTypeArgumentAndClass(final Type type) throws IllegalArgumentException { final Type[] types = getTypeArguments(type); if (types == null) { return Collections.emptyList(); } List<ClassTypePair> list = new ArrayList<>(); for (Type t : types) { list.add(new ClassTypePair(erasure(t), t)); } return list; } private  ReflectionHelper(); static Map<String, Property> getProperties(Class clazz, Type genericType); static List<ClassTypePair> getTypeArgumentAndClass(final Type type); @SuppressWarnings("unchecked") static Class<T> erasure(Type type); static Type[] getTypeArguments(Type type); static String getPrimitiveDefault(Class type); static List<Field> getAllFields(Class<?> cls); }
ReflectionHelper { public static List<ClassTypePair> getTypeArgumentAndClass(final Type type) throws IllegalArgumentException { final Type[] types = getTypeArguments(type); if (types == null) { return Collections.emptyList(); } List<ClassTypePair> list = new ArrayList<>(); for (Type t : types) { list.add(new ClassTypePair(erasure(t), t)); } return list; } private  ReflectionHelper(); static Map<String, Property> getProperties(Class clazz, Type genericType); static List<ClassTypePair> getTypeArgumentAndClass(final Type type); @SuppressWarnings("unchecked") static Class<T> erasure(Type type); static Type[] getTypeArguments(Type type); static String getPrimitiveDefault(Class type); static List<Field> getAllFields(Class<?> cls);  }