@Test public void testArrayToArrayWithConversionErrors() throws Exception { String[] array = new String[] {"1", "2", "a", "3"}; Converter converter = factory.createConverter(array.getClass(), Integer[].class, new Hints()); Integer[] converted = converter.convert(array, Integer[].class); assertNull(converted); }
@Override public Converter createConverter(Class<?> source, Class<?> target, Hints hints) { if (source.isArray() && !target.isArray() && source.getComponentType().isAssignableFrom(target)) { return new ArrayToSingleConverter(); } else if (target.isArray() && !source.isArray() && target.getComponentType().isAssignableFrom(source)) { return new SingleToArrayConverter(); } else if (source.isArray() && target.isArray()) { return new ArrayToArrayConverter(); } return null; }
ArrayConverterFactory implements ConverterFactory { @Override public Converter createConverter(Class<?> source, Class<?> target, Hints hints) { if (source.isArray() && !target.isArray() && source.getComponentType().isAssignableFrom(target)) { return new ArrayToSingleConverter(); } else if (target.isArray() && !source.isArray() && target.getComponentType().isAssignableFrom(source)) { return new SingleToArrayConverter(); } else if (source.isArray() && target.isArray()) { return new ArrayToArrayConverter(); } return null; } }
ArrayConverterFactory implements ConverterFactory { @Override public Converter createConverter(Class<?> source, Class<?> target, Hints hints) { if (source.isArray() && !target.isArray() && source.getComponentType().isAssignableFrom(target)) { return new ArrayToSingleConverter(); } else if (target.isArray() && !source.isArray() && target.getComponentType().isAssignableFrom(source)) { return new SingleToArrayConverter(); } else if (source.isArray() && target.isArray()) { return new ArrayToArrayConverter(); } return null; }  }
ArrayConverterFactory implements ConverterFactory { @Override public Converter createConverter(Class<?> source, Class<?> target, Hints hints) { if (source.isArray() && !target.isArray() && source.getComponentType().isAssignableFrom(target)) { return new ArrayToSingleConverter(); } else if (target.isArray() && !source.isArray() && target.getComponentType().isAssignableFrom(source)) { return new SingleToArrayConverter(); } else if (source.isArray() && target.isArray()) { return new ArrayToArrayConverter(); } return null; }  @Override Converter createConverter(Class<?> source, Class<?> target, Hints hints); }
ArrayConverterFactory implements ConverterFactory { @Override public Converter createConverter(Class<?> source, Class<?> target, Hints hints) { if (source.isArray() && !target.isArray() && source.getComponentType().isAssignableFrom(target)) { return new ArrayToSingleConverter(); } else if (target.isArray() && !source.isArray() && target.getComponentType().isAssignableFrom(source)) { return new SingleToArrayConverter(); } else if (source.isArray() && target.isArray()) { return new ArrayToArrayConverter(); } return null; }  @Override Converter createConverter(Class<?> source, Class<?> target, Hints hints);  }