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 0003 10:12
 */
@AllArgsConstructor
@Getter
public enum AddressLoadOrUnLoadHandlingEnum {

    SINGLE(1, "单装卸"),
    MORE(2, "多装卸");

    private final Integer code;
    private final String msg;


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

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