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

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 合约规划产值计算方式枚举。
 */
@Getter
@AllArgsConstructor
public enum ProjectPlanningCalculationMethodEnum {

    GUIDANCE_PRICE("guidance_price", "指导价法"),
    CONTRACT_PRICE("contract_price", "合同价法"),
    VIRTUAL_OUTPUT("virtual_output", "虚拟产值法");

    private final String code;
    private final String label;

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

}
