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

import org.apache.commons.lang3.StringUtils;

/**
 * 合同收发货允许规则-是否允许收发货(字典：CONTRACT_RECEIVING_SHIPPING_ALLOW_RULES)
 * 枚举(字典：CONTRACT_RECEIVING_SHIPPING_ALLOW_RULES)
 *
 */
public enum ContractReceivingShippingAllowEnum {
    ALLOW_RECEIVING_AND_SHIPPING("ALLOW_RECEIVING_AND_SHIPPING", "允许收发货"),
    NOT_ALLOW_RECEIVING_AND_SHIPPING("NOT_ALLOW_RECEIVING_AND_SHIPPING","不允许收发货"),
    ;


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

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

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

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

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

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

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

}
