@Test public void should_not_box_non_primitive_class() throws Exception { ConfigurationTypeConverter typeConverter = new ConfigurationTypeConverter(); Class<?> boxed = typeConverter.box(Integer.class); assertThat(boxed).isEqualTo(Integer.class); }
public Class<?> box(Class<?> primitive) { if (!primitive.isPrimitive()) { return primitive; } if (int.class.equals(primitive)) { return Integer.class; } else if (long.class.equals(primitive)) { return Long.class; } else if (float.class.equals(primitive)) { return Float.class; } else if (double.class.equals(primitive)) { return Double.class; } else if (short.class.equals(primitive)) { return Short.class; } else if (boolean.class.equals(primitive)) { return Boolean.class; } else if (char.class.equals(primitive)) { return Character.class; } else if (byte.class.equals(primitive)) { return Byte.class; } throw new IllegalArgumentException("Unknown primitive type " + primitive); }
ConfigurationTypeConverter { public Class<?> box(Class<?> primitive) { if (!primitive.isPrimitive()) { return primitive; } if (int.class.equals(primitive)) { return Integer.class; } else if (long.class.equals(primitive)) { return Long.class; } else if (float.class.equals(primitive)) { return Float.class; } else if (double.class.equals(primitive)) { return Double.class; } else if (short.class.equals(primitive)) { return Short.class; } else if (boolean.class.equals(primitive)) { return Boolean.class; } else if (char.class.equals(primitive)) { return Character.class; } else if (byte.class.equals(primitive)) { return Byte.class; } throw new IllegalArgumentException("Unknown primitive type " + primitive); } }
ConfigurationTypeConverter { public Class<?> box(Class<?> primitive) { if (!primitive.isPrimitive()) { return primitive; } if (int.class.equals(primitive)) { return Integer.class; } else if (long.class.equals(primitive)) { return Long.class; } else if (float.class.equals(primitive)) { return Float.class; } else if (double.class.equals(primitive)) { return Double.class; } else if (short.class.equals(primitive)) { return Short.class; } else if (boolean.class.equals(primitive)) { return Boolean.class; } else if (char.class.equals(primitive)) { return Character.class; } else if (byte.class.equals(primitive)) { return Byte.class; } throw new IllegalArgumentException("Unknown primitive type " + primitive); }  }
ConfigurationTypeConverter { public Class<?> box(Class<?> primitive) { if (!primitive.isPrimitive()) { return primitive; } if (int.class.equals(primitive)) { return Integer.class; } else if (long.class.equals(primitive)) { return Long.class; } else if (float.class.equals(primitive)) { return Float.class; } else if (double.class.equals(primitive)) { return Double.class; } else if (short.class.equals(primitive)) { return Short.class; } else if (boolean.class.equals(primitive)) { return Boolean.class; } else if (char.class.equals(primitive)) { return Character.class; } else if (byte.class.equals(primitive)) { return Byte.class; } throw new IllegalArgumentException("Unknown primitive type " + primitive); }  Class<?> box(Class<?> primitive); T convert(String value, Class<T> to); }
ConfigurationTypeConverter { public Class<?> box(Class<?> primitive) { if (!primitive.isPrimitive()) { return primitive; } if (int.class.equals(primitive)) { return Integer.class; } else if (long.class.equals(primitive)) { return Long.class; } else if (float.class.equals(primitive)) { return Float.class; } else if (double.class.equals(primitive)) { return Double.class; } else if (short.class.equals(primitive)) { return Short.class; } else if (boolean.class.equals(primitive)) { return Boolean.class; } else if (char.class.equals(primitive)) { return Character.class; } else if (byte.class.equals(primitive)) { return Byte.class; } throw new IllegalArgumentException("Unknown primitive type " + primitive); }  Class<?> box(Class<?> primitive); T convert(String value, Class<T> to);  }