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;

/**
 * @desc: 地址类型
 * @author: lt
 * @date: 2024/4/3 10:48
 */
@AllArgsConstructor
@Getter
public enum AddressLoadOrUnLoadAddressTypeEnum {
    MINE(1, "矿山"),
    METALLURGICAL_PLANT(2, "冶金厂"),
    CEMENT_PLANT(3, "水泥厂"),
    COMMERCIAL_MIXING_PLANT(4, "商混站"),
    LOGISTICS_PARK(5, "物流园"),
    PORT(6, "港口"),
    PLATFORM(7, "站台"),
    OTHER(8, "其它");

    private final Integer code;
    private final String msg;

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

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