package com.apobates.forum.attention;

import java.util.stream.Stream;

/**
 * 图片存储目录的枚举
 * @author xiaofanku
 * @since 20200516
 */
public enum ImageDirectoryEnum {
    DEFAT(0, "默认"), LOCAL(1, "本地");
    
    private final int symbol;
    private final String title;
    
    private ImageDirectoryEnum(int symbol, String title) {
        this.symbol = symbol;
        this.title = title;
    }
    
    public int getSymbol() {
        return symbol;
    }
    
    public String getTitle() {
        return title;
    }
    
    /**
     * 使用参数与enum的name作无区分大小匹配
     *
     * @param name 目录
     * @return 匹配失败返回null
     */
    public static ImageDirectoryEnum getInstance(String name) {
        return Stream.of(values()).filter(ide->ide.name().equalsIgnoreCase(name)).findFirst().orElse(null);
    }
}