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 MineralAggregateTypeEnum {
    ONE(1, "石灰石原料"),
    TWO(2, "石灰石加工品")
    ;

    private final Integer code;
    private final String msg;


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

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