package com.sckw.usual.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 MoreTruckTypeEnum {
    ONE(1, "铲车"),
    TWO(2, "渣土车");

    private final Integer code;
    private final String msg;


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

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