package com.tzld.piaoquan.recommend.server.common.enums;

import lombok.Getter;
import lombok.ToString;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
@ToString
public enum TabType {

    territory("territory", "地域"),
    personalization("personalization", "个性化"),

    other("other", "其他"),

    ;
    private final String type;
    private final String desc;

    private static final Map<String, TabType> typeMap = Arrays.stream(TabType.values())
            .collect(Collectors.toMap(TabType::getType, Function.identity()));

    TabType(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static TabType getByType(String type) {
        return typeMap.getOrDefault(type, other);
    }
}
