package com.oqpo.api.enums;

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

public enum HeightUnit {

    CM("10", "cm"), //
    M("20", "m"), //
    MM("30", "mm"), //
    KM("40", "km"), //
    INCH("50", "inch"), //
    FT("60", "ft"), //
    YD("70", "yd"), //
    ;

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

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

}
