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

import org.apache.commons.lang3.StringUtils;

/**
 * 合同收发货符号规则-符号比较类型(字典：CONTRACT_RECEIVING_SHIPPING_SYMBOL_RULES)
 * 枚举(字典：CONTRACT_RECEIVING_SHIPPING_SYMBOL_RULES)
 *
 */
public enum ContractReceivingShippingSymbolEnum {
    LESS_THAN("<", "小于"),
    LESS_THAN_OR_EQUAL("<=","小于等于"),
    GREATER_THAN(">","大于"),
    GREATER_THAN_OR_EQUAL(">=","大于等于"),
    EQUAL("=","等于"),
    NOT_EQUAL("!=","不等于"),
    ;


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

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

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

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

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

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

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

}
