Types { static Type arrayComponentType(Type type) { if (type instanceof GenericArrayType) { return ((GenericArrayType) type).getGenericComponentType(); } else if (type instanceof Class) { return ((Class<?>) type).getComponentType(); } else { return null; } } private  Types(); static ParameterizedType newParameterizedType(Type rawType, Type... typeArguments); static ParameterizedType newParameterizedTypeWithOwner(
            Type ownerType, Type rawType, Type... typeArguments); static GenericArrayType arrayOf(Type componentType); static WildcardType subtypeOf(Type bound); static WildcardType supertypeOf(Type bound); static Class<?> getRawType(Type type); static boolean equals(@Nullable Type a, @Nullable Type b); static Type collectionElementType(Type context, Class<?> contextRawType);  }
@Test public void arrayComponentType() throws Exception { assertThat(Types.arrayComponentType(String[][].class), is(Matchers.<Type>equalTo(String[].class))); assertThat(Types.arrayComponentType(String[].class), is(Matchers.<Type>equalTo(String.class))); Type arrayOfMapOfStringIntegerType = TypesTest.class.getDeclaredField( "arrayOfMapOfStringInteger").getGenericType(); Type mapOfStringIntegerType = TypesTest.class.getDeclaredField( "mapOfStringInteger").getGenericType(); assertThat(Types.arrayComponentType(arrayOfMapOfStringIntegerType), is(equalTo(mapOfStringIntegerType))); }