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 9:43
 */
@AllArgsConstructor
@Getter
public enum AddressTypeEnum {
    LOAD_ADDRESS(1, "装货"),   //装货
    UNLOAD_ADDRESS(2, "卸货"),   //卸货
    SHIPMENT(3, "装卸货");   //卸货

    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<AddressTypeEnum> getSortList() {
        AddressTypeEnum[] enums = AddressTypeEnum.values();
        return Arrays.stream(enums).sorted(Comparator.comparingInt(AddressTypeEnum::getCode)).collect(Collectors.toList());
    }
}
