@Test public void testSingleToArray() throws Exception { String single = "text"; Converter converter = factory.createConverter(single.getClass(), String[].class, new Hints()); assertEquals(1, converter.convert(single, String[].class).length); assertEquals("text", converter.convert(single, String[].class)[0]); }
@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);  }