@Test public void testEmptyCollectionsAndArrays() throws NoSuchMethodException { ParamConverterEngine engine = new ParamConverterEngine(); engine.converters = ImmutableList.<ParameterConverter>of(new MemberConverter()); Type type = this.getClass().getMethod("listOfInt", List.class).getGenericParameterTypes()[0]; assertThat(engine.convertValues(null, List.class, type, null)).isEmpty(); assertThat(engine.convertValues(null, Set.class, type, null)).isEmpty(); assertThat(engine.convertValues(null, Collection.class, type, null)).isEmpty(); final List<String> empty = Collections.emptyList(); assertThat(engine.convertValues(empty, List.class, type, "")).isEmpty(); assertThat(engine.convertValues(empty, Set.class, type, "")).isEmpty(); assertThat(engine.convertValues(empty, Collection.class, type, "")).isEmpty(); assertThat(engine.convertValues(null, int[].class, null, null)).isEmpty(); assertThat(engine.convertValues(empty, int[].class, null, "")).isEmpty(); }
@Override public <T> T convertValues(Collection<String> input, Class<T> rawType, Type type, String defaultValue) throws IllegalArgumentException { if (rawType.isArray()) { if (input == null) { input = getMultipleValues(defaultValue, null); } return createArray(input, rawType.getComponentType()); } else if (Collection.class.isAssignableFrom(rawType)) { if (input == null) { input = getMultipleValues(defaultValue, null); } return createCollection(input, rawType, type); } else { return convertSingleValue(input, rawType, defaultValue); } }
ParamConverterEngine implements ParameterFactories { @Override public <T> T convertValues(Collection<String> input, Class<T> rawType, Type type, String defaultValue) throws IllegalArgumentException { if (rawType.isArray()) { if (input == null) { input = getMultipleValues(defaultValue, null); } return createArray(input, rawType.getComponentType()); } else if (Collection.class.isAssignableFrom(rawType)) { if (input == null) { input = getMultipleValues(defaultValue, null); } return createCollection(input, rawType, type); } else { return convertSingleValue(input, rawType, defaultValue); } } }
ParamConverterEngine implements ParameterFactories { @Override public <T> T convertValues(Collection<String> input, Class<T> rawType, Type type, String defaultValue) throws IllegalArgumentException { if (rawType.isArray()) { if (input == null) { input = getMultipleValues(defaultValue, null); } return createArray(input, rawType.getComponentType()); } else if (Collection.class.isAssignableFrom(rawType)) { if (input == null) { input = getMultipleValues(defaultValue, null); } return createCollection(input, rawType, type); } else { return convertSingleValue(input, rawType, defaultValue); } } ParamConverterEngine();  ParamConverterEngine(List<ParameterConverter> conv, List<ParameterFactory> fact); }
ParamConverterEngine implements ParameterFactories { @Override public <T> T convertValues(Collection<String> input, Class<T> rawType, Type type, String defaultValue) throws IllegalArgumentException { if (rawType.isArray()) { if (input == null) { input = getMultipleValues(defaultValue, null); } return createArray(input, rawType.getComponentType()); } else if (Collection.class.isAssignableFrom(rawType)) { if (input == null) { input = getMultipleValues(defaultValue, null); } return createCollection(input, 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 convertValues(Collection<String> input, Class<T> rawType, Type type, String defaultValue) throws IllegalArgumentException { if (rawType.isArray()) { if (input == null) { input = getMultipleValues(defaultValue, null); } return createArray(input, rawType.getComponentType()); } else if (Collection.class.isAssignableFrom(rawType)) { if (input == null) { input = getMultipleValues(defaultValue, null); } return createCollection(input, 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();  }