
package cn.orionsec.ops.constant.app;

import cn.orionsec.ops.constant.CnConst;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum RepositoryAuthType {

    /**
     * 密码
     */
    PASSWORD(10, CnConst.PASSWORD),

    /**
     * 私人令牌
     */
    TOKEN(20, CnConst.TOKEN),

    ;

    private final Integer type;

    private final String label;

    public static RepositoryAuthType of(Integer type) {
        if (type == null) {
            return null;
        }
        for (RepositoryAuthType value : values()) {
            if (value.type.equals(type)) {
                return value;
            }
        }
        return null;
    }

    public static RepositoryAuthType of(String label) {
        if (label == null) {
            return null;
        }
        for (RepositoryAuthType value : values()) {
            if (value.label.equals(label)) {
                return value;
            }
        }
        return null;
    }

}
