package com.zt.plat.module.contractorder.enums.contractreceivesend;

import org.apache.commons.lang3.StringUtils;

/**
 * 合同收发货类型规则-类型(字典：CONTRACT_RECEIVING_SHIPPING_TYPE_RULES)
 * 枚举(字典：CONTRACT_RECEIVING_SHIPPING_TYPE_RULES)
 *
 */
public enum ContractReceivingShippingTypeEnum {
    GRADE("GRADE", "品位"),
    METALLICITY_QUANTITY("METALLICITY_QUANTITY","金属量"),
    NET_WEIGHT("NET_WEIGHT","净重"),
    WET_WEIGHT("WET_WEIGHT","湿重"),
    DTY_WEIGHT("DTY_WEIGHT","干重")
    ;


    /**
     * 编码
     */
    private String code;

    /**
     * 名称
     */
    private String name;

    ContractReceivingShippingTypeEnum(String code, String name){
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static ContractReceivingShippingTypeEnum getEnumByCode(String code){
        for (ContractReceivingShippingTypeEnum e : ContractReceivingShippingTypeEnum.values()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        return GRADE;
    }

    public static ContractReceivingShippingTypeEnum getEnumByName(String name){
        if (StringUtils.isEmpty(name)) return GRADE;
        for (ContractReceivingShippingTypeEnum e : ContractReceivingShippingTypeEnum.values()) {
            if (name.equals(e.getName())) {
                return e;
            }
        }
        return GRADE;
    }

    public static boolean containsCode(String code) {
        for (ContractReceivingShippingTypeEnum e : ContractReceivingShippingTypeEnum.values()) {
            if (e.getCode().equals(code)) {
                return true;
            }
        }
        return false;
    }

}
