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

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 虚拟产值计算方式枚举。
 */
@Getter
@AllArgsConstructor
public enum ProjectPlanningVirtualCalculationMethodEnum {

    GUIDANCE_PRICE("guidance_price", "指导单价法"),
    GUIDANCE_TOTAL_PRICE("guidance_total_price", "指导总价法"),
    WORKING_DAY("working_day", "工日法");

    private final String code;
    private final String label;

    public static ProjectPlanningVirtualCalculationMethodEnum 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) {
        ProjectPlanningVirtualCalculationMethodEnum item = of(code);
        return item == null ? code : item.getLabel();
    }

}
