Types { public static ParameterizedType newParameterizedTypeWithOwner( Type ownerType, Type rawType, Type... typeArguments) { return new ParameterizedTypeImpl(ownerType, rawType, typeArguments); } 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 parameterizedTypeWithUnnecessaryOwnerProvided() throws Exception { try { Types.newParameterizedTypeWithOwner(A.class, List.class, B.class); fail(); } catch (IllegalArgumentException expected) { String message = "unexpected owner type for " + List.class + ": " + A.class; assertThat(expected.getMessage(), is(equalTo(message))); } }
@Test public void getFirstTypeArgument() throws Exception { assertThat(getFirstTypeArgument(A.class), is(nullValue())); Type type = Types.newParameterizedTypeWithOwner(TypesTest.class, A.class, B.class, C.class); assertThat(getFirstTypeArgument(type), is(Matchers.<Type>equalTo(B.class))); }