package com.qmth.boot.core.solar.enums;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 机构二级分类枚举
 */
public enum OrgSubType {

    NETWORK(OrgType.UNIVERSITY, "高校网院"),
    ACADEMIC(OrgType.UNIVERSITY, "高校教务处"),
    UNDERGRADUATE(OrgType.UNIVERSITY, "本科招办"),
    POSTGRADUATE(OrgType.UNIVERSITY, "研究生招办");

    private static Map<OrgType, OrgSubType[]> map;

    static {
        map = new HashMap<>();
        for (OrgType parent : OrgType.values()) {
            map.put(parent, Arrays.stream(OrgSubType.values()).filter(type -> type.parent == parent)
                    .toArray(OrgSubType[]::new));
        }
    }

    private OrgType parent;

    private String name;

    OrgSubType(OrgType parent, String name) {
        this.parent = parent;
        this.name = name;
    }

    public OrgType getParent() {
        return parent;
    }

    public String getName() {
        return name;
    }

    public static OrgSubType[] findByParent(OrgType type) {
        return map.get(type);
    }

}
