PropertyConverterManager { @SuppressWarnings("unchecked") private <T> TypeLiteral<T> mapBoxedType(TypeLiteral<T> targetType) { Type parameterType = targetType.getType(); if (parameterType == int.class) { return TypeLiteral.class.cast(TypeLiteral.of(Integer.class)); } if (parameterType == short.class) { return TypeLiteral.class.cast(TypeLiteral.of(Short.class)); } if (parameterType == byte.class) { return TypeLiteral.class.cast(TypeLiteral.of(Byte.class)); } if (parameterType == long.class) { return TypeLiteral.class.cast(TypeLiteral.of(Long.class)); } if (parameterType == boolean.class) { return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class)); } if (parameterType == char.class) { return TypeLiteral.class.cast(TypeLiteral.of(Character.class)); } if (parameterType == float.class) { return TypeLiteral.class.cast(TypeLiteral.of(Float.class)); } if (parameterType == double.class) { return TypeLiteral.class.cast(TypeLiteral.of(Double.class)); } if (parameterType == int[].class) { return TypeLiteral.class.cast(TypeLiteral.of(Integer[].class)); } if (parameterType == short[].class) { return TypeLiteral.class.cast(TypeLiteral.of(Short[].class)); } if (parameterType == byte[].class) { return TypeLiteral.class.cast(TypeLiteral.of(Byte[].class)); } if (parameterType == long[].class) { return TypeLiteral.class.cast(TypeLiteral.of(Long[].class)); } if (parameterType == boolean[].class) { return TypeLiteral.class.cast(TypeLiteral.of(Boolean[].class)); } if (parameterType == char[].class) { return TypeLiteral.class.cast(TypeLiteral.of(Character[].class)); } if (parameterType == float[].class) { return TypeLiteral.class.cast(TypeLiteral.of(Float[].class)); } if (parameterType == double[].class) { return TypeLiteral.class.cast(TypeLiteral.of(Double[].class)); } return null; } PropertyConverterManager(ServiceContext serviceContext);  PropertyConverterManager(ServiceContext serviceContext, boolean init); @SuppressWarnings("unchecked") void register(TypeLiteral<T> targetType, PropertyConverter<T> converter); boolean isTargetTypeSupported(TypeLiteral<?> targetType); Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters(); List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void testMapBoxedType() throws Exception { ServiceContext serviceContext = ServiceContextManager.getServiceContext(getClass().getClassLoader()); PropertyConverterManager manager = new PropertyConverterManager(serviceContext, false); Class[] boxed = new Class[]{ Integer[].class, Short[].class, Byte[].class, Long[].class, Boolean[].class, Character[].class, Float[].class, Double[].class }; Class[] primitive = new Class[]{ int[].class, short[].class, byte[].class, long[].class, boolean[].class, char[].class, float[].class, double[].class }; Method method = PropertyConverterManager.class.getDeclaredMethod("mapBoxedType", TypeLiteral.class); method.setAccessible(true); for (int i = 0; i < boxed.length; i++) { assertThat(TypeLiteral.of(boxed[i])) .isEqualTo(method.invoke(manager, TypeLiteral.of(primitive[i]))); assertThat(TypeLiteral.of(boxed[i].getComponentType())) .isEqualTo(method.invoke(manager, TypeLiteral.of(primitive[i].getComponentType()))); } }