package com.ningdatech.carapi.common.constant;

import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Objects;

/**
 * 保险公司
 *
 * @author PoffyZhang
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "InsureCompanyEnum", description = "保险公司-枚举")
public enum InsureCompanyEnum {
    /**
     * 阳光财产
     */
    SUN(1, "阳光财产"),

    /**
     * 人寿财产
     */
    LIFE(2, "人寿财产"),

    /**
     * 大地财产
     */
    LAND(3, "大地财产"),

    /**
     * 太平洋财产
     */
    PACIFIC(4, "太平洋财产"),

    /**
     * 人民财产
     */
    PEOPLE(5, "人民财产"),

    /**
     * 中华联合
     */
    CHUT(6, "中华联合"),

    /**
     * 其他保险
     */
    OTHER(99, "其他保险");


    private Integer code;
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static String getNameByCode(Integer code) {
        if(Objects.isNull(code)){
            return StringUtils.EMPTY;
        }
        for (InsureCompanyEnum t : InsureCompanyEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.name;
            }
        }
        return StringUtils.EMPTY;
    }


    public boolean eq(String val) {
        return this.name().equals(val);
    }

    public static List<String> getNames() {
        List<String> res = Lists.newArrayList();
        for(InsureCompanyEnum e : InsureCompanyEnum.values()){
            res.add(e.getName());
        }
        return res;
    }

}
