package com.sckw.mine.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@AllArgsConstructor
@Getter
public enum WorkFlowTypeEnum {
    ONE(1, "原矿料采集"),
    TWO(2, "矿料采集加工")
    ;

    private final Integer code;
    private final String msg;


    public static String getNameByCode(Integer code) {
        WorkFlowTypeEnum[] enums = WorkFlowTypeEnum.values();
        for (WorkFlowTypeEnum instance : enums) {
            if (Objects.equals(instance.getCode(), code)) {
                return instance.getMsg();
            }
        }
        return null;
    }

    public static List<WorkFlowTypeEnum> getSortList() {
        WorkFlowTypeEnum[] enums = WorkFlowTypeEnum.values();
        return Arrays.stream(enums).sorted(Comparator.comparingInt(WorkFlowTypeEnum::getCode)).collect(Collectors.toList());
    }
}
