List<DataConvertor> componentConvertorList = findConvertor(srcType.getComponentType(), targetType.getComponentType());
List<DataConvertor> toArrayConvertorList = ListConvertUtil.transform(componentConvertorList,
new RowConvertor<DataConvertor, DataConvertor>() {
@Override
public DataConvertor convert(int rowIndex, final DataConvertor originalConvertor) {
return new DataConvertor() {
Pair<Class, Class> typePair = extractConvertorTypeInfo(originalConvertor);
@Override
public Object convert(Object obj) {
if (typePair == null) {
return null;
}
int length = Array.getLength(obj);
Object targetArray = Array.newInstance(typePair.getRight(), length);
for (int i = 0; i < length; i++) {
Array.set(targetArray, i, originalConvertor.convert(Array.get(obj, i)));
}
return targetArray;
}
};
}
});
foundConvertorList.addAll(toArrayConvertorList);
}
if (!foundConvertorList.isEmpty()) {
return foundConvertorList;
}
// find as element to array
if (targetType.isArray()) {
List<DataConvertor> componentConvertorList = findConvertor(srcType, targetType.getComponentType());
List<DataConvertor> toArrayConvertorList = ListConvertUtil.transform(componentConvertorList,
new RowConvertor<DataConvertor, DataConvertor>() {
@Override
public DataConvertor convert(int rowIndex, final DataConvertor originalConvertor) {
return new DataConvertor() {
private Pair<Class, Class> typePair = extractConvertorTypeInfo(originalConvertor);
@Override
public Object convert(Object obj) {
if (typePair == null) {
return null;
}
Object array = Array.newInstance(typePair.getRight(), 1);
Array.set(array, 0, originalConvertor.convert(obj));
return array;
}
};
}
});
foundConvertorList.addAll(toArrayConvertorList);
}
if (!foundConvertorList.isEmpty()) {
return foundConvertorList;
}
// find as array to element
if (srcType.isArray()) {
List<DataConvertor> componentConvertorList = findConvertor(srcType.getComponentType(), targetType);
List<DataConvertor> toArrayConvertorList = ListConvertUtil.transform(componentConvertorList,
new RowConvertor<DataConvertor, DataConvertor>() {
@Override
public DataConvertor convert(int rowIndex, final DataConvertor originalConvertor) {
return new DataConvertor() {
@Override
public Object convert(Object obj) {
int length = Array.getLength(obj);
if (length == 0) {
return null;