package com.apobates.forum.utils;

import com.apobates.forum.utils.lang.EnumArchitecture;
import java.util.stream.Stream;

/**
 *
 * @author xiaofanku
 * @since 20200512
 */
public enum TipMessageLevelEnum implements EnumArchitecture{
    ACC("acc", 1), ERR("err", 0), IBB("ibb", 2);
    private final String level;
    private final int category;
    
    private TipMessageLevelEnum(String level, int category) {
        this.level = level;
        this.category = category;
    }
    
    // GET/SET
    public String getLevel() {
        return level;
    }
    
    public int getCategory() {
        return category;
    }
    
    public static TipMessageLevelEnum getInstance(boolean symbol) {
        if (symbol) {
            return TipMessageLevelEnum.ACC;
        }
        return TipMessageLevelEnum.ERR;
    }
    
    public static TipMessageLevelEnum getInstance(String level) {
        return Stream.of(values()).filter(tmp->tmp.getLevel().toLowerCase().equals(level.toLowerCase())).findFirst().orElse(TipMessageLevelEnum.ERR);
    }
    
    @Override
    public int getSymbol() {
        return getCategory();
    }
    
    @Override
    public String getTitle() {
        return getLevel();
    }
}