package com.ningdatech.pmapi.meeting.entity.enumeration;

import lombok.Getter;

import java.util.Arrays;

/**
 * <p>
 * ExpertExtractRuleType
 * </p>
 *
 * @author WendyYang
 * @since 10:11 2022/7/26
 */
@Getter
public enum ExpertInviteTypeEnum {

    /**
     * 专家抽取类型
     */
    RANDOM(1, "随机邀请"),
    APPOINT(2, "指定邀请");

    private final Integer code;
    private final String name;

    ExpertInviteTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public boolean eq(Integer code) {
        return this.getCode().equals(code);
    }

    public static ExpertInviteTypeEnum getByCode(Integer code) {
        return Arrays.stream(values())
                .filter(w -> w.getCode().equals(code))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("无效的邀请类型"));
    }

}
