@Test public void testWithArrayOfPrimitives() throws NoSuchMethodException { ParamConverterEngine engine = new ParamConverterEngine(); engine.converters = Collections.emptyList(); assertThat(engine.convertValue("1, 2", Integer[].class, null, null)).containsExactly(1, 2); assertThat(engine.convertValue("1, 2", int[].class, null, null)).containsExactly(1, 2); assertThat(engine.convertValue(null, Integer[].class, null, "1,2")).containsExactly(1, 2); assertThat(engine.convertValue("1, 2", Long[].class, null, null)).containsExactly(1l, 2l); assertThat(engine.convertValue("1, 2", long[].class, null, null)).containsExactly(1l, 2l); assertThat(engine.convertValue(null, Long[].class, null, "1,2")).containsExactly(1l, 2l); assertThat(engine.convertValue("1.1, 2.2", Float[].class, null, null)).containsExactly(1.1f, 2.2f); assertThat(engine.convertValue("1.1, 2.2", float[].class, null, null)).containsExactly(1.1f, 2.2f); assertThat(engine.convertValue(null, Float[].class, null, "1,2")).containsExactly(1.0f, 2.0f); assertThat(engine.convertValue("1.1, 2.2", Double[].class, null, null)).containsExactly(1.1d, 2.2d); assertThat(engine.convertValue("1.1, 2.2", double[].class, null, null)).containsExactly(1.1d, 2.2d); assertThat(engine.convertValue(null, Double[].class, null, "1,2")).containsExactly(1.0d, 2.0d); assertThat(engine.convertValue("true, yes, no, false, off", Boolean[].class, null, null)).containsExactly(true, true, false, false, false); assertThat(engine.convertValue("true, yes, no, false, off", boolean[].class, null, null)).containsExactly(true, true, false, false, false); assertThat(engine.convertValue(null, boolean[].class, null, "true, yes, no, false, off")).containsExactly(true, true, false, false, false); }
@Override public <T> T convertValue(String input, Class<T> rawType, Type type, String defaultValue) throws IllegalArgumentException { if (rawType.isArray()) { List<String> args = getMultipleValues(input, defaultValue); return createArray(args, rawType.getComponentType()); } else if (Collection.class.isAssignableFrom(rawType)) { List<String> args = getMultipleValues(input, defaultValue); return createCollection(args, rawType, type); } else { return convertSingleValue(input, rawType, defaultValue); } }
ParamConverterEngine implements ParameterFactories { @Override public <T> T convertValue(String input, Class<T> rawType, Type type, String defaultValue) throws IllegalArgumentException { if (rawType.isArray()) { List<String> args = getMultipleValues(input, defaultValue); return createArray(args, rawType.getComponentType()); } else if (Collection.class.isAssignableFrom(rawType)) { List<String> args = getMultipleValues(input, defaultValue); return createCollection(args, rawType, type); } else { return convertSingleValue(input, rawType, defaultValue); } } }
ParamConverterEngine implements ParameterFactories { @Override public <T> T convertValue(String input, Class<T> rawType, Type type, String defaultValue) throws IllegalArgumentException { if (rawType.isArray()) { List<String> args = getMultipleValues(input, defaultValue); return createArray(args, rawType.getComponentType()); } else if (Collection.class.isAssignableFrom(rawType)) { List<String> args = getMultipleValues(input, defaultValue); return createCollection(args, rawType, type); } else { return convertSingleValue(input, rawType, defaultValue); } } ParamConverterEngine();  ParamConverterEngine(List<ParameterConverter> conv, List<ParameterFactory> fact); }
ParamConverterEngine implements ParameterFactories { @Override public <T> T convertValue(String input, Class<T> rawType, Type type, String defaultValue) throws IllegalArgumentException { if (rawType.isArray()) { List<String> args = getMultipleValues(input, defaultValue); return createArray(args, rawType.getComponentType()); } else if (Collection.class.isAssignableFrom(rawType)) { List<String> args = getMultipleValues(input, defaultValue); return createCollection(args, rawType, type); } else { return convertSingleValue(input, rawType, defaultValue); } } ParamConverterEngine();  ParamConverterEngine(List<ParameterConverter> conv, List<ParameterFactory> fact); @Override T convertValue(String input, Class<T> rawType, Type type, String defaultValue); @Override T convertValues(Collection<String> input, Class<T> rawType, Type type, String defaultValue); @Override T newInstance(Context context, Class<T> type); @Override Set<Class> getTypesHandledByFactories(); }
ParamConverterEngine implements ParameterFactories { @Override public <T> T convertValue(String input, Class<T> rawType, Type type, String defaultValue) throws IllegalArgumentException { if (rawType.isArray()) { List<String> args = getMultipleValues(input, defaultValue); return createArray(args, rawType.getComponentType()); } else if (Collection.class.isAssignableFrom(rawType)) { List<String> args = getMultipleValues(input, defaultValue); return createCollection(args, rawType, type); } else { return convertSingleValue(input, rawType, defaultValue); } } ParamConverterEngine();  ParamConverterEngine(List<ParameterConverter> conv, List<ParameterFactory> fact); @Override T convertValue(String input, Class<T> rawType, Type type, String defaultValue); @Override T convertValues(Collection<String> input, Class<T> rawType, Type type, String defaultValue); @Override T newInstance(Context context, Class<T> type); @Override Set<Class> getTypesHandledByFactories();  }