PropertyUtils { public static Class<?> getTypeOf(Class<?> type) { if (type.isPrimitive()) { return types.get(type); } else { return type; } } private  PropertyUtils(); static Object getPropertyValue(Object context, String property); static Object setPropertyValue(Object context, String property, Object value); static PropertyDescriptor getPropertyDescriptor(Class<?> domainType, String expression); static Class<?> getTypeOf(Class<?> type); static String getPropertyName(Method getter);  }
@Test public void testPrimitiveTypeConversion() { assertThat(PropertyUtils.getTypeOf(int.class), is(Matchers.equalTo(Integer.class))); assertThat(PropertyUtils.getTypeOf(float.class), is(Matchers.equalTo(Float.class))); assertThat(PropertyUtils.getTypeOf(double.class), is(Matchers.equalTo(Double.class))); assertThat(PropertyUtils.getTypeOf(byte.class), is(Matchers.equalTo(Byte.class))); assertThat(PropertyUtils.getTypeOf(short.class), is(Matchers.equalTo(Short.class))); assertThat(PropertyUtils.getTypeOf(long.class), is(Matchers.equalTo(Long.class))); assertThat(PropertyUtils.getTypeOf(char.class), is(Matchers.equalTo(Character.class))); assertThat(PropertyUtils.getTypeOf(boolean.class), is(Matchers.equalTo(Boolean.class))); }
@Test public void testNonPrimitiveTypeConversion() { assertThat(PropertyUtils.getTypeOf(Object.class), is(Matchers.equalTo(Object.class))); assertThat(PropertyUtils.getTypeOf(String.class), is(Matchers.equalTo(String.class))); assertThat(PropertyUtils.getTypeOf(BigDecimal.class), is(Matchers.equalTo(BigDecimal.class))); assertThat(PropertyUtils.getTypeOf(Person.class), is(Matchers.equalTo(Person.class))); }