package com.sckw.car.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 WaybillOrderStatusEnum {
    ONE(1, "草稿"),
    TWO(2, "提交")
    ;

    private final Integer code;
    private final String msg;


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

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