package com.qmth.boot.test.tools.excel.model;

import com.qmth.boot.tools.excel.convertor.ValueConvertor;
import com.qmth.boot.tools.excel.model.FieldParam;
import org.apache.poi.ss.usermodel.Cell;

public class GenderEnumConvertor implements ValueConvertor<GenderEnum> {

    @Override
    public void format(GenderEnum object, FieldParam param, Cell cell) throws Exception {
        cell.setCellValue(object.getName());
    }

    @Override
    public GenderEnum parse(String value, FieldParam param) throws Exception {
        for (GenderEnum obj : GenderEnum.values()) {
            if (obj.getName().equals(value) || obj.toString().equalsIgnoreCase(value)) {
                return obj;
            }
        }
        return null;
    }
}
