@Test @Parameters(method = "primitivesToBeBoxed") public void should_box_primitive_types(Class<?> primitiveClass, Class<?> expectedBoxedClass) throws Exception { ConfigurationTypeConverter typeConverter = new ConfigurationTypeConverter(); Class<?> actualBoxedClass = typeConverter.box(primitiveClass); assertThat(actualBoxedClass).isEqualTo(expectedBoxedClass); }
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);  }