package com.microservices.pms.enums;

import com.microservices.common.core.exception.ServiceException;
import io.swagger.annotations.ApiModel;
import lombok.Getter;

/**
 * @author OTTO
 */
@Getter
@ApiModel("来源类型")
public enum ProductLibraryRepoFromTypeEnum {
    COMMON("common", "普通类型"),
    PIPELINE("pipeline", "流水线类型"),
    DOC("doc", "文档类型");

    private final String key;
    private final String name;

    ProductLibraryRepoFromTypeEnum(String key, String name) {
        this.key = key;
        this.name = name;
    }


    public static ProductLibraryRepoFromTypeEnum getByKey(String key) {
        for (ProductLibraryRepoFromTypeEnum typeEnum : ProductLibraryRepoFromTypeEnum.values()) {
            if (typeEnum.key.equals(key)) {
                return typeEnum;
            }
        }
        throw new ServiceException("该来源类型不存在(来源类型[%s])", key);
    }
}
