看一下Spring的文档描述:
Context about a type to convert from or to.
其场景用于Convert体系中,我们会发现关于Type相关的类会比较混乱,功能会出现重叠,可能是因为历史原因造成的,比如TypeDescriptor的出现时间比ResolvableType早
等ResolvableType出现之后,又对TypeDescriptor进行了改造。
来看一段示例代码:
getObjectType是获取值类型的包装类型()
@Test
public void parameterPrimitive() throws Exception {
TypeDescriptor desc = new TypeDescriptor(new MethodParameter(getClass().getMethod("testParameterPrimitive", int.class), 0));
assertEquals(int.class, desc.getType());
assertEquals(Integer.class, desc.getObjectType());
assertEquals("int", desc.getName());
assertEquals("int", desc.toString());
assertTrue(desc.isPrimitive());
assertEquals(0, desc.getAnnotations().length);
assertFalse(desc.isCollection());
assertFalse(desc.isMap());
}