package com.kamco.cd.training.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum DetectionClassification {
  ROAD("road", "도로", 10),
  BUILDING("building", "건물", 20),
  GREENHOUSE("greenhouse", "비닐하우스", 30),
  FIELD("field", "논/밭", 40),
  ORCHARD("orchard", "과수원", 50),
  GRASS("grass", "초지", 60),
  FOREST("forest", "숲", 70),
  WATER("water", "물", 80),
  STONE("stone", "모래/자갈", 90),
  WASTE("waste", "적치물", 100),
  CONTAINER("container", "컨테이너", 110),
  LAND("land", "일반토지", 120),
  SOLAR("solar", "태양광", 130),
  TANK("tank", "물탱크", 140),
  NDC("NDC", "미분류", 150),
  ETC("ETC", "기타", 160);

  private final String id;
  private final String desc;
  private final int order;

  /**
   * Optional: Helper method to get the enum from a String, case-insensitive, or return ETC if not
   * found.
   */
  public static DetectionClassification fromString(String text) {
    if (text == null || text.trim().isEmpty()) {
      return ETC;
    }

    try {
      return DetectionClassification.valueOf(text.toUpperCase());
    } catch (IllegalArgumentException e) {
      // If the string doesn't match any enum constant name, return ETC
      return ETC;
    }
  }

  /**
   * Desc 한글명 get 하기
   *
   * @return
   */
  public static String fromStrDesc(String text) {
    DetectionClassification dtf = fromString(text);
    return dtf.getDesc();
  }
}
