package cn.iocoder.lyzsys.module.tjt.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 指导价法设计部位枚举。
 */
@Getter
@AllArgsConstructor
public enum ProjectPlanningDesignPartEnum {

    ABOVE_GROUND("above_ground", "地上部分"),
    UNDERGROUND("underground", "地下部分"),
    OTHER("other", "其他");

    private final String code;
    private final String label;

    public static ProjectPlanningDesignPartEnum of(String code) {
        return Arrays.stream(values())
                .filter(item -> item.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }

    public static boolean contains(String code) {
        return of(code) != null;
    }

    public static String labelOf(String code) {
        ProjectPlanningDesignPartEnum item = of(code);
        return item == null ? code : item.getLabel();
    }

}
