package com.oqpo.api.enums;

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

public enum VolumeUnit {

    CM3("10", "cm³"), //
    M3("20", "m³"), //
    L("30", "L"), //
    ML("40", "ml"), //
    ;

    VolumeUnit(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) {
        VolumeUnit[] values = VolumeUnit.values();
        for (VolumeUnit icd : values) {
            if (icd.name.equals(nname)) {
                return icd.cd;
            }
        }
        return nname;
    }

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

}
