package cn.com.qmth.stmms.common.enums;

import java.util.LinkedList;
import java.util.List;

public enum SchoolLevel {
    NONE("", 0), PRIMARY("小学", 1), JUNIOR("初中", 2), SENIOR("高中", 3), MIDDLE("中学", 4), COLLEGE("大学", 5), POSTGRADUATE(
            "研究生", 6);

    private String name;

    private int value;

    private static List<SchoolLevel> list;

    private SchoolLevel(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public int getValue() {
        return value;
    }

    public static List<SchoolLevel> getLevelList() {
        if (list == null) {
            list = new LinkedList<SchoolLevel>();
            for (SchoolLevel level : SchoolLevel.values()) {
                if (level.value > 0) {
                    list.add(level);
                }
            }
        }
        return list;
    }

    public static SchoolLevel findByValue(int value) {
        SchoolLevel level = null;
        for (SchoolLevel s : SchoolLevel.values()) {
            if (s.getValue() == value) {
                level = s;
                break;
            }
        }
        return level;
    }
}
