package cc.smtweb.framework.core.common;

import org.apache.commons.lang3.StringUtils;

/**
 * Created by Akmm at 2017/5/3 17:25
 * int、text型枚举
 */
public class StrEnum extends AbstractEnum<String, AbstractEnum.StrEnumBean> {
    @Override
    protected Object getSqlValue(StrEnumBean pbs) {
        return "'" + pbs.value + "'";
    }

    @Override
    protected AbstractEnum.StrEnumBean buildBean(String value, String name) {
        return new AbstractEnum.StrEnumBean(value, name);
    }

    //根据value获取name
    public String getNames(String value) {
        if (StringUtils.isEmpty(value)) return "";
        StringBuilder sb = new StringBuilder(128);
        for (String s : value.split(",")) {
            String n = getName(s);
            if (StringUtils.isNotEmpty(n)) sb.append(",").append(n);
        }
        return sb.substring(1);
    }
}
