12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package com.oqpo.api.enums;
- import com.oqpo.api.exception.GlobalException;
- import lombok.Getter;
- import lombok.Setter;
- public enum WeightUnit {
- KG("10", "kg"), //
- G("20", "g"), //
- MG("30", "mg"), //
- TON("40", "ton"), //
- ;
- WeightUnit(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) {
- WeightUnit[] values = WeightUnit.values();
- for (WeightUnit icd : values) {
- if (icd.name.equals(nname)) {
- return icd.cd;
- }
- }
- throw new GlobalException(SystemMessageCode.ERR_CODE_NM);
- }
- public static String getName(String ccd) {
- WeightUnit[] values = WeightUnit.values();
- for (WeightUnit icd : values) {
- if (icd.cd.equals(ccd)) {
- return icd.name;
- }
- }
- return ccd;
- }
- }
|