package com.jwipc.supplier.constant;

import lombok.Getter;

import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 供应商采购品类的状态
 * <p> 状态 1.注册 2.潜在 3.正式 4.临时 5.退出 6.合格</p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@Getter
public enum AuthenticationState {
    /**
     * 单例对象
     */
    INIT(-1, "初始化"),
    REGISTER(1, "注册"),
    POTENTIAL(2, "潜在"),
    FORMAL(3, "正式"),
    TEMPORARY(4, "临时"),
    QUIT(5, "退出"),
    QUALIFIED(6, "合格"),
    SMALL_BATCH(7, "小批量");
    private final int state;
    private final String title;

    AuthenticationState(int state, String title) {

        this.state = state;
        this.title = title;
    }

    public static Set<String> getAllTitle() {
        return Arrays.stream(values()).map(AuthenticationState::getTitle).collect(Collectors.toSet());
    }

    public static AuthenticationState getByTitle(String title) {
        for (AuthenticationState value : values()) {
            if (title.equals(value.getTitle())) {
                return value;
            }
        }
        return null;
    }
}
