@Test public void classType() throws Exception { Type type = SerializableTypeWrapper.forField(Fields.class.getField("classType")); assertThat(type.toString(), equalTo("class java.lang.String")); assertSerializable(type); }
@Test public void forField() throws Exception { Type type = SerializableTypeWrapper.forField(Fields.class.getField("parameterizedType")); assertThat(type.toString(), equalTo("java.util.List<java.lang.String>")); assertSerializable(type); }
@Test public void wildcardType() throws Exception { ParameterizedType typeSource = (ParameterizedType) SerializableTypeWrapper.forField(Fields.class.getField("wildcardType")); WildcardType type = (WildcardType) typeSource.getActualTypeArguments()[0]; assertThat(type.toString(), equalTo("? extends java.lang.CharSequence")); assertSerializable(type); assertSerializable(type.getLowerBounds()); assertSerializable(type.getUpperBounds()); }
@Test public void genericArrayType() throws Exception { GenericArrayType type = (GenericArrayType) SerializableTypeWrapper.forField(Fields.class.getField("genericArrayType")); assertThat(type.toString(), equalTo("java.util.List<java.lang.String>[]")); assertSerializable(type); assertSerializable(type.getGenericComponentType()); }
@Test public void typeVariableType() throws Exception { TypeVariable<?> type = (TypeVariable<?>) SerializableTypeWrapper.forField(Fields.class.getField("typeVariableType")); assertThat(type.toString(), equalTo("T")); assertSerializable(type); assertSerializable(type.getBounds()); }
@Test public void parameterizedType() throws Exception { ParameterizedType type = (ParameterizedType) SerializableTypeWrapper.forField(Fields.class.getField("parameterizedType")); assertThat(type.toString(), equalTo("java.util.List<java.lang.String>")); assertSerializable(type); assertSerializable(type.getOwnerType()); assertSerializable(type.getRawType()); assertSerializable(type.getActualTypeArguments()); assertSerializable(type.getActualTypeArguments()[0]); }