package jnpf.easyexcel;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class EasyEnumNamesConverter implements Converter<EasyEnumNames> {
    @Override
    public Class<?> supportJavaTypeKey() {
        return EasyEnumNames.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public WriteCellData<?> convertToExcelData(EasyEnumNames value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        if (contentProperty == null) {
            return null;
        } else {
            return new WriteCellData<>(value.getName());
        }
    }
}
