package com.oqpo.api.enums;

import com.oqpo.api.exception.GlobalException;
import lombok.Getter;
import lombok.Setter;

public enum DstrbtCostUnit {

    CBM("CBM", "부피"), //
    EA("EA", "개수"), //
    BOX("BOX", "박스"), //
    ;

    DstrbtCostUnit(String cd, String nm) {
        this.cd = cd;
        this.name = nm;
    }

    @Getter
    @Setter
    private String cd;

    @Getter
    @Setter
    private String name;

    public static String getCd(String nname) {
        DstrbtCostUnit[] values = DstrbtCostUnit.values();
        for (DstrbtCostUnit icd : values) {
            if (icd.name.equals(nname)) {
                return icd.cd;
            }
        }
        return nname;
    }

    public static String getName(String ccd) {
        DstrbtCostUnit[] values = DstrbtCostUnit.values();
        for (DstrbtCostUnit icd : values) {
            if (icd.cd.equals(ccd)) {
                return icd.name;
            }
        }
        return ccd;
    }

}
