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 TransportUnderEnum {

    ONE(1, "自有物流"),
    TWO(2, "非自有/不承接");

    private final Integer code;
    private final String msg;


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

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