package com.ningdatech.pmapi.expert.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author liuxinxin
 * @date 2022/7/26 下午1:38
 */
@AllArgsConstructor
@Getter
public enum ExpertApplyStatusEnum {

    // 待审核
    PENDING_REVIEW("pending_review"),
    // 审核通过
    PASSED("passed"),
    // 审核不通过
    REFUSED("refused"),
    // 已撤销
    REVOKED("revoked");
    private final String key;

    public static boolean contains(String key) {
        if (StringUtils.isBlank(key)) {
            return false;
        }
        for (ExpertApplyStatusEnum statusEnum : ExpertApplyStatusEnum.values()) {
            if (statusEnum.key.equals(key)) {
                return true;
            }
        }
        return false;
    }

    public static ExpertApplyStatusEnum of(String key) {
        for (ExpertApplyStatusEnum statusEnum : ExpertApplyStatusEnum.values()) {
            if (statusEnum.key.equals(key)) {
                return statusEnum;
            }
        }
        throw new IllegalArgumentException(String.format("Illegal ExpertApplyStatusEnum = %s", key));
    }
}
