All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.robe.convert.excel.parsers.ParseEnum Maven / Gradle / Ivy

There is a newer version: 0.5.0.0-1039
Show newest version
package io.robe.convert.excel.parsers;

import org.apache.poi.ss.usermodel.Cell;

import java.lang.reflect.Field;

import static java.lang.Enum.valueOf;

public class ParseEnum implements IsParser {

    @Override
    public Object parse(Object o, Field field) {
        if (!field.getType().isEnum())
            return null;
        Class type = (Class) field.getType();
        Enum anEnum = valueOf(type, o.toString());
        return anEnum;
    }

    @Override
    public void setCell(Object o, Cell cell, Field field) {
        Enum anEnum = (Enum) o;
        if (anEnum != null) {
            cell.setCellValue(anEnum.name());
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy