package cn.report.excel.easyexcel.api.converters.bytearray;

import cn.report.excel.easyexcel.api.converters.Converter;
import cn.report.excel.easyexcel.api.metadata.GlobalConfiguration;
import cn.report.excel.easyexcel.api.metadata.data.WriteCellData;
import cn.report.excel.easyexcel.api.metadata.property.ExcelContentProperty;

/**
 * Boxing Byte array and image converter
 *
 * @author Jiaju Zhuang
 */
public class BoxingByteArrayImageConverter implements Converter<Byte[]> {
    @Override
    public Class<?> supportJavaTypeKey() {
        return Byte[].class;
    }

    @Override
    public WriteCellData<?> convertToExcelData(Byte[] value, ExcelContentProperty contentProperty,
        GlobalConfiguration globalConfiguration) {
        byte[] byteValue = new byte[value.length];
        for (int i = 0; i < value.length; i++) {
            byteValue[i] = value[i];
        }
        return new WriteCellData<>(byteValue);
    }

}
