public Object convertSourceToTargetClass(Object source, Class<?> targetClass) { if (source == null) { return null; } Class<?> sourceComponentType = source.getClass().getComponentType(); Class<?> targetComponentType = targetClass.getComponentType(); int length = Array.getLength(source); Object targetArray = Array.newInstance(targetComponentType, length); ConversionExecutor converter = getElementConverter(sourceComponentType, targetComponentType); for (int i = 0; i < length; i++) { Object value = Array.get(source, i); Array.set(targetArray, i, converter.execute(value)); } return targetArray; }
return new StaticConversionExecutor(sourceClass, targetClass, new ArrayToArray(this)); } else if (Collection.class.isAssignableFrom(targetClass)) { if (!targetClass.isInterface() && Modifier.isAbstract(targetClass.getModifiers())) {
return new StaticConversionExecutor(sourceClass, targetClass, new ArrayToArray(elementConverter)); } else if (converter.getTargetClass().isAssignableFrom(sourceComponentType) && converter instanceof TwoWayConverter) { ConversionExecutor elementConverter = new StaticConversionExecutor(sourceComponentType, targetComponentType, new ReverseConverter(twoWay)); return new StaticConversionExecutor(sourceClass, targetClass, new ArrayToArray(elementConverter)); } else { throw new ConversionExecutorNotFoundException(sourceClass, targetClass,
return new StaticConversionExecutor(sourceClass, targetClass, new ArrayToArray(elementConverter)); } else if (converter.getTargetClass().isAssignableFrom(sourceComponentType) && converter instanceof TwoWayConverter) { ConversionExecutor elementConverter = new StaticConversionExecutor(sourceComponentType, targetComponentType, new ReverseConverter(twoWay)); return new StaticConversionExecutor(sourceClass, targetClass, new ArrayToArray(elementConverter)); } else { throw new ConversionExecutorNotFoundException(sourceClass, targetClass,
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) { if (source == null) { return null; } Class<?> sourceComponentType = source.getClass().getComponentType(); Class<?> targetComponentType = targetClass.getComponentType(); int length = Array.getLength(source); Object targetArray = Array.newInstance(targetComponentType, length); ConversionExecutor converter = getElementConverter(sourceComponentType, targetComponentType); for (int i = 0; i < length; i++) { Object value = Array.get(source, i); Array.set(targetArray, i, converter.execute(value)); } return targetArray; }